Skip to content

Commit 37ef9c5

Browse files
authored
Extend snapshotting and forking page with ListObjects, GetObject and HeadObject info (#286)
* Extend snapshotting and forking page with ListObjects, GetObject and HeadObject info * Remove this from upcoming features * prettier
1 parent 22a30e9 commit 37ef9c5

File tree

2 files changed

+74
-9
lines changed

2 files changed

+74
-9
lines changed

docs/buckets/snapshots-and-forks.mdx

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,8 @@ Example using the Go SDK `github.com/aws/aws-sdk-go-v2/service/s3`:
375375

376376
```go
377377
func createBucketFork(ctx context.Context, client *s3.Client, bucketName string) error {
378-
_, err := client.CreateBucket(ctx, &s3.CreateBucketInput{Bucket: aws.String(bucketName)},
379-
func(options *s3.Options) {
380-
options.APIOptions = append(
381-
options.APIOptions,
382-
http.AddHeaderValue("X-Tigris-Fork-Source-Bucket", "PARENT_BUCKET_NAME"),
383-
)
378+
_, err := client.CreateBucket(ctx, &s3.CreateBucketInput{Bucket: aws.String(bucketName)}, func(options *s3.Options) {
379+
options.APIOptions = append(options.APIOptions, http.AddHeaderValue("X-Tigris-Fork-Source-Bucket", "PARENT_BUCKET_NAME"))
384380
})
385381
return err
386382
}
@@ -424,6 +420,68 @@ def create_bucket_fork(tigris, bucket_name):
424420
</TabItem>
425421
</Tabs>
426422

423+
### Listing and Retrieving Objects from a Snapshot
424+
425+
Objects can be listed in a snapshot with the same ListObjectsV2 API call, with
426+
an additional header: `X-Tigris-Snapshot-Version: SNAPSHOT_VERSION`. Similarly,
427+
specific versions of an object in a particular snapshot can be retrieved with
428+
the same GetObject API call and header. The same approach also applies to
429+
HeadObject requests.
430+
431+
Below is an example of retrieving an object from a snapshot:
432+
433+
<Tabs groupId="languages">
434+
<TabItem value="go" label="Go">
435+
Example using the Go SDK `github.com/aws/aws-sdk-go-v2/service/s3`:
436+
437+
```go
438+
func getObjectFromSnapshot(ctx context.Context, client *s3.Client, bucket string, object string, snapshotVersion string) (*s3.GetObjectOutput, error) {
439+
return client.GetObject(ctx, &s3.GetObjectInput{Bucket: aws.String(bucket), Key: aws.String(object)}, func(options *s3.Options) {
440+
options.APIOptions = append(options.APIOptions, http.AddHeaderValue("X-Tigris-Snapshot-Version", snapshotVersion))
441+
})
442+
}
443+
```
444+
445+
</TabItem>
446+
447+
<TabItem value="js" label="JavaScript">
448+
Example using the AWS SDK for JavaScript v3:
449+
450+
```js
451+
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
452+
453+
async function getObjectFromSnapshot(client, bucket, key, snapshotVersion) {
454+
return client.send(
455+
new GetObjectCommand({
456+
Bucket: bucket,
457+
Key: key,
458+
$httpOptions: {
459+
headers: { "X-Tigris-Snapshot-Version": snapshotVersion },
460+
},
461+
}),
462+
);
463+
}
464+
```
465+
466+
</TabItem>
467+
<TabItem value="python" label="Python">
468+
Example using the Python SDK boto3:
469+
470+
```python
471+
def get_object_from_snapshot(s3_client, bucket_name, object_key, snapshot_version):
472+
def add_header(request, **kwargs):
473+
request.headers["X-Tigris-Snapshot-Version"] = snapshot_version
474+
s3_client.meta.events.register("before-sign.s3.GetObject", add_header)
475+
try:
476+
response = s3_client.get_object(Bucket=bucket_name, Key=object_key)
477+
return response
478+
finally:
479+
s3_client.meta.events.unregister("before-sign.s3.GetObject", add_header)
480+
```
481+
482+
</TabItem>
483+
</Tabs>
484+
427485
### Using a Forked Bucket
428486

429487
Forked buckets behave the same as regular buckets, and you can use the usual
@@ -432,6 +490,14 @@ tooling (AWS CLI or SDK) to work with them.
432490
The only restriction is that the parent bucket cannot be deleted while forked
433491
buckets depend on it.
434492

493+
### Authorization
494+
495+
Snapshotting and forking operations on existing buckets are limited to users who
496+
are bucket owners, organization admins, or have `ReadOnly` (or `Editor`) access
497+
to the buckets. This includes all operations mentioned above, such as creating a
498+
snapshot, creating a fork from a specific parent bucket, or listing objects in a
499+
snapshot.
500+
435501
## Limitations and Upcoming Functionality
436502

437503
### Current Limitations
@@ -450,7 +516,6 @@ limitations:
450516

451517
### Upcoming Features
452518

453-
- Listing and retrieving objects from a specific bucket snapshot.
454519
- Listing all versions of an object.
455520
- Snapshot and fork management in the Tigris Dashboard.
456521
- Deletion of old snapshots.

docs/sdks/tigris/snapshots-and-forks.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ Forks can be created using the `createBucket` function and by passing
8383
import { createBucket } from "@tigrisdata/storage";
8484

8585
const createFork = await createBucket(
86-
"llm-fork", // forkname
86+
"llm-fork", // name of the fork bucket being created
8787
{
88-
sourceBucketName: "llm-base", // source bucket name
88+
sourceBucketName: "llm-base", // name of the fork parent bucket
8989
},
9090
);
9191

0 commit comments

Comments
 (0)