Skip to content

threefold.zerohub #

ZeroHub

This is a SAL for the ZeroHub

The default hub we connect to is https://hub.grid.tf/

for developers

more info see https://github.com/threefoldtech/0-hub#public-api-endpoints-no-authentication-needed

TODO: implement each endpoint on the zerohub here at client

Hub Authorization

ZeroHub authorized enpoints can be accessed with exporting a jwt in env vars. to do so:- go to https://hub.grid.tf, and on the login section try Generate API Token

  • copy the token you got and export HUB_JWT=<jwt>

fn new #

fn new(args ZeroHubClientArgs) !ZeroHubClient

see https://hub.grid.tf/ more info see https://github.com/threefoldtech/0-hub#public-api-endpoints-no-authentication-needed

struct File #

struct File {
pub:
	size i64
	path string
}

struct FlistContents #

struct FlistContents {
pub:
	regular   i32
	failure   i32
	directory i32
	symlink   string
	fullsize  i64
	content   []File
}

struct FlistInfo #

struct FlistInfo {
pub:
	name     string
	size     string
	updated  i64
	type_    string
	linktime i64
	target   string
}

struct Repository #

struct Repository {
pub:
	name     string
	official bool
}

struct ZeroHubClient #

struct ZeroHubClient {
pub mut:
	url    string
	secret string // is called bearer in documentation	
	header http.Header
}

Todo: curl -H "Authorization: bearer 6Pz6giOpHSaA3KdYI6LLpGSLmDmzmRkVdwvc7S-E5PVB0-iRfgDKW9Rb_ZTlj-xEW4_uSCa5VsyoRsML7DunA1sia3Jpc3RvZi4zYm90IiwgMTY3OTIxNTc3MF0=" https://hub.grid.tf/api/flist/

fn (ZeroHubClient) convert #

fn (mut cl ZeroHubClient) convert(image string) !string

fn (ZeroHubClient) get_files #

fn (mut cl ZeroHubClient) get_files() !map[string][]FlistInfo

fn (ZeroHubClient) get_flist_dump #

fn (mut cl ZeroHubClient) get_flist_dump(repo_name string, flist_name string) !FlistContents

fn (ZeroHubClient) get_flists #

fn (mut cl ZeroHubClient) get_flists() ![]string

fn (ZeroHubClient) get_me #

fn (mut cl ZeroHubClient) get_me() !json2.Any

fn (ZeroHubClient) get_my_flist #

fn (mut cl ZeroHubClient) get_my_flist(flist string) !FlistContents

fn (ZeroHubClient) get_repo_flists #

fn (mut cl ZeroHubClient) get_repo_flists(repo_name string) ![]FlistInfo

fn (ZeroHubClient) get_repos #

fn (mut cl ZeroHubClient) get_repos() ![]Repository

fn (ZeroHubClient) merge_flists #

fn (mut cl ZeroHubClient) merge_flists(flists []string, target string) !string

fn (ZeroHubClient) promote #

fn (mut cl ZeroHubClient) promote(source_repo string, source_name string, localname string) !string

fn (ZeroHubClient) remove_my_flist #

fn (mut cl ZeroHubClient) remove_my_flist(flist string) !json2.Any

fn (ZeroHubClient) rename #

fn (mut cl ZeroHubClient) rename(source string, dest string) !string

fn (ZeroHubClient) upload_archive #

fn (mut cl ZeroHubClient) upload_archive(path string) !os.Result

fn (ZeroHubClient) upload_flist #

fn (mut cl ZeroHubClient) upload_flist(path string) !os.Result

struct ZeroHubClientArgs #

@[params]
struct ZeroHubClientArgs {
pub:
	url    string = 'hub.grid.tf'
	secret string // is called bearer in documentation	
}