vaultrs/api/database/requests.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
use super::responses::{
GenerateCredentialsResponse, GetStaticCredentialsResponse, ListConnectionsResponse,
ListRolesResponse, ListStaticRolesResponse, ReadConnectionResponse, ReadRoleResponse,
ReadStaticRoleResponse,
};
use rustify_derive::Endpoint;
use std::fmt::Debug;
/// ## Configure Connection
/// This endpoint configures the connection string used to communicate with the
/// desired database.
/// * Path: {self.mount}/config/{self.name}
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docssecret/databases#configure-connection>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/config/{self.name}",
method = "POST",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct PostgreSQLConnectionRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
pub connection_url: String,
pub plugin_name: String,
pub allowed_roles: Option<Vec<String>>, // Default parameters
pub password_policy: Option<String>,
pub root_rotation_statements: Option<Vec<String>>,
pub verify_connection: Option<bool>,
pub max_connection_lifetime: Option<String>, // PostgresSQL specific parameters
pub max_idle_connections: Option<u64>,
pub max_open_connections: Option<u64>,
pub password: Option<String>,
pub username: Option<String>,
pub username_template: Option<String>,
}
/// ## Read Connection
/// This endpoint returns the configuration settings for a connection.
///
/// * Path: {self.mount}/config/{self.name}
/// * Method: GET
/// * Response: [ReadConnectionResponse]]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#read-connection>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/config/{self.name}",
response = "ReadConnectionResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ReadConnectionRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## List Connections
/// This endpoint returns a list of available connections.
///
/// * Path: {self.mount}/config
/// * Method: LIST
/// * Response: [ListConnectionsResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#list-connections>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/config",
method = "LIST",
response = "ListConnectionsResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ListConnectionsRequest {
#[endpoint(skip)]
pub mount: String,
}
/// ## Delete Connection
/// This endpoint deletes a connection.
///
/// * Path: {{self.mount}/config/{self.name}
/// * Method: DELETE
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#delete-connection>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/config/{self.name}",
method = "DELETE",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct DeleteConnectionRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## Reset Connection
/// This endpoint closes a connection and it's underlying plugin and restarts it
/// with the configuration stored in the barrier.
///
/// * Path: {{self.mount}/reset/{self.name}
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#reset-connection>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/reset/{self.name}",
method = "POST",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ResetConnectionRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## Rotate Root Credentials
/// This endpoint is used to rotate the "root" user credentials stored for the
/// database connection.
///
/// * Path: {{self.mount}/rotate-root/{self.name}
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#rotate-root-credentials>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/rotate-root/{self.name}",
method = "POST",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct RotateRootRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## Create Role
/// This endpoint creates or updates a role definition.
///
/// * Path: {{self.mount}/roles/{self.name}
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#create-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/roles/{self.name}",
method = "POST",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct SetRoleRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
pub creation_statements: Option<Vec<String>>,
pub db_name: String,
pub default_ttl: Option<String>,
pub max_ttl: Option<String>,
pub renew_statements: Option<Vec<String>>,
pub revocation_statements: Option<Vec<String>>,
pub rollback_statements: Option<Vec<String>>,
}
/// ## Read Role
/// This endpoint queries the role definition.
///
/// * Path: {{self.mount}/roles/{self.name}
/// * Method: GET
/// * Response: [ReadRoleResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#read-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/roles/{self.name}",
response = "ReadRoleResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ReadRoleRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## List Roles
/// This endpoint returns a list of available roles.
///
/// * Path: {self.mount}/roles
/// * Method: LIST
/// * Response: [ListRolesResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#list-roles>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/roles",
method = "LIST",
response = "ListRolesResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ListRolesRequest {
#[endpoint(skip)]
pub mount: String,
}
/// ## Delete Role
/// This endpoint deletes the role definition.
///
/// * Path: {{self.mount}/roles/{self.name}
/// * Method: DELETE
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#delete-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/roles/{self.name}",
method = "DELETE",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct DeleteRoleRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## Generate Credentials
/// This endpoint generates a new set of dynamic credentials based on the named
/// role.
///
/// * Path: {{self.mount}/creds/{self.name}
/// * Method: GET
/// * Response: [GenerateCredentialsResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#read-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/creds/{self.name}",
response = "GenerateCredentialsResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct GenerateCredentialsRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## Create Static Role
/// This endpoint creates or updates a static role definition.
///
/// * Path: {{self.mount}/static-oles/{self.name}
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#create-static-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/static-roles/{self.name}",
method = "POST",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct SetStaticRoleRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
pub db_name: String,
pub username: String,
pub rotation_period: String,
pub rotation_statements: Option<Vec<String>>,
}
/// ## Read Static Role
/// This endpoint queries the static role definition.
///
/// * Path: {{self.mount}/static-roles/{self.name}
/// * Method: GET
/// * Response: [ReadStaticRoleResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#read-static-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/static-roles/{self.name}",
response = "ReadStaticRoleResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ReadStaticRoleRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## List Static Roles
/// This endpoint returns a list of available static roles.
///
/// * Path: {self.mount}/static-roles
/// * Method: LIST
/// * Response: [ListStaticRolesResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#list-static-roles>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/static-roles",
method = "LIST",
response = "ListStaticRolesResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ListStaticRolesRequest {
#[endpoint(skip)]
pub mount: String,
}
/// ## Delete Static Role
/// This endpoint deletes the static role definition.
///
/// * Path: {{self.mount}/static-roles/{self.name}
/// * Method: DELETE
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#delete-static-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/static-roles/{self.name}",
method = "DELETE",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct DeleteStaticRoleRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## Get Static Credentials
/// This endpoint returns the current credentials based on the named static role.
///
/// * Path: {self.mount}/static-creds/{self.name}
/// * Method: GET
/// * Response: [GetStaticCredentialsResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#get-static-credentials>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/static-creds/{self.name}",
response = "GetStaticCredentialsResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct GetStaticCredentialsRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## Rotate Static Role Credentials
/// This endpoint is used to rotate the Static Role credentials stored for a
/// given role name.
///
/// * Path: {{self.mount}/rotate-role/{self.name}
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/databases#rotate-static-role-credentials>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/rotate-role/{self.name}",
method = "POST",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct RotateStaticRoleRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}