admin api: generate params from struct
This commit is contained in:
parent
795b4a41b7
commit
0b12debf6c
3 changed files with 72 additions and 27 deletions
|
@ -554,13 +554,25 @@
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"description": "Admin API token ID",
|
"description": "Admin API token ID",
|
||||||
"required": true
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "search",
|
"name": "search",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"description": "Partial token ID or name to search for",
|
"description": "Partial token ID or name to search for",
|
||||||
"required": true
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
@ -634,19 +646,37 @@
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"description": "Exact bucket ID to look up",
|
"description": "Exact bucket ID to look up",
|
||||||
"required": true
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "globalAlias",
|
"name": "globalAlias",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"description": "Global alias of bucket to look up",
|
"description": "Global alias of bucket to look up",
|
||||||
"required": true
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "search",
|
"name": "search",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"description": "Partial ID or alias to search for",
|
"description": "Partial ID or alias to search for",
|
||||||
"required": true
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
@ -795,19 +825,34 @@
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"description": "Access key ID",
|
"description": "Access key ID",
|
||||||
"required": true
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "search",
|
"name": "search",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"description": "Partial key ID or name to search for",
|
"description": "Partial key ID or name to search for",
|
||||||
"required": true
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "showSecretKey",
|
"name": "showSecretKey",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"description": "Whether to return the secret access key",
|
"description": "Whether to return the secret access key",
|
||||||
"required": true
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use paste::paste;
|
use paste::paste;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use utoipa::ToSchema;
|
use utoipa::{IntoParams, ToSchema};
|
||||||
|
|
||||||
use garage_rpc::*;
|
use garage_rpc::*;
|
||||||
|
|
||||||
|
@ -303,9 +303,12 @@ pub struct ListAdminTokensResponse(pub Vec<GetAdminTokenInfoResponse>);
|
||||||
|
|
||||||
// ---- GetAdminTokenInfo ----
|
// ---- GetAdminTokenInfo ----
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct GetAdminTokenInfoRequest {
|
pub struct GetAdminTokenInfoRequest {
|
||||||
|
/// Admin API token ID
|
||||||
pub id: Option<String>,
|
pub id: Option<String>,
|
||||||
|
/// Partial token ID or name to search for
|
||||||
pub search: Option<String>,
|
pub search: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,10 +637,15 @@ pub struct ListKeysResponseItem {
|
||||||
|
|
||||||
// ---- GetKeyInfo ----
|
// ---- GetKeyInfo ----
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct GetKeyInfoRequest {
|
pub struct GetKeyInfoRequest {
|
||||||
|
/// Access key ID
|
||||||
pub id: Option<String>,
|
pub id: Option<String>,
|
||||||
|
/// Partial key ID or name to search for
|
||||||
pub search: Option<String>,
|
pub search: Option<String>,
|
||||||
|
/// Whether to return the secret access key
|
||||||
|
#[serde(default)]
|
||||||
pub show_secret_key: bool,
|
pub show_secret_key: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,10 +769,14 @@ pub struct BucketLocalAlias {
|
||||||
|
|
||||||
// ---- GetBucketInfo ----
|
// ---- GetBucketInfo ----
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct GetBucketInfoRequest {
|
pub struct GetBucketInfoRequest {
|
||||||
|
/// Exact bucket ID to look up
|
||||||
pub id: Option<String>,
|
pub id: Option<String>,
|
||||||
|
/// Global alias of bucket to look up
|
||||||
pub global_alias: Option<String>,
|
pub global_alias: Option<String>,
|
||||||
|
/// Partial ID or alias to search for
|
||||||
pub search: Option<String>,
|
pub search: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ do not correspond to an actual website.
|
||||||
)]
|
)]
|
||||||
fn CheckDomain() -> () {}
|
fn CheckDomain() -> () {}
|
||||||
|
|
||||||
|
|
||||||
// **********************************************
|
// **********************************************
|
||||||
// Cluster operations
|
// Cluster operations
|
||||||
// **********************************************
|
// **********************************************
|
||||||
|
@ -141,10 +140,7 @@ fn ListAdminTokens() -> () {}
|
||||||
Return information about a specific admin API token.
|
Return information about a specific admin API token.
|
||||||
You can search by specifying the exact token identifier (`id`) or by specifying a pattern (`search`).
|
You can search by specifying the exact token identifier (`id`) or by specifying a pattern (`search`).
|
||||||
",
|
",
|
||||||
params(
|
params(GetAdminTokenInfoRequest),
|
||||||
("id", description = "Admin API token ID"),
|
|
||||||
("search", description = "Partial token ID or name to search for"),
|
|
||||||
),
|
|
||||||
responses(
|
responses(
|
||||||
(status = 200, description = "Information about the admin token", body = GetAdminTokenInfoResponse),
|
(status = 200, description = "Information about the admin token", body = GetAdminTokenInfoResponse),
|
||||||
(status = 500, description = "Internal server error")
|
(status = 500, description = "Internal server error")
|
||||||
|
@ -337,11 +333,7 @@ You can search by specifying the exact key identifier (`id`) or by specifying a
|
||||||
|
|
||||||
For confidentiality reasons, the secret key is not returned by default: you must pass the `showSecretKey` query parameter to get it.
|
For confidentiality reasons, the secret key is not returned by default: you must pass the `showSecretKey` query parameter to get it.
|
||||||
",
|
",
|
||||||
params(
|
params(GetKeyInfoRequest),
|
||||||
("id", description = "Access key ID"),
|
|
||||||
("search", description = "Partial key ID or name to search for"),
|
|
||||||
("showSecretKey", description = "Whether to return the secret access key"),
|
|
||||||
),
|
|
||||||
responses(
|
responses(
|
||||||
(status = 200, description = "Information about the access key", body = GetKeyInfoResponse),
|
(status = 200, description = "Information about the access key", body = GetKeyInfoResponse),
|
||||||
(status = 500, description = "Internal server error")
|
(status = 500, description = "Internal server error")
|
||||||
|
@ -434,11 +426,7 @@ It includes its aliases, its web configuration, keys that have some permissions
|
||||||
on it, some statistics (number of objects, size), number of dangling multipart uploads,
|
on it, some statistics (number of objects, size), number of dangling multipart uploads,
|
||||||
and its quotas (if any).
|
and its quotas (if any).
|
||||||
",
|
",
|
||||||
params(
|
params(GetBucketInfoRequest),
|
||||||
("id", description = "Exact bucket ID to look up"),
|
|
||||||
("globalAlias", description = "Global alias of bucket to look up"),
|
|
||||||
("search", description = "Partial ID or alias to search for"),
|
|
||||||
),
|
|
||||||
responses(
|
responses(
|
||||||
(status = 200, description = "Returns exhaustive information about the bucket", body = GetBucketInfoResponse),
|
(status = 200, description = "Returns exhaustive information about the bucket", body = GetBucketInfoResponse),
|
||||||
(status = 500, description = "Internal server error")
|
(status = 500, description = "Internal server error")
|
||||||
|
|
Loading…
Add table
Reference in a new issue