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,541 @@
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 Databases
14
+ include MsRestAzure
15
+
16
+ #
17
+ # Creates and initializes a new instance of the Databases 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
+ # Creates a new database or updates an existing database.
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 database_name [String] The name of the database.
35
+ # @param parameters [Database] The required parameters for creating or updating
36
+ # a database.
37
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
38
+ # will be added to the HTTP request.
39
+ #
40
+ # @return [Database] operation results.
41
+ #
42
+ def create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers:nil)
43
+ response = create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers:custom_headers).value!
44
+ response.body unless response.nil?
45
+ end
46
+
47
+ #
48
+ # @param resource_group_name [String] The name of the resource group that
49
+ # contains the resource. You can obtain this value from the Azure Resource
50
+ # Manager API or the portal.
51
+ # @param server_name [String] The name of the server.
52
+ # @param database_name [String] The name of the database.
53
+ # @param parameters [Database] The required parameters for creating or updating
54
+ # a database.
55
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
56
+ # will be added to the HTTP request.
57
+ #
58
+ # @return [Concurrent::Promise] promise which provides async access to http
59
+ # response.
60
+ #
61
+ def create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers:nil)
62
+ # Send request
63
+ promise = begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers:custom_headers)
64
+
65
+ promise = promise.then do |response|
66
+ # Defining deserialization method.
67
+ deserialize_method = lambda do |parsed_response|
68
+ result_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::Database.mapper()
69
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
70
+ end
71
+
72
+ # Waiting for response.
73
+ @client.get_long_running_operation_result(response, deserialize_method)
74
+ end
75
+
76
+ promise
77
+ end
78
+
79
+ #
80
+ # Deletes a database.
81
+ #
82
+ # @param resource_group_name [String] The name of the resource group that
83
+ # contains the resource. You can obtain this value from the Azure Resource
84
+ # Manager API or the portal.
85
+ # @param server_name [String] The name of the server.
86
+ # @param database_name [String] The name of the database.
87
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
88
+ # will be added to the HTTP request.
89
+ #
90
+ def delete(resource_group_name, server_name, database_name, custom_headers:nil)
91
+ response = delete_async(resource_group_name, server_name, database_name, custom_headers:custom_headers).value!
92
+ nil
93
+ end
94
+
95
+ #
96
+ # @param resource_group_name [String] The name of the resource group that
97
+ # contains the resource. You can obtain this value from the Azure Resource
98
+ # Manager API or the portal.
99
+ # @param server_name [String] The name of the server.
100
+ # @param database_name [String] The name of the database.
101
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
102
+ # will be added to the HTTP request.
103
+ #
104
+ # @return [Concurrent::Promise] promise which provides async access to http
105
+ # response.
106
+ #
107
+ def delete_async(resource_group_name, server_name, database_name, custom_headers:nil)
108
+ # Send request
109
+ promise = begin_delete_async(resource_group_name, server_name, database_name, custom_headers:custom_headers)
110
+
111
+ promise = promise.then do |response|
112
+ # Defining deserialization method.
113
+ deserialize_method = lambda do |parsed_response|
114
+ end
115
+
116
+ # Waiting for response.
117
+ @client.get_long_running_operation_result(response, deserialize_method)
118
+ end
119
+
120
+ promise
121
+ end
122
+
123
+ #
124
+ # Gets information about a database.
125
+ #
126
+ # @param resource_group_name [String] The name of the resource group that
127
+ # contains the resource. You can obtain this value from the Azure Resource
128
+ # Manager API or the portal.
129
+ # @param server_name [String] The name of the server.
130
+ # @param database_name [String] The name of the database.
131
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
132
+ # will be added to the HTTP request.
133
+ #
134
+ # @return [Database] operation results.
135
+ #
136
+ def get(resource_group_name, server_name, database_name, custom_headers:nil)
137
+ response = get_async(resource_group_name, server_name, database_name, custom_headers:custom_headers).value!
138
+ response.body unless response.nil?
139
+ end
140
+
141
+ #
142
+ # Gets information about a database.
143
+ #
144
+ # @param resource_group_name [String] The name of the resource group that
145
+ # contains the resource. You can obtain this value from the Azure Resource
146
+ # Manager API or the portal.
147
+ # @param server_name [String] The name of the server.
148
+ # @param database_name [String] The name of the database.
149
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
150
+ # will be added to the HTTP request.
151
+ #
152
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
153
+ #
154
+ def get_with_http_info(resource_group_name, server_name, database_name, custom_headers:nil)
155
+ get_async(resource_group_name, server_name, database_name, custom_headers:custom_headers).value!
156
+ end
157
+
158
+ #
159
+ # Gets information about a database.
160
+ #
161
+ # @param resource_group_name [String] The name of the resource group that
162
+ # contains the resource. You can obtain this value from the Azure Resource
163
+ # Manager API or the portal.
164
+ # @param server_name [String] The name of the server.
165
+ # @param database_name [String] The name of the database.
166
+ # @param [Hash{String => String}] A hash of custom headers that will be added
167
+ # to the HTTP request.
168
+ #
169
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
170
+ #
171
+ def get_async(resource_group_name, server_name, database_name, custom_headers:nil)
172
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
173
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
174
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
175
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
176
+ fail ArgumentError, 'database_name is nil' if database_name.nil?
177
+
178
+
179
+ request_headers = {}
180
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
181
+
182
+ # Set Headers
183
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
184
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
185
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/databases/{databaseName}'
186
+
187
+ request_url = @base_url || @client.base_url
188
+
189
+ options = {
190
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
191
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name},
192
+ query_params: {'api-version' => @client.api_version},
193
+ headers: request_headers.merge(custom_headers || {}),
194
+ base_url: request_url
195
+ }
196
+ promise = @client.make_request_async(:get, path_template, options)
197
+
198
+ promise = promise.then do |result|
199
+ http_response = result.response
200
+ status_code = http_response.status
201
+ response_content = http_response.body
202
+ unless status_code == 200
203
+ error_model = JSON.load(response_content)
204
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
205
+ end
206
+
207
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
208
+ # Deserialize Response
209
+ if status_code == 200
210
+ begin
211
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
212
+ result_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::Database.mapper()
213
+ result.body = @client.deserialize(result_mapper, parsed_response)
214
+ rescue Exception => e
215
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
216
+ end
217
+ end
218
+
219
+ result
220
+ end
221
+
222
+ promise.execute
223
+ end
224
+
225
+ #
226
+ # List all the databases in a given server.
227
+ #
228
+ # @param resource_group_name [String] The name of the resource group that
229
+ # contains the resource. You can obtain this value from the Azure Resource
230
+ # Manager API or the portal.
231
+ # @param server_name [String] The name of the server.
232
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
233
+ # will be added to the HTTP request.
234
+ #
235
+ # @return [DatabaseListResult] operation results.
236
+ #
237
+ def list_by_server(resource_group_name, server_name, custom_headers:nil)
238
+ response = list_by_server_async(resource_group_name, server_name, custom_headers:custom_headers).value!
239
+ response.body unless response.nil?
240
+ end
241
+
242
+ #
243
+ # List all the databases in a given server.
244
+ #
245
+ # @param resource_group_name [String] The name of the resource group that
246
+ # contains the resource. You can obtain this value from the Azure Resource
247
+ # Manager API or the portal.
248
+ # @param server_name [String] The name of the server.
249
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
250
+ # will be added to the HTTP request.
251
+ #
252
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
253
+ #
254
+ def list_by_server_with_http_info(resource_group_name, server_name, custom_headers:nil)
255
+ list_by_server_async(resource_group_name, server_name, custom_headers:custom_headers).value!
256
+ end
257
+
258
+ #
259
+ # List all the databases in a given server.
260
+ #
261
+ # @param resource_group_name [String] The name of the resource group that
262
+ # contains the resource. You can obtain this value from the Azure Resource
263
+ # Manager API or the portal.
264
+ # @param server_name [String] The name of the server.
265
+ # @param [Hash{String => String}] A hash of custom headers that will be added
266
+ # to the HTTP request.
267
+ #
268
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
269
+ #
270
+ def list_by_server_async(resource_group_name, server_name, custom_headers:nil)
271
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
272
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
273
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
274
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
275
+
276
+
277
+ request_headers = {}
278
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
279
+
280
+ # Set Headers
281
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
282
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
283
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/databases'
284
+
285
+ request_url = @base_url || @client.base_url
286
+
287
+ options = {
288
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
289
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name},
290
+ query_params: {'api-version' => @client.api_version},
291
+ headers: request_headers.merge(custom_headers || {}),
292
+ base_url: request_url
293
+ }
294
+ promise = @client.make_request_async(:get, path_template, options)
295
+
296
+ promise = promise.then do |result|
297
+ http_response = result.response
298
+ status_code = http_response.status
299
+ response_content = http_response.body
300
+ unless status_code == 200
301
+ error_model = JSON.load(response_content)
302
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
303
+ end
304
+
305
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
306
+ # Deserialize Response
307
+ if status_code == 200
308
+ begin
309
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
310
+ result_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::DatabaseListResult.mapper()
311
+ result.body = @client.deserialize(result_mapper, parsed_response)
312
+ rescue Exception => e
313
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
314
+ end
315
+ end
316
+
317
+ result
318
+ end
319
+
320
+ promise.execute
321
+ end
322
+
323
+ #
324
+ # Creates a new database or updates an existing database.
325
+ #
326
+ # @param resource_group_name [String] The name of the resource group that
327
+ # contains the resource. You can obtain this value from the Azure Resource
328
+ # Manager API or the portal.
329
+ # @param server_name [String] The name of the server.
330
+ # @param database_name [String] The name of the database.
331
+ # @param parameters [Database] The required parameters for creating or updating
332
+ # a database.
333
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
334
+ # will be added to the HTTP request.
335
+ #
336
+ # @return [Database] operation results.
337
+ #
338
+ def begin_create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers:nil)
339
+ response = begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers:custom_headers).value!
340
+ response.body unless response.nil?
341
+ end
342
+
343
+ #
344
+ # Creates a new database or updates an existing database.
345
+ #
346
+ # @param resource_group_name [String] The name of the resource group that
347
+ # contains the resource. You can obtain this value from the Azure Resource
348
+ # Manager API or the portal.
349
+ # @param server_name [String] The name of the server.
350
+ # @param database_name [String] The name of the database.
351
+ # @param parameters [Database] The required parameters for creating or updating
352
+ # a database.
353
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
354
+ # will be added to the HTTP request.
355
+ #
356
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
357
+ #
358
+ def begin_create_or_update_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers:nil)
359
+ begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers:custom_headers).value!
360
+ end
361
+
362
+ #
363
+ # Creates a new database or updates an existing database.
364
+ #
365
+ # @param resource_group_name [String] The name of the resource group that
366
+ # contains the resource. You can obtain this value from the Azure Resource
367
+ # Manager API or the portal.
368
+ # @param server_name [String] The name of the server.
369
+ # @param database_name [String] The name of the database.
370
+ # @param parameters [Database] The required parameters for creating or updating
371
+ # a database.
372
+ # @param [Hash{String => String}] A hash of custom headers that will be added
373
+ # to the HTTP request.
374
+ #
375
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
376
+ #
377
+ def begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers:nil)
378
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
379
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
380
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
381
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
382
+ fail ArgumentError, 'database_name is nil' if database_name.nil?
383
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
384
+
385
+
386
+ request_headers = {}
387
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
388
+
389
+ # Set Headers
390
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
391
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
392
+
393
+ # Serialize Request
394
+ request_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::Database.mapper()
395
+ request_content = @client.serialize(request_mapper, parameters)
396
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
397
+
398
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/databases/{databaseName}'
399
+
400
+ request_url = @base_url || @client.base_url
401
+
402
+ options = {
403
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
404
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name},
405
+ query_params: {'api-version' => @client.api_version},
406
+ body: request_content,
407
+ headers: request_headers.merge(custom_headers || {}),
408
+ base_url: request_url
409
+ }
410
+ promise = @client.make_request_async(:put, path_template, options)
411
+
412
+ promise = promise.then do |result|
413
+ http_response = result.response
414
+ status_code = http_response.status
415
+ response_content = http_response.body
416
+ unless status_code == 200 || status_code == 201 || status_code == 202
417
+ error_model = JSON.load(response_content)
418
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
419
+ end
420
+
421
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
422
+ # Deserialize Response
423
+ if status_code == 200
424
+ begin
425
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
426
+ result_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::Database.mapper()
427
+ result.body = @client.deserialize(result_mapper, parsed_response)
428
+ rescue Exception => e
429
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
430
+ end
431
+ end
432
+ # Deserialize Response
433
+ if status_code == 201
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::Database.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
+
443
+ result
444
+ end
445
+
446
+ promise.execute
447
+ end
448
+
449
+ #
450
+ # Deletes a database.
451
+ #
452
+ # @param resource_group_name [String] The name of the resource group that
453
+ # contains the resource. You can obtain this value from the Azure Resource
454
+ # Manager API or the portal.
455
+ # @param server_name [String] The name of the server.
456
+ # @param database_name [String] The name of the database.
457
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
458
+ # will be added to the HTTP request.
459
+ #
460
+ #
461
+ def begin_delete(resource_group_name, server_name, database_name, custom_headers:nil)
462
+ response = begin_delete_async(resource_group_name, server_name, database_name, custom_headers:custom_headers).value!
463
+ nil
464
+ end
465
+
466
+ #
467
+ # Deletes a database.
468
+ #
469
+ # @param resource_group_name [String] The name of the resource group that
470
+ # contains the resource. You can obtain this value from the Azure Resource
471
+ # Manager API or the portal.
472
+ # @param server_name [String] The name of the server.
473
+ # @param database_name [String] The name of the database.
474
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
475
+ # will be added to the HTTP request.
476
+ #
477
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
478
+ #
479
+ def begin_delete_with_http_info(resource_group_name, server_name, database_name, custom_headers:nil)
480
+ begin_delete_async(resource_group_name, server_name, database_name, custom_headers:custom_headers).value!
481
+ end
482
+
483
+ #
484
+ # Deletes a database.
485
+ #
486
+ # @param resource_group_name [String] The name of the resource group that
487
+ # contains the resource. You can obtain this value from the Azure Resource
488
+ # Manager API or the portal.
489
+ # @param server_name [String] The name of the server.
490
+ # @param database_name [String] The name of the database.
491
+ # @param [Hash{String => String}] A hash of custom headers that will be added
492
+ # to the HTTP request.
493
+ #
494
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
495
+ #
496
+ def begin_delete_async(resource_group_name, server_name, database_name, custom_headers:nil)
497
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
498
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
499
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
500
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
501
+ fail ArgumentError, 'database_name is nil' if database_name.nil?
502
+
503
+
504
+ request_headers = {}
505
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
506
+
507
+ # Set Headers
508
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
509
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
510
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/databases/{databaseName}'
511
+
512
+ request_url = @base_url || @client.base_url
513
+
514
+ options = {
515
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
516
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name},
517
+ query_params: {'api-version' => @client.api_version},
518
+ headers: request_headers.merge(custom_headers || {}),
519
+ base_url: request_url
520
+ }
521
+ promise = @client.make_request_async(:delete, path_template, options)
522
+
523
+ promise = promise.then do |result|
524
+ http_response = result.response
525
+ status_code = http_response.status
526
+ response_content = http_response.body
527
+ unless status_code == 200 || status_code == 202 || status_code == 204
528
+ error_model = JSON.load(response_content)
529
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
530
+ end
531
+
532
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
533
+
534
+ result
535
+ end
536
+
537
+ promise.execute
538
+ end
539
+
540
+ end
541
+ end