zboxutil

package
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 29 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ALLOCATION_ENDPOINT      = "/allocation"
	UPLOAD_ENDPOINT          = "/v1/file/upload/"
	ATTRS_ENDPOINT           = "/v1/file/attributes/"
	RENAME_ENDPOINT          = "/v1/file/rename/"
	COPY_ENDPOINT            = "/v1/file/copy/"
	LIST_ENDPOINT            = "/v1/file/list/"
	REFERENCE_ENDPOINT       = "/v1/file/referencepath/"
	CONNECTION_ENDPOINT      = "/v1/connection/details/"
	COMMIT_ENDPOINT          = "/v1/connection/commit/"
	DOWNLOAD_ENDPOINT        = "/v1/file/download/"
	LATEST_READ_MARKER       = "/v1/readmarker/latest"
	FILE_META_ENDPOINT       = "/v1/file/meta/"
	FILE_STATS_ENDPOINT      = "/v1/file/stats/"
	OBJECT_TREE_ENDPOINT     = "/v1/file/objecttree/"
	REFS_ENDPOINT            = "/v1/file/refs/"
	COMMIT_META_TXN_ENDPOINT = "/v1/file/commitmetatxn/"
	COLLABORATOR_ENDPOINT    = "/v1/file/collaborator/"
	CALCULATE_HASH_ENDPOINT  = "/v1/file/calculatehash/"
	SHARE_ENDPOINT           = "/v1/marketplace/shareinfo/"
	DIR_ENDPOINT             = "/v1/dir/"

	// CLIENT_SIGNATURE_HEADER represents http request header contains signature.
	CLIENT_SIGNATURE_HEADER = "X-App-Client-Signature"
)
View Source
const EncryptedFolderName = "encrypted"
View Source
const MAX_RETRIES = 5
View Source
const REGISTER_CLIENT = "v1/client/put"
View Source
const SC_REST_API_URL = "v1/screst/"
View Source
const SLEEP_BETWEEN_RETRIES = 5

Variables

View Source
var DefaultTransport = &http.Transport{
	Proxy: envProxy.Proxy,
	DialContext: (&net.Dialer{
		Timeout:   45 * time.Second,
		KeepAlive: 45 * time.Second,
		DualStack: true,
	}).DialContext,
	MaxIdleConns:          100,
	IdleConnTimeout:       90 * time.Second,
	TLSHandshakeTimeout:   10 * time.Second,
	ExpectContinueTimeout: 1 * time.Second,
	MaxIdleConnsPerHost:   100,
}

Functions

func Decrypt

func Decrypt(key, text []byte) ([]byte, error)

func DeleteCollaboratorRequest

func DeleteCollaboratorRequest(baseUrl string, allocation string, body io.Reader) (*http.Request, error)

func Encrypt

func Encrypt(key, text []byte) ([]byte, error)

func GetCollaboratorsRequest

func GetCollaboratorsRequest(baseUrl string, allocation string, body io.Reader) (*http.Request, error)

func GetFileContentType

func GetFileContentType(out *os.File) (string, error)

func GetFullRemotePath

func GetFullRemotePath(localPath, remotePath string) string

func GetRefsHash added in v1.3.0

func GetRefsHash(r []byte) string

func HttpDo

func HttpDo(ctx context.Context, cncl context.CancelFunc, req *http.Request, f func(*http.Response, error) error) error

func IsRemoteAbs

func IsRemoteAbs(path string) bool

func Join

func Join(a, b string) string

func MakeSCRestAPICall

func MakeSCRestAPICall(scAddress string, relativePath string, params map[string]string, handler SCRestAPIHandler) ([]byte, error)

func NewAllocationRequest

func NewAllocationRequest(baseUrl, allocation string) (*http.Request, error)

func NewAttributesRequest

func NewAttributesRequest(baseUrl, allocation string, body io.Reader) (
	req *http.Request, err error)

func NewCalculateHashRequest

func NewCalculateHashRequest(baseUrl, allocation string, paths []string) (*http.Request, error)

func NewCollaboratorRequest

func NewCollaboratorRequest(baseUrl string, allocation string, body io.Reader) (*http.Request, error)

func NewCommitMetaTxnRequest

func NewCommitMetaTxnRequest(baseUrl string, allocation string, body io.Reader) (*http.Request, error)

func NewCommitRequest

