azure_mgmt_mysql 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql.rb +79 -0
  4. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/check_name_availability.rb +128 -0
  5. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/configurations.rb +402 -0
  6. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/databases.rb +549 -0
  7. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/firewall_rules.rb +549 -0
  8. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/location_based_performance_tier.rb +118 -0
  9. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/log_files.rb +128 -0
  10. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/configuration.rb +132 -0
  11. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/configuration_list_result.rb +55 -0
  12. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/database.rb +84 -0
  13. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/database_list_result.rb +55 -0
  14. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/firewall_rule.rb +92 -0
  15. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/firewall_rule_list_result.rb +55 -0
  16. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/geo_redundant_backup.rb +16 -0
  17. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/log_file.rb +119 -0
  18. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/log_file_list_result.rb +55 -0
  19. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/name_availability.rb +68 -0
  20. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/name_availability_request.rb +57 -0
  21. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/operation.rb +95 -0
  22. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/operation_display.rb +83 -0
  23. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/operation_list_result.rb +55 -0
  24. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/operation_origin.rb +17 -0
  25. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/performance_tier_list_result.rb +56 -0
  26. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/performance_tier_properties.rb +67 -0
  27. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/performance_tier_service_level_objectives.rb +126 -0
  28. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/proxy_resource.rb +71 -0
  29. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server.rb +220 -0
  30. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_for_create.rb +92 -0
  31. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_list_result.rb +55 -0
  32. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_properties_for_create.rb +86 -0
  33. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_properties_for_default_create.rb +100 -0
  34. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_properties_for_geo_restore.rb +88 -0
  35. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_properties_for_replica.rb +87 -0
  36. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_properties_for_restore.rb +99 -0
  37. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_security_alert_policy.rb +166 -0
  38. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_security_alert_policy_state.rb +16 -0
  39. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_state.rb +17 -0
  40. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_update_parameters.rb +126 -0
  41. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/server_version.rb +16 -0
  42. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/sku.rb +97 -0
  43. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/sku_tier.rb +17 -0
  44. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/ssl_enforcement_enum.rb +16 -0
  45. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/storage_autogrow.rb +16 -0
  46. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/storage_profile.rb +81 -0
  47. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/tracked_resource.rb +93 -0
  48. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/virtual_network_rule.rb +99 -0
  49. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/virtual_network_rule_list_result.rb +100 -0
  50. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/models/virtual_network_rule_state.rb +19 -0
  51. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/module_definition.rb +9 -0
  52. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/my_sqlmanagement_client.rb +172 -0
  53. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/operations.rb +112 -0
  54. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/replicas.rb +128 -0
  55. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/server_security_alert_policies.rb +294 -0
  56. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/servers.rb +918 -0
  57. data/lib/2017-12-01-preview/generated/azure_mgmt_mysql/virtual_network_rules.rb +676 -0
  58. data/lib/2017-12-01/generated/azure_mgmt_mysql.rb +79 -0
  59. data/lib/2017-12-01/generated/azure_mgmt_mysql/check_name_availability.rb +128 -0
  60. data/lib/2017-12-01/generated/azure_mgmt_mysql/configurations.rb +402 -0
  61. data/lib/2017-12-01/generated/azure_mgmt_mysql/databases.rb +549 -0
  62. data/lib/2017-12-01/generated/azure_mgmt_mysql/firewall_rules.rb +549 -0
  63. data/lib/2017-12-01/generated/azure_mgmt_mysql/location_based_performance_tier.rb +118 -0
  64. data/lib/2017-12-01/generated/azure_mgmt_mysql/log_files.rb +128 -0
  65. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/configuration.rb +132 -0
  66. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/configuration_list_result.rb +55 -0
  67. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/database.rb +84 -0
  68. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/database_list_result.rb +55 -0
  69. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/firewall_rule.rb +92 -0
  70. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/firewall_rule_list_result.rb +55 -0
  71. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/geo_redundant_backup.rb +16 -0
  72. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/log_file.rb +119 -0
  73. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/log_file_list_result.rb +55 -0
  74. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/name_availability.rb +68 -0
  75. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/name_availability_request.rb +57 -0
  76. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/operation.rb +95 -0
  77. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/operation_display.rb +83 -0
  78. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/operation_list_result.rb +55 -0
  79. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/operation_origin.rb +17 -0
  80. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/performance_tier_list_result.rb +56 -0
  81. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/performance_tier_properties.rb +67 -0
  82. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/performance_tier_service_level_objectives.rb +126 -0
  83. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/proxy_resource.rb +71 -0
  84. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server.rb +220 -0
  85. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_for_create.rb +92 -0
  86. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_list_result.rb +55 -0
  87. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_properties_for_create.rb +86 -0
  88. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_properties_for_default_create.rb +100 -0
  89. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_properties_for_geo_restore.rb +88 -0
  90. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_properties_for_replica.rb +87 -0
  91. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_properties_for_restore.rb +99 -0
  92. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_security_alert_policy.rb +166 -0
  93. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_security_alert_policy_state.rb +16 -0
  94. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_state.rb +17 -0
  95. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_update_parameters.rb +126 -0
  96. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/server_version.rb +16 -0
  97. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/sku.rb +97 -0
  98. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/sku_tier.rb +17 -0
  99. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/ssl_enforcement_enum.rb +16 -0
  100. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/storage_autogrow.rb +16 -0
  101. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/storage_profile.rb +81 -0
  102. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/tracked_resource.rb +93 -0
  103. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/virtual_network_rule.rb +99 -0
  104. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/virtual_network_rule_list_result.rb +100 -0
  105. data/lib/2017-12-01/generated/azure_mgmt_mysql/models/virtual_network_rule_state.rb +19 -0
  106. data/lib/2017-12-01/generated/azure_mgmt_mysql/module_definition.rb +9 -0
  107. data/lib/2017-12-01/generated/azure_mgmt_mysql/my_sqlmanagement_client.rb +172 -0
  108. data/lib/2017-12-01/generated/azure_mgmt_mysql/operations.rb +112 -0
  109. data/lib/2017-12-01/generated/azure_mgmt_mysql/replicas.rb +128 -0
  110. data/lib/2017-12-01/generated/azure_mgmt_mysql/server_security_alert_policies.rb +294 -0
  111. data/lib/2017-12-01/generated/azure_mgmt_mysql/servers.rb +918 -0
  112. data/lib/2017-12-01/generated/azure_mgmt_mysql/virtual_network_rules.rb +676 -0
  113. data/lib/azure_mgmt_mysql.rb +7 -0
  114. data/lib/module_definition.rb +7 -0
  115. data/lib/profiles/latest/modules/mysql_profile_module.rb +245 -0
  116. data/lib/profiles/latest/mysql_latest_profile_client.rb +40 -0
  117. data/lib/profiles/latest/mysql_module_definition.rb +8 -0
  118. data/lib/version.rb +7 -0
  119. metadata +234 -0
