ephcli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAPIRequestTimeout = 5 * time.Second
View Source
const (
	DefaultBarWidth = 50
)

Variables

View Source
var (
	ErrInvalidToken = errors.New("invalid token")
	Now             func() time.Time // for testing purposes
)
View Source
var (
	ErrFileNotFound = errors.New("file not found")
)

Functions

func CheckExpiration

func CheckExpiration(token string) (expired bool, err error)

func Whoami

func Whoami(token string) (email string, expirationTime time.Time, err error)

Types

type APIError

type APIError struct {
	Err     bool   `json:"error"`
	Message string `json:"msg"`
}

APIError is the error response from the API

type Box

type Box struct {
	CapacityMb  int64 `json:"capacity_mb"`
	UsedMb      int64 `json:"used_mb"`
	RemainingMb int64 `json:"remaining_mb"`
}

type ClientEphemeralfiles

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

ClientEphemeralfiles is the client to interact with the API

func NewClient

func NewClient(token string) *ClientEphemeralfiles

NewClient creates a new client

func (*ClientEphemeralfiles) DisableProgressBar

func (c *ClientEphemeralfiles) DisableProgressBar()

func (*ClientEphemeralfiles) Download

func (c *ClientEphemeralfiles) Download(uuidFile string, outputfile string) error

Download downloads a file from the server and saves it to the outputfile If the outputfile is empty, the file will be saved to the current directory with the same name as the file on the server (retrieving the name from the Content-Disposition header)

func (*ClientEphemeralfiles) DownloadEndpoint

func (c *ClientEphemeralfiles) DownloadEndpoint(uuidFile string) string

func (*ClientEphemeralfiles) Fetch

func (c *ClientEphemeralfiles) Fetch() (FileList, error)

Fetch retrieves the list of files from the server

func (*ClientEphemeralfiles) FilesEndpoint

func (c *ClientEphemeralfiles) FilesEndpoint() string

FilesEndpoint returns the endpoint for the files

func (*ClientEphemeralfiles) GetBoxInfos

func (c *ClientEphemeralfiles) GetBoxInfos() (*Box, error)

func (*ClientEphemeralfiles) Remove

func (c *ClientEphemeralfiles) Remove(uuidFileToRemove string) error

Download downloads a file from the server and saves it to the outputfile If the outputfile is empty, the file will be saved to the current directory with the same name as the file on the server (retrieving the name from the Content-Disposition header)

func (*ClientEphemeralfiles) SetEndpoint

func (c *ClientEphemeralfiles) SetEndpoint(endpoint string)

func (*ClientEphemeralfiles) SetHTTPClient

func (c *ClientEphemeralfiles) SetHTTPClient(client *http.Client)

func (*ClientEphemeralfiles) Upload

func (c *ClientEphemeralfiles) Upload(fileToUpload string) error

func (*ClientEphemeralfiles) UploadEndpoint

func (c *ClientEphemeralfiles) UploadEndpoint() string

func (*ClientEphemeralfiles) UploadWithProgressBar

func (c *ClientEphemeralfiles) UploadWithProgressBar(fileToUpload string) error

func (*ClientEphemeralfiles) UploadWithoutProgressBar

func (c *ClientEphemeralfiles) UploadWithoutProgressBar(fileToUpload string) error

type File

type File struct {
	Idfile          string    `json:"idfile"`
	FileName        string    `json:"filename"`
	Size            int64     `json:"size"`
	UpdateDateBegin time.Time `json:"update_date_egin"`
	UpdateDateEnd   time.Time `json:"update_date_end"`
	ExpirationDate  time.Time `json:"expiration_date"`
}

File is the struct that represents a file in the API

type FileList

type FileList []File

FileList is a list of files

func (*FileList) Print

func (fl *FileList) Print() error

Print prints the list of files as a table

func (*FileList) PrintCSV

func (fl *FileList) PrintCSV() error

PrintCSV prints the list of files as a CSV

func (*FileList) PrintJSON

func (fl *FileList) PrintJSON() error

PrintJSON prints the list of files as JSON

func (*FileList) PrintYAML

func (fl *FileList) PrintYAML() error

PrintYAML prints the list of files as YAML

Jump to

Keyboard shortcuts

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