func NewCommitRequest(baseUrl, allocation string, body io.Reader) (*http.Request, error)

func NewConnectionId

func NewConnectionId() string

NewConnectionId generate new connection id

func NewCopyRequest

func NewCopyRequest(baseUrl, allocation string, body io.Reader) (*http.Request, error)

func NewCreateDirRequest

func NewCreateDirRequest(baseUrl, allocation string, body io.Reader) (*http.Request, error)

func NewDeleteRequest

func NewDeleteRequest(baseUrl, allocation string, body io.Reader) (*http.Request, error)

func NewDownloadRequest

func NewDownloadRequest(baseUrl, allocation string, body io.Reader) (*http.Request, error)

func NewFileMetaRequest

func NewFileMetaRequest(baseUrl string, allocation string, body io.Reader) (*http.Request, error)

func NewFileStatsRequest

func NewFileStatsRequest(baseUrl string, allocation string, body io.Reader) (*http.Request, error)

func NewHTTPRequest

func NewHTTPRequest(method string, url string, data []byte) (*http.Request, context.Context, context.CancelFunc, error)

func NewListRequest

func NewListRequest(baseUrl, allocation string, path, pathHash string, auth_token string) (*http.Request, error)

func NewObjectTreeRequest

func NewObjectTreeRequest(baseUrl, allocation string, path string) (*http.Request, error)

func NewReferencePathRequest

func NewReferencePathRequest(baseUrl, allocation string, paths []string) (*http.Request, error)

func NewRefsRequest added in v1.3.0

func NewRefsRequest(baseUrl, allocationID, path, offsetPath, updatedDate, offsetDate, fileType, refType string, level, pageLimit int) (*http.Request, error)

func NewRenameRequest

func NewRenameRequest(baseUrl, allocation string, body io.Reader) (*http.Request, error)

func NewRevokeShareRequest

func NewRevokeShareRequest(baseUrl, allocation string, body io.Reader) (*http.Request, error)

func NewShareRequest

func NewShareRequest(baseUrl, allocation string, body io.Reader) (*http.Request, error)

func NewUploadRequest

func NewUploadRequest(baseUrl, allocation string, body io.Reader, update bool) (*http.Request, error)

func NewUploadRequestWithMethod added in v1.2.88

func NewUploadRequestWithMethod(baseURL, allocation string, body io.Reader, method string) (*http.Request, error)

NewUploadRequestWithMethod create a http reqeust of upload

func RemoteClean

func RemoteClean(path string) string

Types

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}
var Client HttpClient

type SCRestAPIHandler

type SCRestAPIHandler func(response map[string][]byte, numSharders int, err error)

type Uint128

type Uint128 struct {
	// contains filtered or unexported fields
}

func NewUint128

func NewUint128(x uint64) Uint128

func (Uint128) Add

func (x Uint128) Add(y Uint128) Uint128

Add returns x+y.

func (Uint128) Add64

func (x Uint128) Add64(y uint64) Uint128

Add64 returns x+y.

func (Uint128) And

func (x Uint128) And(v Uint128) Uint128

And returns x&y.

func (Uint128) And64

func (x Uint128) And64(y uint64) Uint128

And64 returns x&y.

func (Uint128) CountOnes

func (x Uint128) CountOnes() int

CountOnes return num of 1 bits in x.

func (Uint128) Equals

func (x Uint128) Equals(y Uint128) bool

Equals returns true if x == y.

func (Uint128) Equals64

func (x Uint128) Equals64(y uint64) bool

Equals64 returns true if x == y.

func (Uint128) Lsh

func (x Uint128) Lsh(y uint64) Uint128

Lsh returns x<<y.

func (Uint128) Not

func (x Uint128) Not() Uint128

Not returns ^x.

func (Uint128) Or

func (x Uint128) Or(v Uint128) Uint128

Or returns x|y.

func (Uint128) Sub

func (x Uint128) Sub(y Uint128) Uint128

Sub returns x-y.

func (Uint128) Sub64

func (x Uint128) Sub64(y uint64) Uint128

Sub64 returns x-y.

func (Uint128) TrailingZeros

func (x Uint128) TrailingZeros() int

TrailingZeros returns the number of trailing zero bits in x; the result is 128 for x == 0.

func (Uint128) Xor

func (x Uint128) Xor(v Uint128) Uint128

Xor returns x^y.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL