Skip to main content

timeweb_rs/apis/
databases_api.rs

1/*
2 * Документация публичного API
3 *
4 * # Введение API Timeweb Cloud позволяет вам управлять ресурсами в облаке программным способом с использованием обычных HTTP-запросов.  Множество функций, которые доступны в панели управления Timeweb Cloud, также доступны через API, что позволяет вам автоматизировать ваши собственные сценарии.  В этой документации сперва будет описан общий дизайн и принципы работы API, а после этого конкретные конечные точки. Также будут приведены примеры запросов к ним.   ## Запросы Запросы должны выполняться по протоколу `HTTPS`, чтобы гарантировать шифрование транзакций. Поддерживаются следующие методы запроса: |Метод|Применение| |--- |--- | |GET|Извлекает данные о коллекциях и отдельных ресурсах.| |POST|Для коллекций создает новый ресурс этого типа. Также используется для выполнения действий с конкретным ресурсом.| |PUT|Обновляет существующий ресурс.| |PATCH|Некоторые ресурсы поддерживают частичное обновление, то есть обновление только части атрибутов ресурса, в этом случае вместо метода PUT будет использован PATCH.| |DELETE|Удаляет ресурс.|  Методы `POST`, `PUT` и `PATCH` могут включать объект в тело запроса с типом содержимого `application/json`.  ### Параметры в запросах Некоторые коллекции поддерживают пагинацию, поиск или сортировку в запросах. В параметрах запроса требуется передать: - `limit` — обозначает количество записей, которое необходимо вернуть  - `offset` — указывает на смещение, относительно начала списка  - `search` — позволяет указать набор символов для поиска  - `sort` — можно задать правило сортировки коллекции  ## Ответы Запросы вернут один из следующих кодов состояния ответа HTTP:  |Статус|Описание| |--- |--- | |200 OK|Действие с ресурсом было выполнено успешно.| |201 Created|Ресурс был успешно создан. При этом ресурс может быть как уже готовым к использованию, так и находиться в процессе запуска.| |204 No Content|Действие с ресурсом было выполнено успешно, и ответ не содержит дополнительной информации в теле.| |400 Bad Request|Был отправлен неверный запрос, например, в нем отсутствуют обязательные параметры и т. д. Тело ответа будет содержать дополнительную информацию об ошибке.| |401 Unauthorized|Ошибка аутентификации.| |403 Forbidden|Аутентификация прошла успешно, но недостаточно прав для выполнения действия.| |404 Not Found|Запрашиваемый ресурс не найден.| |409 Conflict|Запрос конфликтует с текущим состоянием.| |423 Locked|Ресурс из запроса заблокирован от применения к нему указанного метода.| |429 Too Many Requests|Был достигнут лимит по количеству запросов в единицу времени.| |500 Internal Server Error|При выполнении запроса произошла какая-то внутренняя ошибка. Чтобы решить эту проблему, лучше всего создать тикет в панели управления.|  ### Структура успешного ответа Все конечные точки будут возвращать данные в формате `JSON`. Ответы на `GET`-запросы будут иметь на верхнем уровне следующую структуру атрибутов:  |Название поля|Тип|Описание| |--- |--- |--- | |[entity_name]|object, object[], string[], number[], boolean|Динамическое поле, которое будет меняться в зависимости от запрашиваемого ресурса и будет содержать все атрибуты, необходимые для описания этого ресурса. Например, при запросе списка баз данных будет возвращаться поле `dbs`, а при запросе конкретного облачного сервера `server`. Для некоторых конечных точек в ответе может возвращаться сразу несколько ресурсов.| |meta|object|Опционально. Объект, который содержит вспомогательную информацию о ресурсе. Чаще всего будет встречаться при запросе коллекций и содержать поле `total`, которое будет указывать на количество элементов в коллекции.| |response_id|string|Опционально. В большинстве случаев в ответе будет содержаться ID ответа в формате UUIDv4, который однозначно указывает на ваш запрос внутри нашей системы. Если вам потребуется задать вопрос нашей поддержке, приложите к вопросу этот ID— так мы сможем найти ответ на него намного быстрее. Также вы можете использовать этот ID, чтобы убедиться, что это новый ответ на запрос и результат не был получен из кэша.|  Пример запроса на получение списка SSH-ключей: ```     HTTP/2.0 200 OK     {       \"ssh_keys\":[           {             \"body\":\"ssh-rsa AAAAB3NzaC1sdfghjkOAsBwWhs= example@device.local\",             \"created_at\":\"2021-09-15T19:52:27Z\",             \"expired_at\":null,             \"id\":5297,             \"is_default\":false,             \"name\":\"example@device.local\",             \"used_at\":null,             \"used_by\":[]           }       ],       \"meta\":{           \"total\":1       },       \"response_id\":\"94608d15-8672-4eed-8ab6-28bd6fa3cdf7\"     } ```  ### Структура ответа с ошибкой |Название поля|Тип|Описание| |--- |--- |--- | |status_code|number|Короткий числовой идентификатор ошибки.| |error_code|string|Короткий текстовый идентификатор ошибки, который уточняет числовой идентификатор и удобен для программной обработки. Самый простой пример — это код `not_found` для ошибки 404.| |message|string, string[]|Опционально. В большинстве случаев в ответе будет содержаться человекочитаемое подробное описание ошибки или ошибок, которые помогут понять, что нужно исправить.| |response_id|string|Опционально. В большинстве случае в ответе будет содержаться ID ответа в формате UUIDv4, который однозначно указывает на ваш запрос внутри нашей системы. Если вам потребуется задать вопрос нашей поддержке, приложите к вопросу этот ID — так мы сможем найти ответ на него намного быстрее.|  Пример: ```     HTTP/2.0 403 Forbidden     {       \"status_code\": 403,       \"error_code\":  \"forbidden\",       \"message\":     \"You do not have access for the attempted action\",       \"response_id\": \"94608d15-8672-4eed-8ab6-28bd6fa3cdf7\"     } ```  ## Статусы ресурсов Важно учесть, что при создании большинства ресурсов внутри платформы вам будет сразу возвращен ответ от сервера со статусом `200 OK` или `201 Created` и ID созданного ресурса в теле ответа, но при этом этот ресурс может быть ещё в *состоянии запуска*.  Для того чтобы понять, в каком состоянии сейчас находится ваш ресурс, мы добавили поле `status` в ответ на получение информации о ресурсе.  Список статусов будет отличаться в зависимости от типа ресурса. Увидеть поддерживаемый список статусов вы сможете в описании каждого конкретного ресурса.     ## Ограничение скорости запросов (Rate Limiting) Чтобы обеспечить стабильность для всех пользователей, Timeweb Cloud защищает API от всплесков входящего трафика, анализируя количество запросов c каждого аккаунта к каждой конечной точке.  Если ваше приложение отправляет более 20 запросов в секунду на одну конечную точку, то для этого запроса API может вернуть код состояния HTTP `429 Too Many Requests`.   ## Аутентификация Доступ к API осуществляется с помощью JWT-токена. Токенами можно управлять внутри панели управления Timeweb Cloud в разделе *API и Terraform*.  Токен необходимо передавать в заголовке каждого запроса в формате: ```   Authorization: Bearer $TIMEWEB_CLOUD_TOKEN ```  ## Формат примеров API Примеры в этой документации описаны с помощью `curl`, HTTP-клиента командной строки. На компьютерах `Linux` и `macOS` обычно по умолчанию установлен `curl`, и он доступен для загрузки на всех популярных платформах, включая `Windows`.  Каждый пример разделен на несколько строк символом `\\`, который совместим с `bash`. Типичный пример выглядит так: ```   curl -X PATCH      -H \"Content-Type: application/json\"      -H \"Authorization: Bearer $TIMEWEB_CLOUD_TOKEN\"      -d '{\"name\":\"Cute Corvus\",\"comment\":\"Development Server\"}'      \"https://api.timeweb.cloud/api/v1/dedicated/1051\" ``` - Параметр `-X` задает метод запроса. Для согласованности метод будет указан во всех примерах, даже если он явно не требуется для методов `GET`. - Строки `-H` задают требуемые HTTP-заголовки. - Примеры, для которых требуется объект JSON в теле запроса, передают требуемые данные через параметр `-d`.  Чтобы использовать приведенные примеры, не подставляя каждый раз в них свой токен, вы можете добавить токен один раз в переменные окружения в вашей консоли. Например, на `Linux` это можно сделать с помощью команды:  ``` TIMEWEB_CLOUD_TOKEN=\"token\" ```  После этого токен будет автоматически подставляться в ваши запросы.  Обратите внимание, что все значения в этой документации являются примерами. Не полагайтесь на IDы операционных систем, тарифов и т.д., используемые в примерах. Используйте соответствующую конечную точку для получения значений перед созданием ресурсов.   ## Версионирование API построено согласно принципам [семантического версионирования](https://semver.org/lang/ru). Это значит, что мы гарантируем обратную совместимость всех изменений в пределах одной мажорной версии.  Мажорная версия каждой конечной точки обозначается в пути запроса, например, запрос `/api/v1/servers` указывает, что этот метод имеет версию 1.
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * Contact: info@timeweb.cloud
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12use serde::{Deserialize, Serialize, de::Error as _};
13
14use super::{ContentType, Error, configuration};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`create_database`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum CreateDatabaseError {
21    Status400(models::GetFinances400Response),
22    Status401(models::GetFinances401Response),
23    Status403(models::GetAccountStatus403Response),
24    Status404(models::GetImage404Response),
25    Status429(models::GetFinances429Response),
26    Status500(models::GetFinances500Response),
27    UnknownValue(serde_json::Value)
28}
29
30/// struct for typed errors of method [`create_database_backup`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum CreateDatabaseBackupError {
34    Status400(models::GetFinances400Response),
35    Status401(models::GetFinances401Response),
36    Status403(models::GetAccountStatus403Response),
37    Status404(models::GetImage404Response),
38    Status409(models::CreateDatabaseBackup409Response),
39    Status429(models::GetFinances429Response),
40    Status500(models::GetFinances500Response),
41    UnknownValue(serde_json::Value)
42}
43
44/// struct for typed errors of method [`create_database_cluster`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum CreateDatabaseClusterError {
48    Status400(models::GetFinances400Response),
49    Status401(models::GetFinances401Response),
50    Status403(models::GetAccountStatus403Response),
51    Status404(models::GetImage404Response),
52    Status429(models::GetFinances429Response),
53    Status500(models::GetFinances500Response),
54    UnknownValue(serde_json::Value)
55}
56
57/// struct for typed errors of method [`create_database_instance`]
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum CreateDatabaseInstanceError {
61    Status400(models::GetFinances400Response),
62    Status401(models::GetFinances401Response),
63    Status403(models::GetAccountStatus403Response),
64    Status404(models::GetImage404Response),
65    Status429(models::GetFinances429Response),
66    Status500(models::GetFinances500Response),
67    UnknownValue(serde_json::Value)
68}
69
70/// struct for typed errors of method [`create_database_user`]
71#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum CreateDatabaseUserError {
74    Status400(models::GetFinances400Response),
75    Status401(models::GetFinances401Response),
76    Status403(models::GetAccountStatus403Response),
77    Status404(models::GetImage404Response),
78    Status429(models::GetFinances429Response),
79    Status500(models::GetFinances500Response),
80    UnknownValue(serde_json::Value)
81}
82
83/// struct for typed errors of method [`delete_database`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum DeleteDatabaseError {
87    Status400(models::GetFinances400Response),
88    Status401(models::GetFinances401Response),
89    Status403(models::GetAccountStatus403Response),
90    Status404(models::GetImage404Response),
91    Status429(models::GetFinances429Response),
92    Status500(models::GetFinances500Response),
93    UnknownValue(serde_json::Value)
94}
95
96/// struct for typed errors of method [`delete_database_backup`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum DeleteDatabaseBackupError {
100    Status400(models::GetFinances400Response),
101    Status401(models::GetFinances401Response),
102    Status403(models::GetAccountStatus403Response),
103    Status404(models::GetImage404Response),
104    Status429(models::GetFinances429Response),
105    Status500(models::GetFinances500Response),
106    UnknownValue(serde_json::Value)
107}
108
109/// struct for typed errors of method [`delete_database_cluster`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum DeleteDatabaseClusterError {
113    Status400(models::GetFinances400Response),
114    Status401(models::GetFinances401Response),
115    Status403(models::GetAccountStatus403Response),
116    Status404(models::GetImage404Response),
117    Status429(models::GetFinances429Response),
118    Status500(models::GetFinances500Response),
119    UnknownValue(serde_json::Value)
120}
121
122/// struct for typed errors of method [`delete_database_instance`]
123#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum DeleteDatabaseInstanceError {
126    Status400(models::GetFinances400Response),
127    Status401(models::GetFinances401Response),
128    Status403(models::GetAccountStatus403Response),
129    Status404(models::GetImage404Response),
130    Status429(models::GetFinances429Response),
131    Status500(models::GetFinances500Response),
132    UnknownValue(serde_json::Value)
133}
134
135/// struct for typed errors of method [`delete_database_user`]
136#[derive(Debug, Clone, Serialize, Deserialize)]
137#[serde(untagged)]
138pub enum DeleteDatabaseUserError {
139    Status400(models::GetFinances400Response),
140    Status401(models::GetFinances401Response),
141    Status403(models::GetAccountStatus403Response),
142    Status404(models::GetImage404Response),
143    Status429(models::GetFinances429Response),
144    Status500(models::GetFinances500Response),
145    UnknownValue(serde_json::Value)
146}
147
148/// struct for typed errors of method [`get_database`]
149#[derive(Debug, Clone, Serialize, Deserialize)]
150#[serde(untagged)]
151pub enum GetDatabaseError {
152    Status400(models::GetFinances400Response),
153    Status401(models::GetFinances401Response),
154    Status403(models::GetAccountStatus403Response),
155    Status404(models::GetImage404Response),
156    Status429(models::GetFinances429Response),
157    Status500(models::GetFinances500Response),
158    UnknownValue(serde_json::Value)
159}
160
161/// struct for typed errors of method [`get_database_auto_backups_settings`]
162#[derive(Debug, Clone, Serialize, Deserialize)]
163#[serde(untagged)]
164pub enum GetDatabaseAutoBackupsSettingsError {
165    Status400(models::GetFinances400Response),
166    Status401(models::GetFinances401Response),
167    Status403(models::GetAccountStatus403Response),
168    Status404(models::GetImage404Response),
169    Status429(models::GetFinances429Response),
170    Status500(models::GetFinances500Response),
171    UnknownValue(serde_json::Value)
172}
173
174/// struct for typed errors of method [`get_database_backup`]
175#[derive(Debug, Clone, Serialize, Deserialize)]
176#[serde(untagged)]
177pub enum GetDatabaseBackupError {
178    Status400(models::GetFinances400Response),
179    Status401(models::GetFinances401Response),
180    Status403(models::GetAccountStatus403Response),
181    Status404(models::GetImage404Response),
182    Status429(models::GetFinances429Response),
183    Status500(models::GetFinances500Response),
184    UnknownValue(serde_json::Value)
185}
186
187/// struct for typed errors of method [`get_database_backups`]
188#[derive(Debug, Clone, Serialize, Deserialize)]
189#[serde(untagged)]
190pub enum GetDatabaseBackupsError {
191    Status400(models::GetFinances400Response),
192    Status401(models::GetFinances401Response),
193    Status403(models::GetAccountStatus403Response),
194    Status404(models::GetImage404Response),
195    Status429(models::GetFinances429Response),
196    Status500(models::GetFinances500Response),
197    UnknownValue(serde_json::Value)
198}
199
200/// struct for typed errors of method [`get_database_cluster`]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum GetDatabaseClusterError {
204    Status400(models::GetFinances400Response),
205    Status401(models::GetFinances401Response),
206    Status403(models::GetAccountStatus403Response),
207    Status404(models::GetImage404Response),
208    Status429(models::GetFinances429Response),
209    Status500(models::GetFinances500Response),
210    UnknownValue(serde_json::Value)
211}
212
213/// struct for typed errors of method [`get_database_cluster_types`]
214#[derive(Debug, Clone, Serialize, Deserialize)]
215#[serde(untagged)]
216pub enum GetDatabaseClusterTypesError {
217    Status400(models::GetFinances400Response),
218    Status401(models::GetFinances401Response),
219    Status403(models::GetAccountStatus403Response),
220    Status404(models::GetImage404Response),
221    Status429(models::GetFinances429Response),
222    Status500(models::GetFinances500Response),
223    UnknownValue(serde_json::Value)
224}
225
226/// struct for typed errors of method [`get_database_clusters`]
227#[derive(Debug, Clone, Serialize, Deserialize)]
228#[serde(untagged)]
229pub enum GetDatabaseClustersError {
230    Status400(models::GetFinances400Response),
231    Status401(models::GetFinances401Response),
232    Status403(models::GetAccountStatus403Response),
233    Status404(models::GetImage404Response),
234    Status429(models::GetFinances429Response),
235    Status500(models::GetFinances500Response),
236    UnknownValue(serde_json::Value)
237}
238
239/// struct for typed errors of method [`get_database_instance`]
240#[derive(Debug, Clone, Serialize, Deserialize)]
241#[serde(untagged)]
242pub enum GetDatabaseInstanceError {
243    Status400(models::GetFinances400Response),
244    Status401(models::GetFinances401Response),
245    Status403(models::GetAccountStatus403Response),
246    Status404(models::GetImage404Response),
247    Status429(models::GetFinances429Response),
248    Status500(models::GetFinances500Response),
249    UnknownValue(serde_json::Value)
250}
251
252/// struct for typed errors of method [`get_database_instances`]
253#[derive(Debug, Clone, Serialize, Deserialize)]
254#[serde(untagged)]
255pub enum GetDatabaseInstancesError {
256    Status400(models::GetFinances400Response),
257    Status401(models::GetFinances401Response),
258    Status403(models::GetAccountStatus403Response),
259    Status404(models::GetImage404Response),
260    Status429(models::GetFinances429Response),
261    Status500(models::GetFinances500Response),
262    UnknownValue(serde_json::Value)
263}
264
265/// struct for typed errors of method [`get_database_parameters`]
266#[derive(Debug, Clone, Serialize, Deserialize)]
267#[serde(untagged)]
268pub enum GetDatabaseParametersError {
269    Status400(models::GetFinances400Response),
270    Status401(models::GetFinances401Response),
271    Status403(models::GetAccountStatus403Response),
272    Status404(models::GetImage404Response),
273    Status429(models::GetFinances429Response),
274    Status500(models::GetFinances500Response),
275    UnknownValue(serde_json::Value)
276}
277
278/// struct for typed errors of method [`get_database_user`]
279#[derive(Debug, Clone, Serialize, Deserialize)]
280#[serde(untagged)]
281pub enum GetDatabaseUserError {
282    Status400(models::GetFinances400Response),
283    Status401(models::GetFinances401Response),
284    Status403(models::GetAccountStatus403Response),
285    Status404(models::GetImage404Response),
286    Status429(models::GetFinances429Response),
287    Status500(models::GetFinances500Response),
288    UnknownValue(serde_json::Value)
289}
290
291/// struct for typed errors of method [`get_database_users`]
292#[derive(Debug, Clone, Serialize, Deserialize)]
293#[serde(untagged)]
294pub enum GetDatabaseUsersError {
295    Status400(models::GetFinances400Response),
296    Status401(models::GetFinances401Response),
297    Status403(models::GetAccountStatus403Response),
298    Status404(models::GetImage404Response),
299    Status429(models::GetFinances429Response),
300    Status500(models::GetFinances500Response),
301    UnknownValue(serde_json::Value)
302}
303
304/// struct for typed errors of method [`get_databases`]
305#[derive(Debug, Clone, Serialize, Deserialize)]
306#[serde(untagged)]
307pub enum GetDatabasesError {
308    Status400(models::GetFinances400Response),
309    Status401(models::GetFinances401Response),
310    Status403(models::GetAccountStatus403Response),
311    Status404(models::GetImage404Response),
312    Status429(models::GetFinances429Response),
313    Status500(models::GetFinances500Response),
314    UnknownValue(serde_json::Value)
315}
316
317/// struct for typed errors of method [`get_databases_presets`]
318#[derive(Debug, Clone, Serialize, Deserialize)]
319#[serde(untagged)]
320pub enum GetDatabasesPresetsError {
321    Status400(models::GetFinances400Response),
322    Status401(models::GetFinances401Response),
323    Status403(models::GetAccountStatus403Response),
324    Status404(models::GetImage404Response),
325    Status429(models::GetFinances429Response),
326    Status500(models::GetFinances500Response),
327    UnknownValue(serde_json::Value)
328}
329
330/// struct for typed errors of method [`restore_database_from_backup`]
331#[derive(Debug, Clone, Serialize, Deserialize)]
332#[serde(untagged)]
333pub enum RestoreDatabaseFromBackupError {
334    Status400(models::GetFinances400Response),
335    Status401(models::GetFinances401Response),
336    Status403(models::GetAccountStatus403Response),
337    Status404(models::GetImage404Response),
338    Status409(models::CreateDatabaseBackup409Response),
339    Status429(models::GetFinances429Response),
340    Status500(models::GetFinances500Response),
341    UnknownValue(serde_json::Value)
342}
343
344/// struct for typed errors of method [`update_database`]
345#[derive(Debug, Clone, Serialize, Deserialize)]
346#[serde(untagged)]
347pub enum UpdateDatabaseError {
348    Status400(models::GetFinances400Response),
349    Status401(models::GetFinances401Response),
350    Status403(models::GetAccountStatus403Response),
351    Status404(models::GetImage404Response),
352    Status429(models::GetFinances429Response),
353    Status500(models::GetFinances500Response),
354    UnknownValue(serde_json::Value)
355}
356
357/// struct for typed errors of method [`update_database_auto_backups_settings`]
358#[derive(Debug, Clone, Serialize, Deserialize)]
359#[serde(untagged)]
360pub enum UpdateDatabaseAutoBackupsSettingsError {
361    Status400(models::GetFinances400Response),
362    Status401(models::GetFinances401Response),
363    Status403(models::GetAccountStatus403Response),
364    Status404(models::GetImage404Response),
365    Status429(models::GetFinances429Response),
366    Status500(models::GetFinances500Response),
367    UnknownValue(serde_json::Value)
368}
369
370/// struct for typed errors of method [`update_database_cluster`]
371#[derive(Debug, Clone, Serialize, Deserialize)]
372#[serde(untagged)]
373pub enum UpdateDatabaseClusterError {
374    Status400(models::GetFinances400Response),
375    Status401(models::GetFinances401Response),
376    Status403(models::GetAccountStatus403Response),
377    Status404(models::GetImage404Response),
378    Status429(models::GetFinances429Response),
379    Status500(models::GetFinances500Response),
380    UnknownValue(serde_json::Value)
381}
382
383/// struct for typed errors of method [`update_database_instance`]
384#[derive(Debug, Clone, Serialize, Deserialize)]
385#[serde(untagged)]
386pub enum UpdateDatabaseInstanceError {
387    Status400(models::GetFinances400Response),
388    Status401(models::GetFinances401Response),
389    Status403(models::GetAccountStatus403Response),
390    Status404(models::GetImage404Response),
391    Status429(models::GetFinances429Response),
392    Status500(models::GetFinances500Response),
393    UnknownValue(serde_json::Value)
394}
395
396/// struct for typed errors of method [`update_database_user`]
397#[derive(Debug, Clone, Serialize, Deserialize)]
398#[serde(untagged)]
399pub enum UpdateDatabaseUserError {
400    Status400(models::GetFinances400Response),
401    Status401(models::GetFinances401Response),
402    Status403(models::GetAccountStatus403Response),
403    Status404(models::GetImage404Response),
404    Status429(models::GetFinances429Response),
405    Status500(models::GetFinances500Response),
406    UnknownValue(serde_json::Value)
407}
408
409/// Чтобы создать базу данных на вашем аккаунте, отправьте POST-запрос на
410/// `/api/v1/dbs`, задав необходимые атрибуты.  База данных будет создана с
411/// использованием предоставленной информации. Тело ответа будет содержать
412/// объект JSON с информацией о созданной базе данных.
413#[deprecated]
414pub async fn create_database(
415    configuration: &configuration::Configuration,
416    create_db: models::CreateDb
417) -> Result<models::CreateDatabase201Response, Error<CreateDatabaseError>> {
418    // add a prefix to parameters to efficiently prevent name collisions
419    let p_body_create_db = create_db;
420
421    let uri_str = format!("{}/api/v1/dbs", configuration.base_path);
422    let mut req_builder = configuration
423        .client
424        .request(reqwest::Method::POST, &uri_str);
425
426    if let Some(ref user_agent) = configuration.user_agent {
427        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
428    }
429    if let Some(ref token) = configuration.bearer_access_token {
430        req_builder = req_builder.bearer_auth(token.to_owned());
431    };
432    req_builder = req_builder.json(&p_body_create_db);
433
434    let req = req_builder.build()?;
435    let resp = configuration.client.execute(req).await?;
436
437    let status = resp.status();
438    let content_type = resp
439        .headers()
440        .get("content-type")
441        .and_then(|v| v.to_str().ok())
442        .unwrap_or("application/octet-stream");
443    let content_type = super::ContentType::from(content_type);
444
445    if !status.is_client_error() && !status.is_server_error() {
446        let content = resp.text().await?;
447        match content_type {
448            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
449            ContentType::Text => {
450                return Err(Error::from(serde_json::Error::custom(
451                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabase201Response`"
452                )));
453            }
454            ContentType::Unsupported(unknown_type) => {
455                return Err(Error::from(serde_json::Error::custom(format!(
456                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabase201Response`"
457                ))));
458            }
459        }
460    } else {
461        let content = resp.text().await?;
462        let entity: Option<CreateDatabaseError> = serde_json::from_str(&content).ok();
463        Err(Error::ResponseError(ResponseContent {
464            status,
465            content,
466            entity
467        }))
468    }
469}
470
471/// Чтобы создать бэкап базы данных, отправьте запрос POST в
472/// `api/v1/dbs/{db_id}/backups`.
473pub async fn create_database_backup(
474    configuration: &configuration::Configuration,
475    db_id: i32,
476    comment: Option<&str>
477) -> Result<models::CreateDatabaseBackup201Response, Error<CreateDatabaseBackupError>> {
478    // add a prefix to parameters to efficiently prevent name collisions
479    let p_path_db_id = db_id;
480    let p_query_comment = comment;
481
482    let uri_str = format!(
483        "{}/api/v1/dbs/{db_id}/backups",
484        configuration.base_path,
485        db_id = p_path_db_id
486    );
487    let mut req_builder = configuration
488        .client
489        .request(reqwest::Method::POST, &uri_str);
490
491    if let Some(ref param_value) = p_query_comment {
492        req_builder = req_builder.query(&[("comment", &param_value.to_string())]);
493    }
494    if let Some(ref user_agent) = configuration.user_agent {
495        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
496    }
497    if let Some(ref token) = configuration.bearer_access_token {
498        req_builder = req_builder.bearer_auth(token.to_owned());
499    };
500
501    let req = req_builder.build()?;
502    let resp = configuration.client.execute(req).await?;
503
504    let status = resp.status();
505    let content_type = resp
506        .headers()
507        .get("content-type")
508        .and_then(|v| v.to_str().ok())
509        .unwrap_or("application/octet-stream");
510    let content_type = super::ContentType::from(content_type);
511
512    if !status.is_client_error() && !status.is_server_error() {
513        let content = resp.text().await?;
514        match content_type {
515            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
516            ContentType::Text => {
517                return Err(Error::from(serde_json::Error::custom(
518                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseBackup201Response`"
519                )));
520            }
521            ContentType::Unsupported(unknown_type) => {
522                return Err(Error::from(serde_json::Error::custom(format!(
523                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseBackup201Response`"
524                ))));
525            }
526        }
527    } else {
528        let content = resp.text().await?;
529        let entity: Option<CreateDatabaseBackupError> = serde_json::from_str(&content).ok();
530        Err(Error::ResponseError(ResponseContent {
531            status,
532            content,
533            entity
534        }))
535    }
536}
537
538/// Чтобы создать кластер базы данных на вашем аккаунте, отправьте POST-запрос
539/// на `/api/v1/databases`.   Вместе с кластером будет создан один инстанс базы
540/// данных и один пользователь.
541pub async fn create_database_cluster(
542    configuration: &configuration::Configuration,
543    create_cluster: models::CreateCluster
544) -> Result<models::CreateDatabaseCluster201Response, Error<CreateDatabaseClusterError>> {
545    // add a prefix to parameters to efficiently prevent name collisions
546    let p_body_create_cluster = create_cluster;
547
548    let uri_str = format!("{}/api/v1/databases", configuration.base_path);
549    let mut req_builder = configuration
550        .client
551        .request(reqwest::Method::POST, &uri_str);
552
553    if let Some(ref user_agent) = configuration.user_agent {
554        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
555    }
556    if let Some(ref token) = configuration.bearer_access_token {
557        req_builder = req_builder.bearer_auth(token.to_owned());
558    };
559    req_builder = req_builder.json(&p_body_create_cluster);
560
561    let req = req_builder.build()?;
562    let resp = configuration.client.execute(req).await?;
563
564    let status = resp.status();
565    let content_type = resp
566        .headers()
567        .get("content-type")
568        .and_then(|v| v.to_str().ok())
569        .unwrap_or("application/octet-stream");
570    let content_type = super::ContentType::from(content_type);
571
572    if !status.is_client_error() && !status.is_server_error() {
573        let content = resp.text().await?;
574        match content_type {
575            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
576            ContentType::Text => {
577                return Err(Error::from(serde_json::Error::custom(
578                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseCluster201Response`"
579                )));
580            }
581            ContentType::Unsupported(unknown_type) => {
582                return Err(Error::from(serde_json::Error::custom(format!(
583                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseCluster201Response`"
584                ))));
585            }
586        }
587    } else {
588        let content = resp.text().await?;
589        let entity: Option<CreateDatabaseClusterError> = serde_json::from_str(&content).ok();
590        Err(Error::ResponseError(ResponseContent {
591            status,
592            content,
593            entity
594        }))
595    }
596}
597
598/// Чтобы создать инстанс базы данных, отправьте POST-запрос на
599/// `/api/v1/databases/{db_cluster_id}/instances`.\\    Существующие
600/// пользователи не будут иметь доступа к новой базе данных после создания. Вы
601/// можете изменить привилегии для пользователя через <a
602/// href='#tag/Bazy-dannyh/operation/updateDatabaseUser'>метод изменения
603/// пользователя</a>
604pub async fn create_database_instance(
605    configuration: &configuration::Configuration,
606    db_cluster_id: i32,
607    create_instance: models::CreateInstance
608) -> Result<models::CreateDatabaseInstance201Response, Error<CreateDatabaseInstanceError>> {
609    // add a prefix to parameters to efficiently prevent name collisions
610    let p_path_db_cluster_id = db_cluster_id;
611    let p_body_create_instance = create_instance;
612
613    let uri_str = format!(
614        "{}/api/v1/databases/{db_cluster_id}/instances",
615        configuration.base_path,
616        db_cluster_id = p_path_db_cluster_id
617    );
618    let mut req_builder = configuration
619        .client
620        .request(reqwest::Method::POST, &uri_str);
621
622    if let Some(ref user_agent) = configuration.user_agent {
623        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
624    }
625    if let Some(ref token) = configuration.bearer_access_token {
626        req_builder = req_builder.bearer_auth(token.to_owned());
627    };
628    req_builder = req_builder.json(&p_body_create_instance);
629
630    let req = req_builder.build()?;
631    let resp = configuration.client.execute(req).await?;
632
633    let status = resp.status();
634    let content_type = resp
635        .headers()
636        .get("content-type")
637        .and_then(|v| v.to_str().ok())
638        .unwrap_or("application/octet-stream");
639    let content_type = super::ContentType::from(content_type);
640
641    if !status.is_client_error() && !status.is_server_error() {
642        let content = resp.text().await?;
643        match content_type {
644            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
645            ContentType::Text => {
646                return Err(Error::from(serde_json::Error::custom(
647                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseInstance201Response`"
648                )));
649            }
650            ContentType::Unsupported(unknown_type) => {
651                return Err(Error::from(serde_json::Error::custom(format!(
652                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseInstance201Response`"
653                ))));
654            }
655        }
656    } else {
657        let content = resp.text().await?;
658        let entity: Option<CreateDatabaseInstanceError> = serde_json::from_str(&content).ok();
659        Err(Error::ResponseError(ResponseContent {
660            status,
661            content,
662            entity
663        }))
664    }
665}
666
667/// Чтобы создать пользователя базы данных, отправьте POST-запрос на
668/// `/api/v1/databases/{db_cluster_id}/admins`.
669pub async fn create_database_user(
670    configuration: &configuration::Configuration,
671    db_cluster_id: i32,
672    create_admin: models::CreateAdmin
673) -> Result<models::CreateDatabaseUser201Response, Error<CreateDatabaseUserError>> {
674    // add a prefix to parameters to efficiently prevent name collisions
675    let p_path_db_cluster_id = db_cluster_id;
676    let p_body_create_admin = create_admin;
677
678    let uri_str = format!(
679        "{}/api/v1/databases/{db_cluster_id}/admins",
680        configuration.base_path,
681        db_cluster_id = p_path_db_cluster_id
682    );
683    let mut req_builder = configuration
684        .client
685        .request(reqwest::Method::POST, &uri_str);
686
687    if let Some(ref user_agent) = configuration.user_agent {
688        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
689    }
690    if let Some(ref token) = configuration.bearer_access_token {
691        req_builder = req_builder.bearer_auth(token.to_owned());
692    };
693    req_builder = req_builder.json(&p_body_create_admin);
694
695    let req = req_builder.build()?;
696    let resp = configuration.client.execute(req).await?;
697
698    let status = resp.status();
699    let content_type = resp
700        .headers()
701        .get("content-type")
702        .and_then(|v| v.to_str().ok())
703        .unwrap_or("application/octet-stream");
704    let content_type = super::ContentType::from(content_type);
705
706    if !status.is_client_error() && !status.is_server_error() {
707        let content = resp.text().await?;
708        match content_type {
709            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
710            ContentType::Text => {
711                return Err(Error::from(serde_json::Error::custom(
712                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseUser201Response`"
713                )));
714            }
715            ContentType::Unsupported(unknown_type) => {
716                return Err(Error::from(serde_json::Error::custom(format!(
717                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseUser201Response`"
718                ))));
719            }
720        }
721    } else {
722        let content = resp.text().await?;
723        let entity: Option<CreateDatabaseUserError> = serde_json::from_str(&content).ok();
724        Err(Error::ResponseError(ResponseContent {
725            status,
726            content,
727            entity
728        }))
729    }
730}
731
732/// Чтобы удалить базу данных, отправьте запрос DELETE в `api/v1/dbs/{db_id}`.
733#[deprecated]
734pub async fn delete_database(
735    configuration: &configuration::Configuration,
736    db_id: i32,
737    hash: Option<&str>,
738    code: Option<&str>
739) -> Result<models::DeleteDatabase200Response, Error<DeleteDatabaseError>> {
740    // add a prefix to parameters to efficiently prevent name collisions
741    let p_path_db_id = db_id;
742    let p_query_hash = hash;
743    let p_query_code = code;
744
745    let uri_str = format!(
746        "{}/api/v1/dbs/{db_id}",
747        configuration.base_path,
748        db_id = p_path_db_id
749    );
750    let mut req_builder = configuration
751        .client
752        .request(reqwest::Method::DELETE, &uri_str);
753
754    if let Some(ref param_value) = p_query_hash {
755        req_builder = req_builder.query(&[("hash", &param_value.to_string())]);
756    }
757    if let Some(ref param_value) = p_query_code {
758        req_builder = req_builder.query(&[("code", &param_value.to_string())]);
759    }
760    if let Some(ref user_agent) = configuration.user_agent {
761        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
762    }
763    if let Some(ref token) = configuration.bearer_access_token {
764        req_builder = req_builder.bearer_auth(token.to_owned());
765    };
766
767    let req = req_builder.build()?;
768    let resp = configuration.client.execute(req).await?;
769
770    let status = resp.status();
771    let content_type = resp
772        .headers()
773        .get("content-type")
774        .and_then(|v| v.to_str().ok())
775        .unwrap_or("application/octet-stream");
776    let content_type = super::ContentType::from(content_type);
777
778    if !status.is_client_error() && !status.is_server_error() {
779        let content = resp.text().await?;
780        match content_type {
781            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
782            ContentType::Text => {
783                return Err(Error::from(serde_json::Error::custom(
784                    "Received `text/plain` content type response that cannot be converted to `models::DeleteDatabase200Response`"
785                )));
786            }
787            ContentType::Unsupported(unknown_type) => {
788                return Err(Error::from(serde_json::Error::custom(format!(
789                    "Received `{unknown_type}` content type response that cannot be converted to `models::DeleteDatabase200Response`"
790                ))));
791            }
792        }
793    } else {
794        let content = resp.text().await?;
795        let entity: Option<DeleteDatabaseError> = serde_json::from_str(&content).ok();
796        Err(Error::ResponseError(ResponseContent {
797            status,
798            content,
799            entity
800        }))
801    }
802}
803
804/// Чтобы удалить бэкап базы данных, отправьте запрос DELETE в
805/// `api/v1/dbs/{db_id}/backups/{backup_id}`.
806pub async fn delete_database_backup(
807    configuration: &configuration::Configuration,
808    db_id: i32,
809    backup_id: i32
810) -> Result<(), Error<DeleteDatabaseBackupError>> {
811    // add a prefix to parameters to efficiently prevent name collisions
812    let p_path_db_id = db_id;
813    let p_path_backup_id = backup_id;
814
815    let uri_str = format!(
816        "{}/api/v1/dbs/{db_id}/backups/{backup_id}",
817        configuration.base_path,
818        db_id = p_path_db_id,
819        backup_id = p_path_backup_id
820    );
821    let mut req_builder = configuration
822        .client
823        .request(reqwest::Method::DELETE, &uri_str);
824
825    if let Some(ref user_agent) = configuration.user_agent {
826        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
827    }
828    if let Some(ref token) = configuration.bearer_access_token {
829        req_builder = req_builder.bearer_auth(token.to_owned());
830    };
831
832    let req = req_builder.build()?;
833    let resp = configuration.client.execute(req).await?;
834
835    let status = resp.status();
836
837    if !status.is_client_error() && !status.is_server_error() {
838        Ok(())
839    } else {
840        let content = resp.text().await?;
841        let entity: Option<DeleteDatabaseBackupError> = serde_json::from_str(&content).ok();
842        Err(Error::ResponseError(ResponseContent {
843            status,
844            content,
845            entity
846        }))
847    }
848}
849
850/// Чтобы удалить кластер базы данных, отправьте DELETE-запрос на
851/// `/api/v1/databases/{db_cluster_id}`.
852pub async fn delete_database_cluster(
853    configuration: &configuration::Configuration,
854    db_cluster_id: i32,
855    hash: Option<&str>,
856    code: Option<&str>
857) -> Result<models::DeleteDatabaseCluster200Response, Error<DeleteDatabaseClusterError>> {
858    // add a prefix to parameters to efficiently prevent name collisions
859    let p_path_db_cluster_id = db_cluster_id;
860    let p_query_hash = hash;
861    let p_query_code = code;
862
863    let uri_str = format!(
864        "{}/api/v1/databases/{db_cluster_id}",
865        configuration.base_path,
866        db_cluster_id = p_path_db_cluster_id
867    );
868    let mut req_builder = configuration
869        .client
870        .request(reqwest::Method::DELETE, &uri_str);
871
872    if let Some(ref param_value) = p_query_hash {
873        req_builder = req_builder.query(&[("hash", &param_value.to_string())]);
874    }
875    if let Some(ref param_value) = p_query_code {
876        req_builder = req_builder.query(&[("code", &param_value.to_string())]);
877    }
878    if let Some(ref user_agent) = configuration.user_agent {
879        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
880    }
881    if let Some(ref token) = configuration.bearer_access_token {
882        req_builder = req_builder.bearer_auth(token.to_owned());
883    };
884
885    let req = req_builder.build()?;
886    let resp = configuration.client.execute(req).await?;
887
888    let status = resp.status();
889    let content_type = resp
890        .headers()
891        .get("content-type")
892        .and_then(|v| v.to_str().ok())
893        .unwrap_or("application/octet-stream");
894    let content_type = super::ContentType::from(content_type);
895
896    if !status.is_client_error() && !status.is_server_error() {
897        let content = resp.text().await?;
898        match content_type {
899            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
900            ContentType::Text => {
901                return Err(Error::from(serde_json::Error::custom(
902                    "Received `text/plain` content type response that cannot be converted to `models::DeleteDatabaseCluster200Response`"
903                )));
904            }
905            ContentType::Unsupported(unknown_type) => {
906                return Err(Error::from(serde_json::Error::custom(format!(
907                    "Received `{unknown_type}` content type response that cannot be converted to `models::DeleteDatabaseCluster200Response`"
908                ))));
909            }
910        }
911    } else {
912        let content = resp.text().await?;
913        let entity: Option<DeleteDatabaseClusterError> = serde_json::from_str(&content).ok();
914        Err(Error::ResponseError(ResponseContent {
915            status,
916            content,
917            entity
918        }))
919    }
920}
921
922/// Чтобы удалить инстанс базы данных, отправьте DELETE-запрос на
923/// `/api/v1/databases/{db_cluster_id}/instances/{instance_id}`.
924pub async fn delete_database_instance(
925    configuration: &configuration::Configuration,
926    db_cluster_id: i32,
927    instance_id: i32
928) -> Result<(), Error<DeleteDatabaseInstanceError>> {
929    // add a prefix to parameters to efficiently prevent name collisions
930    let p_path_db_cluster_id = db_cluster_id;
931    let p_path_instance_id = instance_id;
932
933    let uri_str = format!(
934        "{}/api/v1/databases/{db_cluster_id}/instances/{instance_id}",
935        configuration.base_path,
936        db_cluster_id = p_path_db_cluster_id,
937        instance_id = p_path_instance_id
938    );
939    let mut req_builder = configuration
940        .client
941        .request(reqwest::Method::DELETE, &uri_str);
942
943    if let Some(ref user_agent) = configuration.user_agent {
944        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
945    }
946    if let Some(ref token) = configuration.bearer_access_token {
947        req_builder = req_builder.bearer_auth(token.to_owned());
948    };
949
950    let req = req_builder.build()?;
951    let resp = configuration.client.execute(req).await?;
952
953    let status = resp.status();
954
955    if !status.is_client_error() && !status.is_server_error() {
956        Ok(())
957    } else {
958        let content = resp.text().await?;
959        let entity: Option<DeleteDatabaseInstanceError> = serde_json::from_str(&content).ok();
960        Err(Error::ResponseError(ResponseContent {
961            status,
962            content,
963            entity
964        }))
965    }
966}
967
968/// Чтобы удалить пользователя базы данных на вашем аккаунте, отправьте
969/// DELETE-запрос на `/api/v1/databases/{db_cluster_id}/admins/{admin_id}`.
970pub async fn delete_database_user(
971    configuration: &configuration::Configuration,
972    db_cluster_id: i32,
973    admin_id: i32
974) -> Result<(), Error<DeleteDatabaseUserError>> {
975    // add a prefix to parameters to efficiently prevent name collisions
976    let p_path_db_cluster_id = db_cluster_id;
977    let p_path_admin_id = admin_id;
978
979    let uri_str = format!(
980        "{}/api/v1/databases/{db_cluster_id}/admins/{admin_id}",
981        configuration.base_path,
982        db_cluster_id = p_path_db_cluster_id,
983        admin_id = p_path_admin_id
984    );
985    let mut req_builder = configuration
986        .client
987        .request(reqwest::Method::DELETE, &uri_str);
988
989    if let Some(ref user_agent) = configuration.user_agent {
990        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
991    }
992    if let Some(ref token) = configuration.bearer_access_token {
993        req_builder = req_builder.bearer_auth(token.to_owned());
994    };
995
996    let req = req_builder.build()?;
997    let resp = configuration.client.execute(req).await?;
998
999    let status = resp.status();
1000
1001    if !status.is_client_error() && !status.is_server_error() {
1002        Ok(())
1003    } else {
1004        let content = resp.text().await?;
1005        let entity: Option<DeleteDatabaseUserError> = serde_json::from_str(&content).ok();
1006        Err(Error::ResponseError(ResponseContent {
1007            status,
1008            content,
1009            entity
1010        }))
1011    }
1012}
1013
1014/// Чтобы отобразить информацию об отдельной базе данных, отправьте запрос GET
1015/// на `api/v1/dbs/{db_id}`.
1016#[deprecated]
1017pub async fn get_database(
1018    configuration: &configuration::Configuration,
1019    db_id: i32
1020) -> Result<models::CreateDatabase201Response, Error<GetDatabaseError>> {
1021    // add a prefix to parameters to efficiently prevent name collisions
1022    let p_path_db_id = db_id;
1023
1024    let uri_str = format!(
1025        "{}/api/v1/dbs/{db_id}",
1026        configuration.base_path,
1027        db_id = p_path_db_id
1028    );
1029    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1030
1031    if let Some(ref user_agent) = configuration.user_agent {
1032        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1033    }
1034    if let Some(ref token) = configuration.bearer_access_token {
1035        req_builder = req_builder.bearer_auth(token.to_owned());
1036    };
1037
1038    let req = req_builder.build()?;
1039    let resp = configuration.client.execute(req).await?;
1040
1041    let status = resp.status();
1042    let content_type = resp
1043        .headers()
1044        .get("content-type")
1045        .and_then(|v| v.to_str().ok())
1046        .unwrap_or("application/octet-stream");
1047    let content_type = super::ContentType::from(content_type);
1048
1049    if !status.is_client_error() && !status.is_server_error() {
1050        let content = resp.text().await?;
1051        match content_type {
1052            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1053            ContentType::Text => {
1054                return Err(Error::from(serde_json::Error::custom(
1055                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabase201Response`"
1056                )));
1057            }
1058            ContentType::Unsupported(unknown_type) => {
1059                return Err(Error::from(serde_json::Error::custom(format!(
1060                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabase201Response`"
1061                ))));
1062            }
1063        }
1064    } else {
1065        let content = resp.text().await?;
1066        let entity: Option<GetDatabaseError> = serde_json::from_str(&content).ok();
1067        Err(Error::ResponseError(ResponseContent {
1068            status,
1069            content,
1070            entity
1071        }))
1072    }
1073}
1074
1075/// Чтобы получить список настроек автобэкапов базы данных, отправьте запрос GET
1076/// в `api/v1/dbs/{db_id}/auto-backups`
1077pub async fn get_database_auto_backups_settings(
1078    configuration: &configuration::Configuration,
1079    db_id: i32
1080) -> Result<
1081    models::GetDatabaseAutoBackupsSettings200Response,
1082    Error<GetDatabaseAutoBackupsSettingsError>
1083> {
1084    // add a prefix to parameters to efficiently prevent name collisions
1085    let p_path_db_id = db_id;
1086
1087    let uri_str = format!(
1088        "{}/api/v1/dbs/{db_id}/auto-backups",
1089        configuration.base_path,
1090        db_id = p_path_db_id
1091    );
1092    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1093
1094    if let Some(ref user_agent) = configuration.user_agent {
1095        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1096    }
1097    if let Some(ref token) = configuration.bearer_access_token {
1098        req_builder = req_builder.bearer_auth(token.to_owned());
1099    };
1100
1101    let req = req_builder.build()?;
1102    let resp = configuration.client.execute(req).await?;
1103
1104    let status = resp.status();
1105    let content_type = resp
1106        .headers()
1107        .get("content-type")
1108        .and_then(|v| v.to_str().ok())
1109        .unwrap_or("application/octet-stream");
1110    let content_type = super::ContentType::from(content_type);
1111
1112    if !status.is_client_error() && !status.is_server_error() {
1113        let content = resp.text().await?;
1114        match content_type {
1115            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1116            ContentType::Text => {
1117                return Err(Error::from(serde_json::Error::custom(
1118                    "Received `text/plain` content type response that cannot be converted to `models::GetDatabaseAutoBackupsSettings200Response`"
1119                )));
1120            }
1121            ContentType::Unsupported(unknown_type) => {
1122                return Err(Error::from(serde_json::Error::custom(format!(
1123                    "Received `{unknown_type}` content type response that cannot be converted to `models::GetDatabaseAutoBackupsSettings200Response`"
1124                ))));
1125            }
1126        }
1127    } else {
1128        let content = resp.text().await?;
1129        let entity: Option<GetDatabaseAutoBackupsSettingsError> =
1130            serde_json::from_str(&content).ok();
1131        Err(Error::ResponseError(ResponseContent {
1132            status,
1133            content,
1134            entity
1135        }))
1136    }
1137}
1138
1139/// Чтобы получить бэкап базы данных, отправьте запрос GET в
1140/// `api/v1/dbs/{db_id}/backups/{backup_id}`.
1141pub async fn get_database_backup(
1142    configuration: &configuration::Configuration,
1143    db_id: i32,
1144    backup_id: i32
1145) -> Result<models::CreateDatabaseBackup201Response, Error<GetDatabaseBackupError>> {
1146    // add a prefix to parameters to efficiently prevent name collisions
1147    let p_path_db_id = db_id;
1148    let p_path_backup_id = backup_id;
1149
1150    let uri_str = format!(
1151        "{}/api/v1/dbs/{db_id}/backups/{backup_id}",
1152        configuration.base_path,
1153        db_id = p_path_db_id,
1154        backup_id = p_path_backup_id
1155    );
1156    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1157
1158    if let Some(ref user_agent) = configuration.user_agent {
1159        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1160    }
1161    if let Some(ref token) = configuration.bearer_access_token {
1162        req_builder = req_builder.bearer_auth(token.to_owned());
1163    };
1164
1165    let req = req_builder.build()?;
1166    let resp = configuration.client.execute(req).await?;
1167
1168    let status = resp.status();
1169    let content_type = resp
1170        .headers()
1171        .get("content-type")
1172        .and_then(|v| v.to_str().ok())
1173        .unwrap_or("application/octet-stream");
1174    let content_type = super::ContentType::from(content_type);
1175
1176    if !status.is_client_error() && !status.is_server_error() {
1177        let content = resp.text().await?;
1178        match content_type {
1179            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1180            ContentType::Text => {
1181                return Err(Error::from(serde_json::Error::custom(
1182                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseBackup201Response`"
1183                )));
1184            }
1185            ContentType::Unsupported(unknown_type) => {
1186                return Err(Error::from(serde_json::Error::custom(format!(
1187                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseBackup201Response`"
1188                ))));
1189            }
1190        }
1191    } else {
1192        let content = resp.text().await?;
1193        let entity: Option<GetDatabaseBackupError> = serde_json::from_str(&content).ok();
1194        Err(Error::ResponseError(ResponseContent {
1195            status,
1196            content,
1197            entity
1198        }))
1199    }
1200}
1201
1202/// Чтобы получить список бэкапов базы данных, отправьте запрос GET в
1203/// `api/v1/dbs/{db_id}/backups`.
1204pub async fn get_database_backups(
1205    configuration: &configuration::Configuration,
1206    db_id: i32,
1207    limit: Option<i32>,
1208    offset: Option<i32>
1209) -> Result<models::GetDatabaseBackups200Response, Error<GetDatabaseBackupsError>> {
1210    // add a prefix to parameters to efficiently prevent name collisions
1211    let p_path_db_id = db_id;
1212    let p_query_limit = limit;
1213    let p_query_offset = offset;
1214
1215    let uri_str = format!(
1216        "{}/api/v1/dbs/{db_id}/backups",
1217        configuration.base_path,
1218        db_id = p_path_db_id
1219    );
1220    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1221
1222    if let Some(ref param_value) = p_query_limit {
1223        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
1224    }
1225    if let Some(ref param_value) = p_query_offset {
1226        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
1227    }
1228    if let Some(ref user_agent) = configuration.user_agent {
1229        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1230    }
1231    if let Some(ref token) = configuration.bearer_access_token {
1232        req_builder = req_builder.bearer_auth(token.to_owned());
1233    };
1234
1235    let req = req_builder.build()?;
1236    let resp = configuration.client.execute(req).await?;
1237
1238    let status = resp.status();
1239    let content_type = resp
1240        .headers()
1241        .get("content-type")
1242        .and_then(|v| v.to_str().ok())
1243        .unwrap_or("application/octet-stream");
1244    let content_type = super::ContentType::from(content_type);
1245
1246    if !status.is_client_error() && !status.is_server_error() {
1247        let content = resp.text().await?;
1248        match content_type {
1249            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1250            ContentType::Text => {
1251                return Err(Error::from(serde_json::Error::custom(
1252                    "Received `text/plain` content type response that cannot be converted to `models::GetDatabaseBackups200Response`"
1253                )));
1254            }
1255            ContentType::Unsupported(unknown_type) => {
1256                return Err(Error::from(serde_json::Error::custom(format!(
1257                    "Received `{unknown_type}` content type response that cannot be converted to `models::GetDatabaseBackups200Response`"
1258                ))));
1259            }
1260        }
1261    } else {
1262        let content = resp.text().await?;
1263        let entity: Option<GetDatabaseBackupsError> = serde_json::from_str(&content).ok();
1264        Err(Error::ResponseError(ResponseContent {
1265            status,
1266            content,
1267            entity
1268        }))
1269    }
1270}
1271
1272/// Чтобы получить кластер базы данных на вашем аккаунте, отправьте GET-запрос
1273/// на `/api/v1/databases/{db_cluster_id}`.
1274pub async fn get_database_cluster(
1275    configuration: &configuration::Configuration,
1276    db_cluster_id: i32
1277) -> Result<models::CreateDatabaseCluster201Response, Error<GetDatabaseClusterError>> {
1278    // add a prefix to parameters to efficiently prevent name collisions
1279    let p_path_db_cluster_id = db_cluster_id;
1280
1281    let uri_str = format!(
1282        "{}/api/v1/databases/{db_cluster_id}",
1283        configuration.base_path,
1284        db_cluster_id = p_path_db_cluster_id
1285    );
1286    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1287
1288    if let Some(ref user_agent) = configuration.user_agent {
1289        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1290    }
1291    if let Some(ref token) = configuration.bearer_access_token {
1292        req_builder = req_builder.bearer_auth(token.to_owned());
1293    };
1294
1295    let req = req_builder.build()?;
1296    let resp = configuration.client.execute(req).await?;
1297
1298    let status = resp.status();
1299    let content_type = resp
1300        .headers()
1301        .get("content-type")
1302        .and_then(|v| v.to_str().ok())
1303        .unwrap_or("application/octet-stream");
1304    let content_type = super::ContentType::from(content_type);
1305
1306    if !status.is_client_error() && !status.is_server_error() {
1307        let content = resp.text().await?;
1308        match content_type {
1309            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1310            ContentType::Text => {
1311                return Err(Error::from(serde_json::Error::custom(
1312                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseCluster201Response`"
1313                )));
1314            }
1315            ContentType::Unsupported(unknown_type) => {
1316                return Err(Error::from(serde_json::Error::custom(format!(
1317                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseCluster201Response`"
1318                ))));
1319            }
1320        }
1321    } else {
1322        let content = resp.text().await?;
1323        let entity: Option<GetDatabaseClusterError> = serde_json::from_str(&content).ok();
1324        Err(Error::ResponseError(ResponseContent {
1325            status,
1326            content,
1327            entity
1328        }))
1329    }
1330}
1331
1332/// Чтобы получить список типов баз данных на вашем аккаунте, отправьте
1333/// GET-запрос на `/api/v1/database-types`.
1334pub async fn get_database_cluster_types(
1335    configuration: &configuration::Configuration
1336) -> Result<models::GetDatabaseClusterTypes200Response, Error<GetDatabaseClusterTypesError>> {
1337    let uri_str = format!("{}/api/v1/database-types", configuration.base_path);
1338    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1339
1340    if let Some(ref user_agent) = configuration.user_agent {
1341        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1342    }
1343    if let Some(ref token) = configuration.bearer_access_token {
1344        req_builder = req_builder.bearer_auth(token.to_owned());
1345    };
1346
1347    let req = req_builder.build()?;
1348    let resp = configuration.client.execute(req).await?;
1349
1350    let status = resp.status();
1351    let content_type = resp
1352        .headers()
1353        .get("content-type")
1354        .and_then(|v| v.to_str().ok())
1355        .unwrap_or("application/octet-stream");
1356    let content_type = super::ContentType::from(content_type);
1357
1358    if !status.is_client_error() && !status.is_server_error() {
1359        let content = resp.text().await?;
1360        match content_type {
1361            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1362            ContentType::Text => {
1363                return Err(Error::from(serde_json::Error::custom(
1364                    "Received `text/plain` content type response that cannot be converted to `models::GetDatabaseClusterTypes200Response`"
1365                )));
1366            }
1367            ContentType::Unsupported(unknown_type) => {
1368                return Err(Error::from(serde_json::Error::custom(format!(
1369                    "Received `{unknown_type}` content type response that cannot be converted to `models::GetDatabaseClusterTypes200Response`"
1370                ))));
1371            }
1372        }
1373    } else {
1374        let content = resp.text().await?;
1375        let entity: Option<GetDatabaseClusterTypesError> = serde_json::from_str(&content).ok();
1376        Err(Error::ResponseError(ResponseContent {
1377            status,
1378            content,
1379            entity
1380        }))
1381    }
1382}
1383
1384/// Чтобы получить список кластеров баз данных, отправьте GET-запрос на
1385/// `/api/v1/databases`.   Тело ответа будет представлять собой объект JSON с
1386/// ключом `dbs`.
1387pub async fn get_database_clusters(
1388    configuration: &configuration::Configuration,
1389    limit: Option<i32>,
1390    offset: Option<i32>
1391) -> Result<models::GetDatabaseClusters200Response, Error<GetDatabaseClustersError>> {
1392    // add a prefix to parameters to efficiently prevent name collisions
1393    let p_query_limit = limit;
1394    let p_query_offset = offset;
1395
1396    let uri_str = format!("{}/api/v1/databases", configuration.base_path);
1397    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1398
1399    if let Some(ref param_value) = p_query_limit {
1400        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
1401    }
1402    if let Some(ref param_value) = p_query_offset {
1403        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
1404    }
1405    if let Some(ref user_agent) = configuration.user_agent {
1406        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1407    }
1408    if let Some(ref token) = configuration.bearer_access_token {
1409        req_builder = req_builder.bearer_auth(token.to_owned());
1410    };
1411
1412    let req = req_builder.build()?;
1413    let resp = configuration.client.execute(req).await?;
1414
1415    let status = resp.status();
1416    let content_type = resp
1417        .headers()
1418        .get("content-type")
1419        .and_then(|v| v.to_str().ok())
1420        .unwrap_or("application/octet-stream");
1421    let content_type = super::ContentType::from(content_type);
1422
1423    if !status.is_client_error() && !status.is_server_error() {
1424        let content = resp.text().await?;
1425        match content_type {
1426            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1427            ContentType::Text => {
1428                return Err(Error::from(serde_json::Error::custom(
1429                    "Received `text/plain` content type response that cannot be converted to `models::GetDatabaseClusters200Response`"
1430                )));
1431            }
1432            ContentType::Unsupported(unknown_type) => {
1433                return Err(Error::from(serde_json::Error::custom(format!(
1434                    "Received `{unknown_type}` content type response that cannot be converted to `models::GetDatabaseClusters200Response`"
1435                ))));
1436            }
1437        }
1438    } else {
1439        let content = resp.text().await?;
1440        let entity: Option<GetDatabaseClustersError> = serde_json::from_str(&content).ok();
1441        Err(Error::ResponseError(ResponseContent {
1442            status,
1443            content,
1444            entity
1445        }))
1446    }
1447}
1448
1449/// Чтобы получить инстанс базы данных, отправьте GET-запрос на
1450/// `/api/v1/databases/{db_cluster_id}/instances/{instance_id}`.
1451pub async fn get_database_instance(
1452    configuration: &configuration::Configuration,
1453    db_cluster_id: i32,
1454    instance_id: i32
1455) -> Result<models::CreateDatabaseInstance201Response, Error<GetDatabaseInstanceError>> {
1456    // add a prefix to parameters to efficiently prevent name collisions
1457    let p_path_db_cluster_id = db_cluster_id;
1458    let p_path_instance_id = instance_id;
1459
1460    let uri_str = format!(
1461        "{}/api/v1/databases/{db_cluster_id}/instances/{instance_id}",
1462        configuration.base_path,
1463        db_cluster_id = p_path_db_cluster_id,
1464        instance_id = p_path_instance_id
1465    );
1466    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1467
1468    if let Some(ref user_agent) = configuration.user_agent {
1469        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1470    }
1471    if let Some(ref token) = configuration.bearer_access_token {
1472        req_builder = req_builder.bearer_auth(token.to_owned());
1473    };
1474
1475    let req = req_builder.build()?;
1476    let resp = configuration.client.execute(req).await?;
1477
1478    let status = resp.status();
1479    let content_type = resp
1480        .headers()
1481        .get("content-type")
1482        .and_then(|v| v.to_str().ok())
1483        .unwrap_or("application/octet-stream");
1484    let content_type = super::ContentType::from(content_type);
1485
1486    if !status.is_client_error() && !status.is_server_error() {
1487        let content = resp.text().await?;
1488        match content_type {
1489            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1490            ContentType::Text => {
1491                return Err(Error::from(serde_json::Error::custom(
1492                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseInstance201Response`"
1493                )));
1494            }
1495            ContentType::Unsupported(unknown_type) => {
1496                return Err(Error::from(serde_json::Error::custom(format!(
1497                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseInstance201Response`"
1498                ))));
1499            }
1500        }
1501    } else {
1502        let content = resp.text().await?;
1503        let entity: Option<GetDatabaseInstanceError> = serde_json::from_str(&content).ok();
1504        Err(Error::ResponseError(ResponseContent {
1505            status,
1506            content,
1507            entity
1508        }))
1509    }
1510}
1511
1512/// Чтобы получить список баз данных на вашем аккаунте, отправьте GET-запрос на
1513/// `/api/v1/databases/{db_cluster_id}/instances`.
1514pub async fn get_database_instances(
1515    configuration: &configuration::Configuration,
1516    db_cluster_id: i32
1517) -> Result<models::GetDatabaseInstances200Response, Error<GetDatabaseInstancesError>> {
1518    // add a prefix to parameters to efficiently prevent name collisions
1519    let p_path_db_cluster_id = db_cluster_id;
1520
1521    let uri_str = format!(
1522        "{}/api/v1/databases/{db_cluster_id}/instances",
1523        configuration.base_path,
1524        db_cluster_id = p_path_db_cluster_id
1525    );
1526    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1527
1528    if let Some(ref user_agent) = configuration.user_agent {
1529        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1530    }
1531    if let Some(ref token) = configuration.bearer_access_token {
1532        req_builder = req_builder.bearer_auth(token.to_owned());
1533    };
1534
1535    let req = req_builder.build()?;
1536    let resp = configuration.client.execute(req).await?;
1537
1538    let status = resp.status();
1539    let content_type = resp
1540        .headers()
1541        .get("content-type")
1542        .and_then(|v| v.to_str().ok())
1543        .unwrap_or("application/octet-stream");
1544    let content_type = super::ContentType::from(content_type);
1545
1546    if !status.is_client_error() && !status.is_server_error() {
1547        let content = resp.text().await?;
1548        match content_type {
1549            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1550            ContentType::Text => {
1551                return Err(Error::from(serde_json::Error::custom(
1552                    "Received `text/plain` content type response that cannot be converted to `models::GetDatabaseInstances200Response`"
1553                )));
1554            }
1555            ContentType::Unsupported(unknown_type) => {
1556                return Err(Error::from(serde_json::Error::custom(format!(
1557                    "Received `{unknown_type}` content type response that cannot be converted to `models::GetDatabaseInstances200Response`"
1558                ))));
1559            }
1560        }
1561    } else {
1562        let content = resp.text().await?;
1563        let entity: Option<GetDatabaseInstancesError> = serde_json::from_str(&content).ok();
1564        Err(Error::ResponseError(ResponseContent {
1565            status,
1566            content,
1567            entity
1568        }))
1569    }
1570}
1571
1572/// Чтобы получить список параметров баз данных, отправьте GET-запрос на
1573/// `/api/v1/dbs/parameters`.
1574pub async fn get_database_parameters(
1575    configuration: &configuration::Configuration
1576) -> Result<models::GetDatabaseParameters200Response, Error<GetDatabaseParametersError>> {
1577    let uri_str = format!("{}/api/v1/dbs/parameters", configuration.base_path);
1578    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1579
1580    if let Some(ref user_agent) = configuration.user_agent {
1581        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1582    }
1583    if let Some(ref token) = configuration.bearer_access_token {
1584        req_builder = req_builder.bearer_auth(token.to_owned());
1585    };
1586
1587    let req = req_builder.build()?;
1588    let resp = configuration.client.execute(req).await?;
1589
1590    let status = resp.status();
1591    let content_type = resp
1592        .headers()
1593        .get("content-type")
1594        .and_then(|v| v.to_str().ok())
1595        .unwrap_or("application/octet-stream");
1596    let content_type = super::ContentType::from(content_type);
1597
1598    if !status.is_client_error() && !status.is_server_error() {
1599        let content = resp.text().await?;
1600        match content_type {
1601            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1602            ContentType::Text => {
1603                return Err(Error::from(serde_json::Error::custom(
1604                    "Received `text/plain` content type response that cannot be converted to `models::GetDatabaseParameters200Response`"
1605                )));
1606            }
1607            ContentType::Unsupported(unknown_type) => {
1608                return Err(Error::from(serde_json::Error::custom(format!(
1609                    "Received `{unknown_type}` content type response that cannot be converted to `models::GetDatabaseParameters200Response`"
1610                ))));
1611            }
1612        }
1613    } else {
1614        let content = resp.text().await?;
1615        let entity: Option<GetDatabaseParametersError> = serde_json::from_str(&content).ok();
1616        Err(Error::ResponseError(ResponseContent {
1617            status,
1618            content,
1619            entity
1620        }))
1621    }
1622}
1623
1624/// Чтобы получить пользователя базы данных на вашем аккаунте, отправьте
1625/// GET-запрос на `/api/v1/databases/{db_cluster_id}/admins/{admin_id}`.
1626pub async fn get_database_user(
1627    configuration: &configuration::Configuration,
1628    db_cluster_id: i32,
1629    admin_id: i32
1630) -> Result<models::CreateDatabaseUser201Response, Error<GetDatabaseUserError>> {
1631    // add a prefix to parameters to efficiently prevent name collisions
1632    let p_path_db_cluster_id = db_cluster_id;
1633    let p_path_admin_id = admin_id;
1634
1635    let uri_str = format!(
1636        "{}/api/v1/databases/{db_cluster_id}/admins/{admin_id}",
1637        configuration.base_path,
1638        db_cluster_id = p_path_db_cluster_id,
1639        admin_id = p_path_admin_id
1640    );
1641    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1642
1643    if let Some(ref user_agent) = configuration.user_agent {
1644        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1645    }
1646    if let Some(ref token) = configuration.bearer_access_token {
1647        req_builder = req_builder.bearer_auth(token.to_owned());
1648    };
1649
1650    let req = req_builder.build()?;
1651    let resp = configuration.client.execute(req).await?;
1652
1653    let status = resp.status();
1654    let content_type = resp
1655        .headers()
1656        .get("content-type")
1657        .and_then(|v| v.to_str().ok())
1658        .unwrap_or("application/octet-stream");
1659    let content_type = super::ContentType::from(content_type);
1660
1661    if !status.is_client_error() && !status.is_server_error() {
1662        let content = resp.text().await?;
1663        match content_type {
1664            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1665            ContentType::Text => {
1666                return Err(Error::from(serde_json::Error::custom(
1667                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseUser201Response`"
1668                )));
1669            }
1670            ContentType::Unsupported(unknown_type) => {
1671                return Err(Error::from(serde_json::Error::custom(format!(
1672                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseUser201Response`"
1673                ))));
1674            }
1675        }
1676    } else {
1677        let content = resp.text().await?;
1678        let entity: Option<GetDatabaseUserError> = serde_json::from_str(&content).ok();
1679        Err(Error::ResponseError(ResponseContent {
1680            status,
1681            content,
1682            entity
1683        }))
1684    }
1685}
1686
1687/// Чтобы получить список пользователей базы данных на вашем аккаунте, отправьте
1688/// GET-запрос на `/api/v1/databases/{db_cluster_id}/admins`.
1689pub async fn get_database_users(
1690    configuration: &configuration::Configuration,
1691    db_cluster_id: i32
1692) -> Result<models::GetDatabaseUsers200Response, Error<GetDatabaseUsersError>> {
1693    // add a prefix to parameters to efficiently prevent name collisions
1694    let p_path_db_cluster_id = db_cluster_id;
1695
1696    let uri_str = format!(
1697        "{}/api/v1/databases/{db_cluster_id}/admins",
1698        configuration.base_path,
1699        db_cluster_id = p_path_db_cluster_id
1700    );
1701    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1702
1703    if let Some(ref user_agent) = configuration.user_agent {
1704        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1705    }
1706    if let Some(ref token) = configuration.bearer_access_token {
1707        req_builder = req_builder.bearer_auth(token.to_owned());
1708    };
1709
1710    let req = req_builder.build()?;
1711    let resp = configuration.client.execute(req).await?;
1712
1713    let status = resp.status();
1714    let content_type = resp
1715        .headers()
1716        .get("content-type")
1717        .and_then(|v| v.to_str().ok())
1718        .unwrap_or("application/octet-stream");
1719    let content_type = super::ContentType::from(content_type);
1720
1721    if !status.is_client_error() && !status.is_server_error() {
1722        let content = resp.text().await?;
1723        match content_type {
1724            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1725            ContentType::Text => {
1726                return Err(Error::from(serde_json::Error::custom(
1727                    "Received `text/plain` content type response that cannot be converted to `models::GetDatabaseUsers200Response`"
1728                )));
1729            }
1730            ContentType::Unsupported(unknown_type) => {
1731                return Err(Error::from(serde_json::Error::custom(format!(
1732                    "Received `{unknown_type}` content type response that cannot be converted to `models::GetDatabaseUsers200Response`"
1733                ))));
1734            }
1735        }
1736    } else {
1737        let content = resp.text().await?;
1738        let entity: Option<GetDatabaseUsersError> = serde_json::from_str(&content).ok();
1739        Err(Error::ResponseError(ResponseContent {
1740            status,
1741            content,
1742            entity
1743        }))
1744    }
1745}
1746
1747/// Чтобы получить список всех баз данных на вашем аккаунте, отправьте
1748/// GET-запрос на `/api/v1/dbs`.   Тело ответа будет представлять собой объект
1749/// JSON с ключом `dbs`.
1750#[deprecated]
1751pub async fn get_databases(
1752    configuration: &configuration::Configuration,
1753    limit: Option<i32>,
1754    offset: Option<i32>
1755) -> Result<models::GetDatabases200Response, Error<GetDatabasesError>> {
1756    // add a prefix to parameters to efficiently prevent name collisions
1757    let p_query_limit = limit;
1758    let p_query_offset = offset;
1759
1760    let uri_str = format!("{}/api/v1/dbs", configuration.base_path);
1761    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1762
1763    if let Some(ref param_value) = p_query_limit {
1764        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
1765    }
1766    if let Some(ref param_value) = p_query_offset {
1767        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
1768    }
1769    if let Some(ref user_agent) = configuration.user_agent {
1770        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1771    }
1772    if let Some(ref token) = configuration.bearer_access_token {
1773        req_builder = req_builder.bearer_auth(token.to_owned());
1774    };
1775
1776    let req = req_builder.build()?;
1777    let resp = configuration.client.execute(req).await?;
1778
1779    let status = resp.status();
1780    let content_type = resp
1781        .headers()
1782        .get("content-type")
1783        .and_then(|v| v.to_str().ok())
1784        .unwrap_or("application/octet-stream");
1785    let content_type = super::ContentType::from(content_type);
1786
1787    if !status.is_client_error() && !status.is_server_error() {
1788        let content = resp.text().await?;
1789        match content_type {
1790            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1791            ContentType::Text => {
1792                return Err(Error::from(serde_json::Error::custom(
1793                    "Received `text/plain` content type response that cannot be converted to `models::GetDatabases200Response`"
1794                )));
1795            }
1796            ContentType::Unsupported(unknown_type) => {
1797                return Err(Error::from(serde_json::Error::custom(format!(
1798                    "Received `{unknown_type}` content type response that cannot be converted to `models::GetDatabases200Response`"
1799                ))));
1800            }
1801        }
1802    } else {
1803        let content = resp.text().await?;
1804        let entity: Option<GetDatabasesError> = serde_json::from_str(&content).ok();
1805        Err(Error::ResponseError(ResponseContent {
1806            status,
1807            content,
1808            entity
1809        }))
1810    }
1811}
1812
1813/// Чтобы получить список тарифов для баз данных, отправьте GET-запрос на
1814/// `/api/v2/presets/dbs`.   Тело ответа будет представлять собой объект JSON с
1815/// ключом `databases_presets`.
1816pub async fn get_databases_presets(
1817    configuration: &configuration::Configuration,
1818    db_id: Option<i32>
1819) -> Result<models::GetDatabasesPresets200Response, Error<GetDatabasesPresetsError>> {
1820    // add a prefix to parameters to efficiently prevent name collisions
1821    let p_query_db_id = db_id;
1822
1823    let uri_str = format!("{}/api/v2/presets/dbs", configuration.base_path);
1824    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1825
1826    if let Some(ref param_value) = p_query_db_id {
1827        req_builder = req_builder.query(&[("db_id", &param_value.to_string())]);
1828    }
1829    if let Some(ref user_agent) = configuration.user_agent {
1830        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1831    }
1832    if let Some(ref token) = configuration.bearer_access_token {
1833        req_builder = req_builder.bearer_auth(token.to_owned());
1834    };
1835
1836    let req = req_builder.build()?;
1837    let resp = configuration.client.execute(req).await?;
1838
1839    let status = resp.status();
1840    let content_type = resp
1841        .headers()
1842        .get("content-type")
1843        .and_then(|v| v.to_str().ok())
1844        .unwrap_or("application/octet-stream");
1845    let content_type = super::ContentType::from(content_type);
1846
1847    if !status.is_client_error() && !status.is_server_error() {
1848        let content = resp.text().await?;
1849        match content_type {
1850            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1851            ContentType::Text => {
1852                return Err(Error::from(serde_json::Error::custom(
1853                    "Received `text/plain` content type response that cannot be converted to `models::GetDatabasesPresets200Response`"
1854                )));
1855            }
1856            ContentType::Unsupported(unknown_type) => {
1857                return Err(Error::from(serde_json::Error::custom(format!(
1858                    "Received `{unknown_type}` content type response that cannot be converted to `models::GetDatabasesPresets200Response`"
1859                ))));
1860            }
1861        }
1862    } else {
1863        let content = resp.text().await?;
1864        let entity: Option<GetDatabasesPresetsError> = serde_json::from_str(&content).ok();
1865        Err(Error::ResponseError(ResponseContent {
1866            status,
1867            content,
1868            entity
1869        }))
1870    }
1871}
1872
1873/// Чтобы восстановить базу данных из бэкапа, отправьте запрос PUT в
1874/// `api/v1/dbs/{db_id}/backups/{backup_id}`.
1875pub async fn restore_database_from_backup(
1876    configuration: &configuration::Configuration,
1877    db_id: i32,
1878    backup_id: i32
1879) -> Result<(), Error<RestoreDatabaseFromBackupError>> {
1880    // add a prefix to parameters to efficiently prevent name collisions
1881    let p_path_db_id = db_id;
1882    let p_path_backup_id = backup_id;
1883
1884    let uri_str = format!(
1885        "{}/api/v1/dbs/{db_id}/backups/{backup_id}",
1886        configuration.base_path,
1887        db_id = p_path_db_id,
1888        backup_id = p_path_backup_id
1889    );
1890    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1891
1892    if let Some(ref user_agent) = configuration.user_agent {
1893        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1894    }
1895    if let Some(ref token) = configuration.bearer_access_token {
1896        req_builder = req_builder.bearer_auth(token.to_owned());
1897    };
1898
1899    let req = req_builder.build()?;
1900    let resp = configuration.client.execute(req).await?;
1901
1902    let status = resp.status();
1903
1904    if !status.is_client_error() && !status.is_server_error() {
1905        Ok(())
1906    } else {
1907        let content = resp.text().await?;
1908        let entity: Option<RestoreDatabaseFromBackupError> = serde_json::from_str(&content).ok();
1909        Err(Error::ResponseError(ResponseContent {
1910            status,
1911            content,
1912            entity
1913        }))
1914    }
1915}
1916
1917/// Чтобы обновить только определенные атрибуты базы данных, отправьте запрос
1918/// PATCH в `api/v1/dbs/{db_id}`.
1919#[deprecated]
1920pub async fn update_database(
1921    configuration: &configuration::Configuration,
1922    db_id: i32,
1923    update_db: models::UpdateDb
1924) -> Result<models::CreateDatabase201Response, Error<UpdateDatabaseError>> {
1925    // add a prefix to parameters to efficiently prevent name collisions
1926    let p_path_db_id = db_id;
1927    let p_body_update_db = update_db;
1928
1929    let uri_str = format!(
1930        "{}/api/v1/dbs/{db_id}",
1931        configuration.base_path,
1932        db_id = p_path_db_id
1933    );
1934    let mut req_builder = configuration
1935        .client
1936        .request(reqwest::Method::PATCH, &uri_str);
1937
1938    if let Some(ref user_agent) = configuration.user_agent {
1939        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1940    }
1941    if let Some(ref token) = configuration.bearer_access_token {
1942        req_builder = req_builder.bearer_auth(token.to_owned());
1943    };
1944    req_builder = req_builder.json(&p_body_update_db);
1945
1946    let req = req_builder.build()?;
1947    let resp = configuration.client.execute(req).await?;
1948
1949    let status = resp.status();
1950    let content_type = resp
1951        .headers()
1952        .get("content-type")
1953        .and_then(|v| v.to_str().ok())
1954        .unwrap_or("application/octet-stream");
1955    let content_type = super::ContentType::from(content_type);
1956
1957    if !status.is_client_error() && !status.is_server_error() {
1958        let content = resp.text().await?;
1959        match content_type {
1960            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1961            ContentType::Text => {
1962                return Err(Error::from(serde_json::Error::custom(
1963                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabase201Response`"
1964                )));
1965            }
1966            ContentType::Unsupported(unknown_type) => {
1967                return Err(Error::from(serde_json::Error::custom(format!(
1968                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabase201Response`"
1969                ))));
1970            }
1971        }
1972    } else {
1973        let content = resp.text().await?;
1974        let entity: Option<UpdateDatabaseError> = serde_json::from_str(&content).ok();
1975        Err(Error::ResponseError(ResponseContent {
1976            status,
1977            content,
1978            entity
1979        }))
1980    }
1981}
1982
1983/// Чтобы изменить список настроек автобэкапов базы данных, отправьте запрос
1984/// PATCH в `api/v1/dbs/{db_id}/auto-backups`
1985pub async fn update_database_auto_backups_settings(
1986    configuration: &configuration::Configuration,
1987    db_id: i32,
1988    auto_backup: Option<models::AutoBackup>
1989) -> Result<
1990    models::GetDatabaseAutoBackupsSettings200Response,
1991    Error<UpdateDatabaseAutoBackupsSettingsError>
1992> {
1993    // add a prefix to parameters to efficiently prevent name collisions
1994    let p_path_db_id = db_id;
1995    let p_body_auto_backup = auto_backup;
1996
1997    let uri_str = format!(
1998        "{}/api/v1/dbs/{db_id}/auto-backups",
1999        configuration.base_path,
2000        db_id = p_path_db_id
2001    );
2002    let mut req_builder = configuration
2003        .client
2004        .request(reqwest::Method::PATCH, &uri_str);
2005
2006    if let Some(ref user_agent) = configuration.user_agent {
2007        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2008    }
2009    if let Some(ref token) = configuration.bearer_access_token {
2010        req_builder = req_builder.bearer_auth(token.to_owned());
2011    };
2012    req_builder = req_builder.json(&p_body_auto_backup);
2013
2014    let req = req_builder.build()?;
2015    let resp = configuration.client.execute(req).await?;
2016
2017    let status = resp.status();
2018    let content_type = resp
2019        .headers()
2020        .get("content-type")
2021        .and_then(|v| v.to_str().ok())
2022        .unwrap_or("application/octet-stream");
2023    let content_type = super::ContentType::from(content_type);
2024
2025    if !status.is_client_error() && !status.is_server_error() {
2026        let content = resp.text().await?;
2027        match content_type {
2028            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2029            ContentType::Text => {
2030                return Err(Error::from(serde_json::Error::custom(
2031                    "Received `text/plain` content type response that cannot be converted to `models::GetDatabaseAutoBackupsSettings200Response`"
2032                )));
2033            }
2034            ContentType::Unsupported(unknown_type) => {
2035                return Err(Error::from(serde_json::Error::custom(format!(
2036                    "Received `{unknown_type}` content type response that cannot be converted to `models::GetDatabaseAutoBackupsSettings200Response`"
2037                ))));
2038            }
2039        }
2040    } else {
2041        let content = resp.text().await?;
2042        let entity: Option<UpdateDatabaseAutoBackupsSettingsError> =
2043            serde_json::from_str(&content).ok();
2044        Err(Error::ResponseError(ResponseContent {
2045            status,
2046            content,
2047            entity
2048        }))
2049    }
2050}
2051
2052/// Чтобы изменить кластер базы данных на вашем аккаунте, отправьте PATCH-запрос
2053/// на `/api/v1/databases/{db_cluster_id}`.
2054pub async fn update_database_cluster(
2055    configuration: &configuration::Configuration,
2056    db_cluster_id: i32,
2057    update_cluster: models::UpdateCluster
2058) -> Result<models::CreateDatabaseCluster201Response, Error<UpdateDatabaseClusterError>> {
2059    // add a prefix to parameters to efficiently prevent name collisions
2060    let p_path_db_cluster_id = db_cluster_id;
2061    let p_body_update_cluster = update_cluster;
2062
2063    let uri_str = format!(
2064        "{}/api/v1/databases/{db_cluster_id}",
2065        configuration.base_path,
2066        db_cluster_id = p_path_db_cluster_id
2067    );
2068    let mut req_builder = configuration
2069        .client
2070        .request(reqwest::Method::PATCH, &uri_str);
2071
2072    if let Some(ref user_agent) = configuration.user_agent {
2073        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2074    }
2075    if let Some(ref token) = configuration.bearer_access_token {
2076        req_builder = req_builder.bearer_auth(token.to_owned());
2077    };
2078    req_builder = req_builder.json(&p_body_update_cluster);
2079
2080    let req = req_builder.build()?;
2081    let resp = configuration.client.execute(req).await?;
2082
2083    let status = resp.status();
2084    let content_type = resp
2085        .headers()
2086        .get("content-type")
2087        .and_then(|v| v.to_str().ok())
2088        .unwrap_or("application/octet-stream");
2089    let content_type = super::ContentType::from(content_type);
2090
2091    if !status.is_client_error() && !status.is_server_error() {
2092        let content = resp.text().await?;
2093        match content_type {
2094            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2095            ContentType::Text => {
2096                return Err(Error::from(serde_json::Error::custom(
2097                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseCluster201Response`"
2098                )));
2099            }
2100            ContentType::Unsupported(unknown_type) => {
2101                return Err(Error::from(serde_json::Error::custom(format!(
2102                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseCluster201Response`"
2103                ))));
2104            }
2105        }
2106    } else {
2107        let content = resp.text().await?;
2108        let entity: Option<UpdateDatabaseClusterError> = serde_json::from_str(&content).ok();
2109        Err(Error::ResponseError(ResponseContent {
2110            status,
2111            content,
2112            entity
2113        }))
2114    }
2115}
2116
2117/// Чтобы изменить инстанс базы данных, отправьте PATCH-запрос на
2118/// `/api/v1/databases/{db_cluster_id}/instances/{instance_id}`.
2119pub async fn update_database_instance(
2120    configuration: &configuration::Configuration,
2121    db_cluster_id: i32,
2122    instance_id: i32,
2123    update_instance: models::UpdateInstance
2124) -> Result<models::CreateDatabaseInstance201Response, Error<UpdateDatabaseInstanceError>> {
2125    // add a prefix to parameters to efficiently prevent name collisions
2126    let p_path_db_cluster_id = db_cluster_id;
2127    let p_path_instance_id = instance_id;
2128    let p_body_update_instance = update_instance;
2129
2130    let uri_str = format!(
2131        "{}/api/v1/databases/{db_cluster_id}/instances/{instance_id}",
2132        configuration.base_path,
2133        db_cluster_id = p_path_db_cluster_id,
2134        instance_id = p_path_instance_id
2135    );
2136    let mut req_builder = configuration
2137        .client
2138        .request(reqwest::Method::PATCH, &uri_str);
2139
2140    if let Some(ref user_agent) = configuration.user_agent {
2141        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2142    }
2143    if let Some(ref token) = configuration.bearer_access_token {
2144        req_builder = req_builder.bearer_auth(token.to_owned());
2145    };
2146    req_builder = req_builder.json(&p_body_update_instance);
2147
2148    let req = req_builder.build()?;
2149    let resp = configuration.client.execute(req).await?;
2150
2151    let status = resp.status();
2152    let content_type = resp
2153        .headers()
2154        .get("content-type")
2155        .and_then(|v| v.to_str().ok())
2156        .unwrap_or("application/octet-stream");
2157    let content_type = super::ContentType::from(content_type);
2158
2159    if !status.is_client_error() && !status.is_server_error() {
2160        let content = resp.text().await?;
2161        match content_type {
2162            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2163            ContentType::Text => {
2164                return Err(Error::from(serde_json::Error::custom(
2165                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseInstance201Response`"
2166                )));
2167            }
2168            ContentType::Unsupported(unknown_type) => {
2169                return Err(Error::from(serde_json::Error::custom(format!(
2170                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseInstance201Response`"
2171                ))));
2172            }
2173        }
2174    } else {
2175        let content = resp.text().await?;
2176        let entity: Option<UpdateDatabaseInstanceError> = serde_json::from_str(&content).ok();
2177        Err(Error::ResponseError(ResponseContent {
2178            status,
2179            content,
2180            entity
2181        }))
2182    }
2183}
2184
2185/// Чтобы изменить пользователя базы данных на вашем аккаунте, отправьте
2186/// PATCH-запрос на `/api/v1/databases/{db_cluster_id}/admins/{admin_id}`.
2187pub async fn update_database_user(
2188    configuration: &configuration::Configuration,
2189    db_cluster_id: i32,
2190    admin_id: i32,
2191    update_admin: models::UpdateAdmin
2192) -> Result<models::CreateDatabaseUser201Response, Error<UpdateDatabaseUserError>> {
2193    // add a prefix to parameters to efficiently prevent name collisions
2194    let p_path_db_cluster_id = db_cluster_id;
2195    let p_path_admin_id = admin_id;
2196    let p_body_update_admin = update_admin;
2197
2198    let uri_str = format!(
2199        "{}/api/v1/databases/{db_cluster_id}/admins/{admin_id}",
2200        configuration.base_path,
2201        db_cluster_id = p_path_db_cluster_id,
2202        admin_id = p_path_admin_id
2203    );
2204    let mut req_builder = configuration
2205        .client
2206        .request(reqwest::Method::PATCH, &uri_str);
2207
2208    if let Some(ref user_agent) = configuration.user_agent {
2209        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2210    }
2211    if let Some(ref token) = configuration.bearer_access_token {
2212        req_builder = req_builder.bearer_auth(token.to_owned());
2213    };
2214    req_builder = req_builder.json(&p_body_update_admin);
2215
2216    let req = req_builder.build()?;
2217    let resp = configuration.client.execute(req).await?;
2218
2219    let status = resp.status();
2220    let content_type = resp
2221        .headers()
2222        .get("content-type")
2223        .and_then(|v| v.to_str().ok())
2224        .unwrap_or("application/octet-stream");
2225    let content_type = super::ContentType::from(content_type);
2226
2227    if !status.is_client_error() && !status.is_server_error() {
2228        let content = resp.text().await?;
2229        match content_type {
2230            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2231            ContentType::Text => {
2232                return Err(Error::from(serde_json::Error::custom(
2233                    "Received `text/plain` content type response that cannot be converted to `models::CreateDatabaseUser201Response`"
2234                )));
2235            }
2236            ContentType::Unsupported(unknown_type) => {
2237                return Err(Error::from(serde_json::Error::custom(format!(
2238                    "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDatabaseUser201Response`"
2239                ))));
2240            }
2241        }
2242    } else {
2243        let content = resp.text().await?;
2244        let entity: Option<UpdateDatabaseUserError> = serde_json::from_str(&content).ok();
2245        Err(Error::ResponseError(ResponseContent {
2246            status,
2247            content,
2248            entity
2249        }))
2250    }
2251}