@@ -0,0 +1,549 @@
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::Mysql::Mgmt::V2017_12_01
7
+ #
8
+ # The Microsoft Azure management API provides create, read, update, and
9
+ # delete functionality for Azure MySQL resources including servers,
10
+ # databases, firewall rules, VNET rules, log files and configurations with
11
+ # 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 [MySQLManagementClient] reference to the MySQLManagementClient
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::Mysql::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.DBforMySQL/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
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
209
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
210
+ # Deserialize Response
211
+ if status_code == 200
212
+ begin
213
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
214
+ result_mapper = Azure::Mysql::Mgmt::V2017_12_01::Models::Database.mapper()
215
+ result.body = @client.deserialize(result_mapper, parsed_response)
216
+ rescue Exception => e
217
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
218
+ end
219
+ end
220
+
221
+ result
222
+ end
223
+
224
+ promise.execute
225
+ end
226
+
227
+ #
228
+ # List all the databases in a given server.
229
+ #
230
+ # @param resource_group_name [String] The name of the resource group that
231
+ # contains the resource. You can obtain this value from the Azure Resource
232
+ # Manager API or the portal.
233
+ # @param server_name [String] The name of the server.
234
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
235
+ # will be added to the HTTP request.
236
+ #
237
+ # @return [DatabaseListResult] operation results.
238
+ #
239
+ def list_by_server(resource_group_name, server_name, custom_headers:nil)
240
+ response = list_by_server_async(resource_group_name, server_name, custom_headers:custom_headers).value!
241
+ response.body unless response.nil?
242
+ end
243
+
244
+ #
245
+ # List all the databases in a given server.
246
+ #
247
+ # @param resource_group_name [String] The name of the resource group that
248
+ # contains the resource. You can obtain this value from the Azure Resource
249
+ # Manager API or the portal.
250
+ # @param server_name [String] The name of the server.
251
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
252
+ # will be added to the HTTP request.
253
+ #
254
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
255
+ #
256
+ def list_by_server_with_http_info(resource_group_name, server_name, custom_headers:nil)
257
+ list_by_server_async(resource_group_name, server_name, custom_headers:custom_headers).value!
258
+ end
259
+
260
+ #
261
+ # List all the databases in a given server.
262
+ #
263
+ # @param resource_group_name [String] The name of the resource group that
264
+ # contains the resource. You can obtain this value from the Azure Resource
265
+ # Manager API or the portal.
266
+ # @param server_name [String] The name of the server.
267
+ # @param [Hash{String => String}] A hash of custom headers that will be added
268
+ # to the HTTP request.
269
+ #
270
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
271
+ #
272
+ def list_by_server_async(resource_group_name, server_name, custom_headers:nil)
273
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
274
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
275
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
276
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
277
+
278
+
279
+ request_headers = {}
280
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
281
+
282
+ # Set Headers
283
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
284
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
285
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/databases'
286
+
287
+ request_url = @base_url || @client.base_url
288
+
289
+ options = {
290
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
291
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name},
292
+ query_params: {'api-version' => @client.api_version},
293
+ headers: request_headers.merge(custom_headers || {}),
294
+ base_url: request_url
295
+ }
296
+ promise = @client.make_request_async(:get, path_template, options)
297
+
298
+ promise = promise.then do |result|
299
+ http_response = result.response
300
+ status_code = http_response.status
301
+ response_content = http_response.body
302
+ unless status_code == 200
303
+ error_model = JSON.load(response_content)
304
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
305
+ end
306
+
307
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
308
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
309
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
310
+ # Deserialize Response
311
+ if status_code == 200
312
+ begin
313
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
314
+ result_mapper = Azure::Mysql::Mgmt::V2017_12_01::Models::DatabaseListResult.mapper()
315
+ result.body = @client.deserialize(result_mapper, parsed_response)
316
+ rescue Exception => e
317
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
318
+ end
319
+ end
320
+
321
+ result
322
+ end
323
+
324
+ promise.execute
325
+ end
326
+
327
+ #
328
+ # Creates a new database or updates an existing database.
329
+ #
330
+ # @param resource_group_name [String] The name of the resource group that
331
+ # contains the resource. You can obtain this value from the Azure Resource
332
+ # Manager API or the portal.
333
+ # @param server_name [String] The name of the server.
334
+ # @param database_name [String] The name of the database.
335
+ # @param parameters [Database] The required parameters for creating or updating
336
+ # a database.
337
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
338
+ # will be added to the HTTP request.
339
+ #
340
+ # @return [Database] operation results.
341
+ #
342
+ def begin_create_or_update(resource_group_name, server_name, database_name, parameters, custom_headers:nil)
343
+ response = begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers:custom_headers).value!
344
+ response.body unless response.nil?
345
+ end
346
+
347
+ #
348
+ # Creates a new database or updates an existing database.
349
+ #
350
+ # @param resource_group_name [String] The name of the resource group that
351
+ # contains the resource. You can obtain this value from the Azure Resource
352
+ # Manager API or the portal.
353
+ # @param server_name [String] The name of the server.
354
+ # @param database_name [String] The name of the database.
355
+ # @param parameters [Database] The required parameters for creating or updating
356
+ # a database.
357
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
358
+ # will be added to the HTTP request.
359
+ #
360
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
361
+ #
362
+ def begin_create_or_update_with_http_info(resource_group_name, server_name, database_name, parameters, custom_headers:nil)
363
+ begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers:custom_headers).value!
364
+ end
365
+
366
+ #
367
+ # Creates a new database or updates an existing database.
368
+ #
369
+ # @param resource_group_name [String] The name of the resource group that
370
+ # contains the resource. You can obtain this value from the Azure Resource
371
+ # Manager API or the portal.
372
+ # @param server_name [String] The name of the server.
373
+ # @param database_name [String] The name of the database.
374
+ # @param parameters [Database] The required parameters for creating or updating
375
+ # a database.
376
+ # @param [Hash{String => String}] A hash of custom headers that will be added
377
+ # to the HTTP request.
378
+ #
379
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
380
+ #
381
+ def begin_create_or_update_async(resource_group_name, server_name, database_name, parameters, custom_headers:nil)
382
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
383
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
384
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
385
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
386
+ fail ArgumentError, 'database_name is nil' if database_name.nil?
387
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
388
+
389
+
390
+ request_headers = {}
391
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
392
+
393
+ # Set Headers
394
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
395
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
396
+
397
+ # Serialize Request
398
+ request_mapper = Azure::Mysql::Mgmt::V2017_12_01::Models::Database.mapper()
399
+ request_content = @client.serialize(request_mapper, parameters)
400
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
401
+
402
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/databases/{databaseName}'
403
+
404
+ request_url = @base_url || @client.base_url
405
+
406
+ options = {
407
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
408
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name},
409
+ query_params: {'api-version' => @client.api_version},
410
+ body: request_content,
411
+ headers: request_headers.merge(custom_headers || {}),
412
+ base_url: request_url
413
+ }
414
+ promise = @client.make_request_async(:put, path_template, options)
415
+
416
+ promise = promise.then do |result|
417
+ http_response = result.response
418
+ status_code = http_response.status
419
+ response_content = http_response.body
420
+ unless status_code == 200 || status_code == 201 || status_code == 202
421
+ error_model = JSON.load(response_content)
422
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
423
+ end
424
+
425
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
426
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
427
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
428
+ # Deserialize Response
429
+ if status_code == 200
430
+ begin
431
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
432
+ result_mapper = Azure::Mysql::Mgmt::V2017_12_01::Models::Database.mapper()
433
+ result.body = @client.deserialize(result_mapper, parsed_response)
434
+ rescue Exception => e
435
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
436
+ end
437
+ end
438
+ # Deserialize Response
439
+ if status_code == 201
440
+ begin
441
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
442
+ result_mapper = Azure::Mysql::Mgmt::V2017_12_01::Models::Database.mapper()
443
+ result.body = @client.deserialize(result_mapper, parsed_response)
444
+ rescue Exception => e
445
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
446
+ end
447
+ end
448
+
449
+ result
450
+ end
451
+
452
+ promise.execute
453
+ end
454
+
455
+ #
456
+ # Deletes a database.
457
+ #
458
+ # @param resource_group_name [String] The name of the resource group that
459
+ # contains the resource. You can obtain this value from the Azure Resource
460
+ # Manager API or the portal.
461
+ # @param server_name [String] The name of the server.
462
+ # @param database_name [String] The name of the database.
463
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
464
+ # will be added to the HTTP request.
465
+ #
466
+ #
467
+ def begin_delete(resource_group_name, server_name, database_name, custom_headers:nil)
468
+ response = begin_delete_async(resource_group_name, server_name, database_name, custom_headers:custom_headers).value!
469
+ nil
470
+ end
471
+
472
+ #
473
+ # Deletes a database.
474
+ #
475
+ # @param resource_group_name [String] The name of the resource group that
476
+ # contains the resource. You can obtain this value from the Azure Resource
477
+ # Manager API or the portal.
478
+ # @param server_name [String] The name of the server.
479
+ # @param database_name [String] The name of the database.
480
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
481
+ # will be added to the HTTP request.
482
+ #
483
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
484
+ #
485
+ def begin_delete_with_http_info(resource_group_name, server_name, database_name, custom_headers:nil)
486
+ begin_delete_async(resource_group_name, server_name, database_name, custom_headers:custom_headers).value!
487
+ end
488
+
489
+ #
490
+ # Deletes a database.
491
+ #
492
+ # @param resource_group_name [String] The name of the resource group that
493
+ # contains the resource. You can obtain this value from the Azure Resource
494
+ # Manager API or the portal.
495
+ # @param server_name [String] The name of the server.
496
+ # @param database_name [String] The name of the database.
497
+ # @param [Hash{String => String}] A hash of custom headers that will be added
498
+ # to the HTTP request.
499
+ #
500
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
501
+ #
502
+ def begin_delete_async(resource_group_name, server_name, database_name, custom_headers:nil)
503
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
504
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
505
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
506
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
507
+ fail ArgumentError, 'database_name is nil' if database_name.nil?
508
+
509
+
510
+ request_headers = {}
511
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
512
+
513
+ # Set Headers
514
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
515
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
516
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/databases/{databaseName}'
517
+
518
+ request_url = @base_url || @client.base_url
519
+
520
+ options = {
521
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
522
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'serverName' => server_name,'databaseName' => database_name},
523
+ query_params: {'api-version' => @client.api_version},
524
+ headers: request_headers.merge(custom_headers || {}),
525
+ base_url: request_url
526
+ }
527
+ promise = @client.make_request_async(:delete, path_template, options)
528
+
529
+ promise = promise.then do |result|
530
+ http_response = result.response
531
+ status_code = http_response.status
532
+ response_content = http_response.body
533
+ unless status_code == 200 || status_code == 202 || status_code == 204
534
+ error_model = JSON.load(response_content)
535
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
536
+ end
537
+
538
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
539
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
540
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
541
+
542
+ result
543
+ end
544
+
545
+ promise.execute
546
+ end
547
+
548
+ end
549
+ end