Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ pub enum DatabasesCommands {
#[arg(long = "table")]
tables: Vec<String>,

/// When the database expires. Accepts a relative duration (e.g. 24h, 7d, 90m)
/// or an RFC 3339 timestamp. Defaults to 24h when omitted.
#[arg(long)]
expires_at: Option<String>,

/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
Expand Down
11 changes: 10 additions & 1 deletion src/databases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub fn create_database_request(
description: Option<&str>,
schema: &str,
tables: &[String],
expires_at: Option<&str>,
) -> serde_json::Value {
let mut req = serde_json::Map::new();

Expand All @@ -151,6 +152,13 @@ pub fn create_database_request(
);
}

if let Some(exp) = expires_at {
req.insert(
"expires_at".to_string(),
serde_json::Value::String(exp.to_string()),
Comment thread
eddietejeda marked this conversation as resolved.
);
}
Comment thread
eddietejeda marked this conversation as resolved.

serde_json::Value::Object(req)
}

Expand Down Expand Up @@ -414,11 +422,12 @@ pub fn create(
description: Option<&str>,
schema: &str,
tables: &[String],
expires_at: Option<&str>,
format: &str,
) {
use crossterm::style::Stylize;

let body = create_database_request(description, schema, tables);
let body = create_database_request(description, schema, tables, expires_at);

let api = ApiClient::new(Some(workspace_id));
let spinner = (format == "table").then(|| crate::util::spinner("Creating database..."));
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,14 @@ fn main() {
description,
schema,
tables,
expires_at,
output,
}) => databases::create(
&workspace_id,
description.as_deref(),
&schema,
&tables,
expires_at.as_deref(),
&output,
),
Some(DatabasesCommands::Set { id_or_description }) => {
Expand Down
Loading