ephcli

package
v0.1.0-beta9 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 {
	HttpClient *http.Client
	// contains filtered or unexported fields
}

ClientEphemeralfiles is the client to interact with the API

func NewClient

func NewClient(endpoint string, token string) *ClientEphemeralfiles

NewClient creates a new client

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)

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) Upload

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

func (*ClientEphemeralfiles) UploadEndpoint

func (c *ClientEphemeralfiles) UploadEndpoint() string

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

func (*FileList) PrintCSV

func (fl *FileList) PrintCSV() error

func (*FileList) PrintJSON

func (fl *FileList) PrintJSON() error

func (*FileList) PrintYAML

func (fl *FileList) PrintYAML() error

Jump to

Keyboard shortcuts

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