Skip to content

Commit 98feab6

Browse files
designcodegreptile-apps[bot]MantasMiksys
authored
feat(sdk): add docs for listBuckets, removeBucket and support of snapshots in get, head and list (#290)
* feat(sdk): add docs for list and remove bucket * Update docs/sdks/tigris/using-sdk.mdx Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * feat(sdk): docs for snapshotVersion support in get, head and list * chore: typo * chore: pr comments * Apply suggestion from @MantasMiksys * chore: linting --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: Mantas Miksys <[email protected]>
1 parent 979dea1 commit 98feab6

File tree

2 files changed

+123
-4
lines changed

2 files changed

+123
-4
lines changed

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

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ await createBucketSnapshot("llm-base", {
4949
});
5050
```
5151

52-
### List snapshots for the bucket
52+
### List snapshots of a bucket
5353

5454
A list of snapshots for the bucket can be retrieved using the
5555
`listBucketSnapshots` function.
@@ -64,11 +64,23 @@ if (result.error) {
6464
} else {
6565
console.log("Snapshots:");
6666
result.data.forEach((snapshot) => {
67-
console.log(`- ${snapshot.snapshotName}: ${snapshot.creationDate}`);
67+
console.log(`- ${snapshot.version}: ${snapshot.creationDate}`);
6868
});
6969
}
7070
```
7171

72+
### List objects in a snapshot
73+
74+
Objects in a snapshot can be listed using the `list` function.
75+
76+
```ts
77+
import { list } from "@tigrisdata/storage";
78+
79+
const result = await list("llm-base", {
80+
snapshotVersion: "1760550614083112540",
81+
});
82+
```
83+
7284
## Forks
7385

7486
Fork is a new bucket created from an existing one, sharing data without
@@ -103,11 +115,11 @@ import { createBucket } from "@tigrisdata/storage";
103115

104116
const forkName = "llm-fork";
105117
const sourceBucketName = "llm-base";
106-
const sourceBucketSnapshotName = "fine-tuned-model";
118+
const sourceBucketSnapshot = "1760550614083112540";
107119

108120
const fromSnapshot = await createBucket(forkName, {
109121
sourceBucketName: sourceBucketName,
110-
sourceBucketSnapshot: sourceBucketSnapshotName,
122+
sourceBucketSnapshot: sourceBucketSnapshot,
111123
});
112124

113125
if (fromSnapshot.error) {
@@ -133,3 +145,26 @@ await createBucketSnapshot({
133145

134146
await listBucketSnapshots();
135147
```
148+
149+
## Getting an object from a snapshot
150+
151+
An object from a snapshot can be retrieved using the `get` function.
152+
153+
```ts
154+
import { get } from "@tigrisdata/storage";
155+
156+
const result = await get("object.txt", {
157+
snapshotVersion: "1760550614083112540",
158+
});
159+
```
160+
161+
Similarly, `head` function can be used to get the metadata of an object from a
162+
specific snapshot.
163+
164+
```ts
165+
import { head } from "@tigrisdata/storage";
166+
167+
const result = await head("object.txt", {
168+
snapshotVersion: "1760550614083112540",
169+
});
170+
```

docs/sdks/tigris/using-sdk.mdx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,3 +468,87 @@ if (currentPage.data) {
468468

469469
console.log(allFiles);
470470
```
471+
472+
## Listing buckets
473+
474+
`listBuckets` function can be used to list all buckets that the user has access
475+
to.
476+
477+
### `listBuckets`
478+
479+
```ts
480+
listBuckets(options?: ListBucketsOptions): Promise<TigrisStorageResponse<ListBucketsResponse, Error>>;
481+
```
482+
483+
`listBuckets` accepts the following parameters
484+
485+
- `options`: (Optional) A JSON object with the following optional parameters:
486+
487+
#### `options`
488+
489+
| **Parameter** | **Required** | **Values** |
490+
| --------------- | ------------ | -------------------------------------------------------------------------------- |
491+
| limit | No | The maximum number of buckets to return. |
492+
| paginationToken | No | The pagination token to continue listing buckets from the previous request. |
493+
| config | No | A configuration object to override the [default configuration](#authentication). |
494+
495+
In case of successful `listBuckets`, the `data` property will be set to the list
496+
of buckets and will contain the following properties:
497+
498+
- `buckets`: The list of buckets
499+
- `owner`: The owner of the buckets
500+
- `paginationToken`: The pagination token to continue listing buckets for the
501+
next page.
502+
503+
### Examples
504+
505+
#### Listing buckets
506+
507+
```ts
508+
const result = await listBuckets();
509+
510+
if (result.error) {
511+
console.error("Error listing buckets:", result.error);
512+
} else {
513+
console.log("Buckets:", result.data);
514+
}
515+
```
516+
517+
## Deleting a bucket
518+
519+
`removeBucket` function can be used to delete a bucket.
520+
521+
### `removeBucket`
522+
523+
```ts
524+
removeBucket(bucketName: string, options?: RemoveBucketOptions): Promise<TigrisStorageResponse<void, Error>>;
525+
```
526+
527+
`removeBucket` accepts the following parameters:
528+
529+
- `bucketName`: (Required) A string specifying the name of the bucket
530+
- `options`: (Optional) A JSON object with the following optional parameters:
531+
532+
#### `options`
533+
534+
| **Parameter** | **Required** | **Values** |
535+
| ------------- | ------------ | -------------------------------------------------------------------------------- |
536+
| force | No | When provided, forcefully delete the bucket. |
537+
| config | No | A configuration object to override the [default configuration](#authentication). |
538+
539+
In case of successful `removeBucket`, the `data` property will be set to
540+
`undefined` and the bucket will be deleted.
541+
542+
### Examples
543+
544+
#### Deleting a bucket
545+
546+
```ts
547+
const result = await removeBucket("my-bucket");
548+
549+
if (result.error) {
550+
console.error("Error deleting bucket:", result.error);
551+
} else {
552+
console.log("Bucket deleted successfully");
553+
}
554+
```

0 commit comments

Comments
 (0)