Skip to content

clients.b2 #

B2 Client (Backblase S3 service)

see https://github.com/Backblaze/b2-sdk-python for methods

https://b2-sdk-python.readthedocs.io/en/master/quick_start.html

see examples/clients/b2_kristof.vsh for example

fn get #

fn get(instance string, cfg Config) !B2Client[Config]

fn heroplay #

fn heroplay(mut plbook playbook.PlayBook) !

run heroscript starting from path, text or giturl

 !!b2client.define
     name:'tf_write_1'
     description:'ThreeFold Read Write Repo 1
     keyid:'003e2a7be6357fb0000000001'
     keyname:'tfrw'
     appkey:'K003UsdrYOZou2ulBHA8p4KLa/dL2n4'


 path    string
 text    string
 git_url     string
```	

fn (B2Client[Config]) config_interactive #

fn (mut self B2Client[Config]) config_interactive() !

fn (B2Client[Config]) create_bucket #

fn (mut self B2Client[Config]) create_bucket(args_ CreateBucketArgs) !

fn (B2Client[Config]) delete_bucket #

fn (mut self B2Client[Config]) delete_bucket(args_ DeleteBucketArgs) !

fn (B2Client[Config]) download #

fn (mut self B2Client[Config]) download(args_ DownloadArgs) !

fn (B2Client[Config]) list_buckets #

fn (mut self B2Client[Config]) list_buckets() ![]BucketData

fn (B2Client[Config]) list_files #

fn (mut self B2Client[Config]) list_files(args_ ListBucketArgs) ![]BucketFile

fn (B2Client[Config]) sync #

fn (mut self B2Client[Config]) sync(args_ SyncArgs) !

fn (B2Client[Config]) upload #

fn (mut self B2Client[Config]) upload(args_ UploadArgs) !

enum BucketType #

enum BucketType {
	allpublic
	allprivate
}

bucket type enum

fn (BucketType) to_string #

fn (bt BucketType) to_string() string

Implement the to_string method for the Fruit enum

struct B2Client #

struct B2Client[T] {
	base.BaseConfig[T]
pub mut:
	py python.PythonEnv
}

struct BucketData #

struct BucketData {
pub:
	id    string
	type_ string
	name  string
}

struct BucketFile #

struct BucketFile {
	file_name        string
	upload_timestamp time.Time
}

struct Config #

@[params]
struct Config {
pub mut:
	keyid      string
	appkey     string @[secret]
	bucketname string // can be empty is the default
}

struct CreateBucketArgs #

@[params]
struct CreateBucketArgs {
pub mut:
	bucketname string
	buckettype BucketType
}

create Bucket

struct DeleteBucketArgs #

@[params]
struct DeleteBucketArgs {
pub mut:
	bucketname string
}

Delete Bucket

struct DownloadArgs #

@[params]
struct DownloadArgs {
pub mut:
	file_name  string
	dest       string
	bucketname string
}

download

struct ListBucketArgs #

struct ListBucketArgs {
	bucketname string
}

struct SyncArgs #

struct SyncArgs {
	source string // local dir /home/afouda/Documents/testdir
	dest   string // bucket url b2://testdir
}

Todo: download/upload of full dir (sync)

struct UploadArgs #

@[params]
struct UploadArgs {
pub mut:
	src        string
	dest       string
	bucketname string
}