Skip to content

clients.rclone #

a sal to work with rclone

Rclone is this incredible swiss army knive to deal with S3 storage servers.

Example

import incubaid.herolib.osal.core.rclone

fn main() {
 do() or { panic(err) }
}

fn do() ! {
 mut z:=rclone.new()!

 // name      string            @[required]
 // cmd       string            @[required]
 // cmd_file  bool  //if we wanna force to run it as a file which is given to bash -c  (not just a cmd in rclone)
 // test      string
 // test_file bool
 // after     []string
 // env       map[string]string
 // oneshot   bool
 p:=z.new(
  name:'test'
  cmd:'/bin/bash'
 )!

}

protocol defined in

sal on top of https://github.com/threefoldtech/rclone/tree/master

https://github.com/threefoldtech/rclone/blob/master/docs/protocol.md

Constants #

const version = '0.0.0'

fn check_installed #

fn check_installed() bool

check_installed checks if rclone is installed

fn configure #

fn configure() !

will look for personal configuration file in ~/hero/config . this file is in heroscript format and will have all required info to configure rclone

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

fn delete #

fn delete(args ArgsGet) !

fn exists #

fn exists(args ArgsGet) !bool

does the config exists?

fn get #

fn get(args ArgsGet) !&RCloneClient

fn heroscript_default #

fn heroscript_default() !string

fn heroscript_dumps #

fn heroscript_dumps(obj RCloneClient) !string

///////////NORMALLY NO NEED TO TOUCH

fn heroscript_loads #

fn heroscript_loads(heroscript string) !RCloneClient

fn list #

fn list(args ArgsList) ![]&RCloneClient

if fromdb set: load from filesystem, and not from mem, will also reset what is in mem

fn new #

fn new(args ArgsGet) !&RCloneClient

fn play #

fn play(mut plbook PlayBook) !

fn set #

fn set(o RCloneClient) !

register the config for the future

fn switch #

fn switch(name string)

switch instance to be used for rclone

struct ArgsGet #

@[params]
struct ArgsGet {
pub mut:
	name   string = 'default'
	fromdb bool // will load from filesystem
	create bool // default will not create if not exist
}

///////FACTORY

struct ArgsList #

@[params]
struct ArgsList {
pub mut:
	fromdb bool // will load from filesystem
}

struct RCloneClient #

@[heap]
struct RCloneClient {
pub mut:
	name       string = 'default'
	type_      string = 's3'  // remote type (s3, sftp, etc)
	provider   string = 'aws' // provider for s3 (aws, minio, etc)
	access_key string // access key for authentication
	secret_key string // secret key for authentication
	region     string = 'us-east-1' // region for s3
	endpoint   string // custom endpoint URL if needed
}

fn (RCloneClient) download #

fn (mut r RCloneClient) download(remote_path string, local_path string) !

download downloads a file or directory from the remote

fn (RCloneClient) list #

fn (mut r RCloneClient) list(remote_path string) !string

list lists contents of a remote path

fn (RCloneClient) mount #

fn (mut r RCloneClient) mount(remote_path string, local_path string) !

mount mounts a remote at the specified path

fn (RCloneClient) unmount #

fn (mut r RCloneClient) unmount(local_path string) !

unmount unmounts a mounted remote

fn (RCloneClient) upload #

fn (mut r RCloneClient) upload(local_path string, remote_path string) !

upload uploads a file or directory to the remote