DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Cover image for Managing buckets with Reduct Storage CLI Client
Alexey Timin for ReductStore

Posted on

Managing buckets with Reduct Storage CLI Client

A bucket is a top-level data container of Reduct Storage. You can consider it as a folder of a file system. If you delete it, you delete all files inside the bucket. Also, it has common settings for all entries, like the quota or maximal block size.

You can create, remove or browse a bucket by using:

  1. HTTP API with CURL
  2. Python, JavaScript, or C++ SDKs
  3. Web Console
  4. CLI Client

In this post, I'll show you how we can use the CLI client for typical operations with bucket.

Installing

The CLI client is cross-platform and written in pure Python. The easiest way to install it, is pip:

pip install reduct-cli
Enter fullscreen mode Exit fullscreen mode

After installation, check the version:

rcli --version
Enter fullscreen mode Exit fullscreen mode

This tutorial was written and tested for version 0.2.0 and Reduct Storage 1.0.1.

Aliasing

To avoid entering credentials and server URL for each command, the CLI client uses aliases. So, we should setup one before to start. Let's run a Reduct Storage instance locally and add an alias to it:

rcli alias add local
  URL: http://127.0.0.1:8383
  API Token []: # leav token empty if you don't use it
Enter fullscreen mode Exit fullscreen mode

Check:

rcli server status local
Status:     Ok
Version:    1.0.1
Uptime:     39 second(s)
Enter fullscreen mode Exit fullscreen mode

If you don't have any errors, you create a correct alias.

Bucket Management

Now, we can create a bucket:

rcli bucket create --quota-type FIFO --quota-size 30Mb local/my-data
Bucket 'my-data' created
Enter fullscreen mode Exit fullscreen mode

Here we created a bucket called my-data and FIFO quota of 30MB. We choose this type of the bucket quota to remove old data when the bucket size reaches 30MB.

You can check the whole settings:

rcli bucket show local/my-data --full

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Info โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎโ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Settings โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Entry count:         0                         โ”‚โ”‚ Quota Type:         FIFO   โ”‚
โ”‚ Size:                0 B                       โ”‚โ”‚ Quota Size:         30 MB  โ”‚
โ”‚ Oldest Record (UTC): ---                       โ”‚โ”‚ Max. Block Size:    64 MB  โ”‚
โ”‚ Latest Record (UTC): ---                       โ”‚โ”‚ Max. Block Records: 1024   โ”‚
โ”‚ History Interval:    ---                       โ”‚โ”‚                            โ”‚
โ”‚                                                โ”‚โ”‚                            โ”‚
โ”‚                                                โ”‚โ”‚                            โ”‚
โ”‚                                                โ”‚โ”‚                            โ”‚
โ”‚                                                โ”‚โ”‚                            โ”‚
โ”‚                                                โ”‚โ”‚                            โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
                                    Entries                                     
โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ      โ”ƒ         โ”ƒ        โ”ƒ      โ”ƒ Oldest Record   โ”ƒ Latest Record   โ”ƒ         โ”ƒ
โ”ƒ Name โ”ƒ Records โ”ƒ Blocks โ”ƒ Size โ”ƒ (UTC)           โ”ƒ (UTC)           โ”ƒ History โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Enter fullscreen mode Exit fullscreen mode

You may also notice that the bucket is empty. We can write some data there with CURL:

curl -X POST -d "Hey, I'm a blob string"  http://127.0.0.1:8383/api/v1/b/my-data/entry?ts=1667741359000000
Enter fullscreen mode Exit fullscreen mode

If we repeat the previous bucket show command, we should see that the bucket has some data now:

rcli bucket show local/my-data --full
Enter fullscreen mode Exit fullscreen mode

The CLI client also provides the bucket ls command to print a list of buckets:

rcli bucket ls local
my-data
Enter fullscreen mode Exit fullscreen mode

You also can add --full flag to show more detail:

rcli bucket ls local --full

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ                  โ”ƒ             โ”ƒ      โ”ƒ Oldest Record     โ”ƒ Latest Record    โ”ƒ
โ”ƒ             Name โ”ƒ Entry Count โ”ƒ Size โ”ƒ (UTC)             โ”ƒ (UTC)            โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚          my-data โ”‚ 1           โ”‚ 22 B โ”‚ 2022-11-06T13:29โ€ฆ โ”‚ 2022-11-06T13:2โ€ฆ โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚      Total for 1 โ”‚ 1           โ”‚ 22 B โ”‚ 2022-11-06T13:29โ€ฆ โ”‚ 2022-11-06T13:2โ€ฆ โ”‚
โ”‚          buckets โ”‚             โ”‚      โ”‚                   โ”‚                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Enter fullscreen mode Exit fullscreen mode

In the end, you may want to remove your bucket and all its data. You should use the bucket rm command for this:

rcli bucket rm local/my-data
All data in bucket 'my-data' will be REMOVED.
Do you want to continue? [y/N]: y
Bucket 'my-data' was removed
Enter fullscreen mode Exit fullscreen mode

I hope it was helpful. The Reduct Storage project is open-source software. You can find the source code of the storage engine and all its libraries and tools on our GitHub organization. Please create an issue or discussion there, if you need help.

Top comments (0)

Stop sifting through your feed.

Find the content you want to see.

Change your feed algorithm by adjusting your experience level and give weights to the tags you follow.