Skip to content

Commit

Permalink
feat(cli): add remove bucket to update source (#360)
Browse files Browse the repository at this point in the history
* feat(cli): add detach bucket to update source
  • Loading branch information
joe-prosser authored Feb 20, 2025
1 parent 6662df6 commit 6b29070
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- Add --detach-bucket to `update source`

# v0.36.3
- Fix a typo in get datasets docs
- Allow for round tripping regex pattens in entity defs
Expand Down
1 change: 0 additions & 1 deletion api/src/resources/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ pub struct UpdateSource<'request> {
#[serde(skip_serializing_if = "Option::is_none")]
pub should_translate: Option<bool>,

#[serde(skip_serializing_if = "Option::is_none")]
pub bucket_id: Option<BucketId>,

#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
7 changes: 7 additions & 0 deletions cli/src/commands/update/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ pub struct UpdateSourceArgs {
#[structopt(long = "transform-tag")]
/// Set the transform tag of the source
transform_tag: Option<TransformTag>,

#[structopt(long = "detach-bucket")]
/// Detach bucket from source
detach_bucket: bool,
}

pub fn update(client: &Client, args: &UpdateSourceArgs, printer: &Printer) -> Result<()> {
Expand All @@ -39,6 +43,7 @@ pub fn update(client: &Client, args: &UpdateSourceArgs, printer: &Printer) -> Re
should_translate,
bucket,
transform_tag,
detach_bucket,
} = args;

let bucket_id = match bucket.to_owned() {
Expand All @@ -60,6 +65,8 @@ pub fn update(client: &Client, args: &UpdateSourceArgs, printer: &Printer) -> Re
.full_name(),
};

let bucket_id = if *detach_bucket { None } else { bucket_id };

let source = client
.update_source(
&source_full_name,
Expand Down
6 changes: 5 additions & 1 deletion cli/src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl DisplayTable for Project {

impl DisplayTable for Source {
fn to_table_headers() -> Row {
row![bFg => "Name", "ID", "Updated (UTC)", "Transform Tag", "Title"]
row![bFg => "Name", "ID", "Updated (UTC)", "Transform Tag", "Title", "Bucket"]
}

fn to_table_row(&self) -> Row {
Expand All @@ -208,6 +208,10 @@ impl DisplayTable for Source {
None => "missing".dimmed(),
},
self.title,
match &self.bucket_id {
Some(bucket) => bucket.0.as_str().into(),
None => "missing".dimmed(),
}
]
}
}
Expand Down

0 comments on commit 6b29070

Please sign in to comment.