Skip to content

Commit

Permalink
[server] Add admin db rename #872 (#912)
Browse files Browse the repository at this point in the history
* fix rename with backup

* add admin db rename

* refactor add db

* refactoring

* rename

* exec

* add user

* fixes

* user

* fix coverage
  • Loading branch information
michaelvlach authored Dec 23, 2023
1 parent cafac48 commit 0a8812f
Show file tree
Hide file tree
Showing 25 changed files with 1,004 additions and 914 deletions.
106 changes: 67 additions & 39 deletions agdb_server/openapi/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ServerDatabaseSize"
"$ref": "#/components/schemas/ServerDatabase"
}
}
}
Expand Down Expand Up @@ -295,6 +295,61 @@
]
}
},
"/api/v1/admin/db/{owner}/{db}/rename": {
"post": {
"tags": [
"crate::routes::admin::db"
],
"operationId": "rename",
"parameters": [
{
"name": "owner",
"in": "path",
"description": "db owner user name",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "db",
"in": "path",
"description": "db name",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "new_name",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"201": {
"description": "db renamed"
},
"401": {
"description": "unauthorized"
},
"404": {
"description": "user / db not found"
},
"467": {
"description": "invalid db"
}
},
"security": [
{
"Token": []
}
]
}
},
"/api/v1/admin/db/{owner}/{db}/user/list": {
"get": {
"tags": [
Expand Down Expand Up @@ -624,7 +679,7 @@
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ServerDatabaseWithRole"
"$ref": "#/components/schemas/ServerDatabase"
}
}
}
Expand Down Expand Up @@ -889,7 +944,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ServerDatabaseSize"
"$ref": "#/components/schemas/ServerDatabase"
}
}
}
Expand Down Expand Up @@ -990,7 +1045,7 @@
}
],
"responses": {
"204": {
"201": {
"description": "db renamed"
},
"401": {
Expand Down Expand Up @@ -1415,22 +1470,12 @@
"$ref": "#/components/schemas/QueryResult"
}
},
"ServerDatabaseRename": {
"type": "object",
"required": [
"new_name"
],
"properties": {
"new_name": {
"type": "string"
}
}
},
"ServerDatabaseSize": {
"ServerDatabase": {
"type": "object",
"required": [
"name",
"db_type",
"role",
"size",
"backup"
],
Expand All @@ -1446,41 +1491,24 @@
"name": {
"type": "string"
},
"role": {
"$ref": "#/components/schemas/DbUserRole"
},
"size": {
"type": "integer",
"format": "int64",
"minimum": 0
}
}
},
"ServerDatabaseWithRole": {
"ServerDatabaseRename": {
"type": "object",
"required": [
"name",
"db_type",
"role",
"size",
"backup"
"new_name"
],
"properties": {
"backup": {
"type": "integer",
"format": "int64",
"minimum": 0
},
"db_type": {
"$ref": "#/components/schemas/DbType"
},
"name": {
"new_name": {
"type": "string"
},
"role": {
"$ref": "#/components/schemas/DbUserRole"
},
"size": {
"type": "integer",
"format": "int64",
"minimum": 0
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions agdb_server/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use utoipa::OpenApi;
crate::routes::admin::db::exec,
crate::routes::admin::db::list,
crate::routes::admin::db::optimize,
crate::routes::admin::db::rename,
crate::routes::admin::db::remove,
crate::routes::admin::db::user::add,
crate::routes::admin::db::user::list,
Expand Down Expand Up @@ -42,8 +43,7 @@ use utoipa::OpenApi;
crate::routes::db::DbTypeParam,
crate::routes::db::Queries,
crate::routes::db::QueriesResults,
crate::routes::db::ServerDatabaseSize,
crate::routes::db::ServerDatabaseWithRole,
crate::routes::db::ServerDatabase,
crate::routes::db::ServerDatabaseRename,
crate::routes::db::user::DbUser,
crate::routes::db::user::DbUserRole,
Expand Down
4 changes: 4 additions & 0 deletions agdb_server/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub(crate) fn app(config: Config, shutdown_sender: Sender<()>, db_pool: DbPool)
"/admin/db/:user/:db/remove",
routing::delete(routes::admin::db::remove),
)
.route(
"/admin/db/:user/:db/rename",
routing::post(routes::admin::db::rename),
)
.route(
"/admin/db/:user/:db/user/list",
routing::get(routes::admin::db::user::list),
Expand Down
Loading

0 comments on commit 0a8812f

Please sign in to comment.