Skip to content

Commit bb29d3a

Browse files
designcodeclaude
andcommitted
feat(cli): support default-tier updates and snapshot-scoped object restore
- buckets set: add `--default-tier` to change an existing bucket's default storage tier - objects restore / restore-info: add `--snapshot-version` (alias `--snapshot`) to target a point-in-time bucket snapshot Assisted-by: Claude Opus 4.8 (1M context) via Claude Code Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 55a3b54 commit bb29d3a

5 files changed

Lines changed: 44 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tigrisdata/cli": minor
3+
---
4+
5+
Add `--default-tier` to `tigris buckets set` and `--snapshot-version` (alias `--snapshot`) to `tigris objects restore` / `tigris objects restore-info`.

packages/cli/src/lib/buckets/set.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { getStorageConfigWithOrg } from '@auth/provider.js';
2-
import { type UpdateBucketOptions, updateBucket } from '@tigrisdata/storage';
2+
import {
3+
type StorageClass,
4+
type UpdateBucketOptions,
5+
updateBucket,
6+
} from '@tigrisdata/storage';
37
import { failWithError } from '@utils/exit.js';
48
import { parseLocations } from '@utils/locations.js';
59
import { msg, printStart, printSuccess } from '@utils/messages.js';
@@ -14,6 +18,10 @@ export default async function set(options: Record<string, unknown>) {
1418

1519
const name = getOption<string>(options, ['name']);
1620
const access = getOption<string>(options, ['access']);
21+
const defaultTier = getOption<string>(options, [
22+
'default-tier',
23+
'defaultTier',
24+
]);
1725
const locations = getOption<string | string[]>(options, ['locations']);
1826
const allowObjectAcl = getOption<string | boolean>(options, [
1927
'allow-object-acl',
@@ -52,6 +60,7 @@ export default async function set(options: Record<string, unknown>) {
5260
// Check if at least one setting is provided
5361
if (
5462
access === undefined &&
63+
defaultTier === undefined &&
5564
locations === undefined &&
5665
allowObjectAcl === undefined &&
5766
disableDirectoryListing === undefined &&
@@ -71,6 +80,10 @@ export default async function set(options: Record<string, unknown>) {
7180
updateOptions.access = access as 'public' | 'private';
7281
}
7382

83+
if (defaultTier !== undefined) {
84+
updateOptions.defaultTier = defaultTier as StorageClass;
85+
}
86+
7487
if (locations !== undefined) {
7588
updateOptions.locations = parseLocations(locations);
7689
}

packages/cli/src/lib/objects/restore-info.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export default async function restoreInfo(options: Record<string, unknown>) {
1515
const bucketArg = getOption<string>(options, ['bucket']);
1616
const keyArg = getOption<string>(options, ['key']);
1717
const versionId = getOption<string>(options, ['version-id', 'versionId']);
18+
const snapshotVersion = getOption<string>(options, [
19+
'snapshot-version',
20+
'snapshotVersion',
21+
'snapshot',
22+
]);
1823

1924
if (!bucketArg) {
2025
failWithError(context, 'Bucket name or path is required');
@@ -30,6 +35,7 @@ export default async function restoreInfo(options: Record<string, unknown>) {
3035

3136
const { data, error } = await getRestoreInfo(key, {
3237
...(versionId ? { versionId } : {}),
38+
...(snapshotVersion ? { snapshotVersion } : {}),
3339
config: {
3440
...config,
3541
bucket,

packages/cli/src/lib/objects/restore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export default async function restore(options: Record<string, unknown>) {
1414
const bucketArg = getOption<string>(options, ['bucket']);
1515
const keyArg = getOption<string>(options, ['key']);
1616
const versionId = getOption<string>(options, ['version-id', 'versionId']);
17+
const snapshotVersion = getOption<string>(options, [
18+
'snapshot-version',
19+
'snapshotVersion',
20+
'snapshot',
21+
]);
1722
const daysArg = getOption<string | number>(options, ['days', 'd']);
1823

1924
if (!bucketArg) {
@@ -39,6 +44,7 @@ export default async function restore(options: Record<string, unknown>) {
3944
const { error } = await restoreObject(key, {
4045
...(days !== undefined ? { days } : {}),
4146
...(versionId ? { versionId } : {}),
47+
...(snapshotVersion ? { snapshotVersion } : {}),
4248
config: {
4349
...config,
4450
bucket,

packages/cli/src/specs.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,10 +914,11 @@ commands:
914914
- my-bucket
915915
# set
916916
- name: set
917-
description: Update settings on an existing bucket such as access level, location, caching, or custom domain
917+
description: Update settings on an existing bucket such as access level, default tier, location, caching, or custom domain
918918
alias: s
919919
examples:
920920
- "tigris buckets set my-bucket --access public"
921+
- "tigris buckets set my-bucket --default-tier GLACIER"
921922
- "tigris buckets set my-bucket --locations iad,fra --cache-control 'max-age=3600'"
922923
- "tigris buckets set my-bucket --custom-domain assets.example.com"
923924
- "tigris buckets set my-bucket --soft-delete enable --retention-days 30"
@@ -936,6 +937,9 @@ commands:
936937
- name: access
937938
description: Bucket access level
938939
options: *access_options
940+
- name: default-tier
941+
description: Change the default storage tier for objects uploaded to the bucket
942+
options: *tier_options
939943
- name: region
940944
removed: true
941945
replaced_by: --locations
@@ -1666,6 +1670,7 @@ commands:
16661670
- "tigris objects restore my-bucket archived.bin"
16671671
- "tigris objects restore my-bucket archived.bin --days 3"
16681672
- "tigris objects restore t3://my-bucket/archived.bin --days 7"
1673+
- "tigris objects restore my-bucket archived.bin --snapshot-version 1765889000501544464"
16691674
messages:
16701675
onStart: 'Requesting restore...'
16711676
onSuccess: "Restore requested for '{{key}}'"
@@ -1684,6 +1689,9 @@ commands:
16841689
default: 1
16851690
- name: version-id
16861691
description: Restore a specific object version (requires bucket versioning). Omit to restore the current version
1692+
- name: snapshot-version
1693+
description: Restore the object as of a specific bucket snapshot. Accepts a snapshot version string or any UNIX nanosecond-precision timestamp (e.g. 1765889000501544464)
1694+
alias: snapshot
16871695
- name: format
16881696
description: Output format
16891697
options: [json, table, xml]
@@ -1695,6 +1703,7 @@ commands:
16951703
examples:
16961704
- "tigris objects restore-info my-bucket archived.bin"
16971705
- "tigris objects restore-info t3://my-bucket/archived.bin --format json"
1706+
- "tigris objects restore-info my-bucket archived.bin --snapshot-version 1765889000501544464"
16981707
messages:
16991708
onStart: ''
17001709
onSuccess: ''
@@ -1710,6 +1719,9 @@ commands:
17101719
description: Key of the object (omit if bucket contains the full path)
17111720
- name: version-id
17121721
description: Inspect a specific object version (requires bucket versioning). Omit to read the current version
1722+
- name: snapshot-version
1723+
description: Inspect the object as of a specific bucket snapshot. Accepts a snapshot version string or any UNIX nanosecond-precision timestamp (e.g. 1765889000501544464)
1724+
alias: snapshot
17131725
- name: format
17141726
description: Output format
17151727
options: [json, table, xml]

0 commit comments

Comments
 (0)