Documentation ¶
Overview ¶
Package travelagent gets the suitcases to their final destination
Index ¶
- Constants
- func BindCobra(cmd *cobra.Command)
- type ErrorResponse
- type Option
- func WithClient(c *http.Client) Option
- func WithCmd(cmd *cobra.Command) Option
- func WithMetaTokenExpiration(d time.Duration) Option
- func WithPrintCurl() Option
- func WithToken(s string) Option
- func WithTokenExpiration(d time.Duration) Option
- func WithURL(s string) Option
- func WithUniquePrefix(s string) Option
- func WithUploadRetries(i int) Option
- func WithUploadRetryTime(d time.Duration) Option
- type Response
- type Status
- type StatusUpdate
- type StatusUpdateResponse
- type TravelAgent
- type TravelAgenter
Constants ¶
const ( // StatusPending has not yet started StatusPending = iota // StatusInProgress is currently running StatusInProgress // StatusComplete is completed successfully StatusComplete // StatusFailed is a falure StatusFailed )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Errors []string `json:"errors"`
}
ErrorResponse represents an error from the api
type Option ¶
type Option func() (func(*TravelAgent), error)
Option is just an option for TravelAgent
func WithMetaTokenExpiration ¶ added in v0.19.0
WithMetaTokenExpiration sets the suitcase token at create
func WithPrintCurl ¶
func WithPrintCurl() Option
WithPrintCurl prints out the curl command for each request
func WithTokenExpiration ¶ added in v0.19.0
WithTokenExpiration sets the suitcase token at create
func WithUniquePrefix ¶ added in v0.19.0
WithUniquePrefix adds a unique prefix to the uploaded path
func WithUploadRetries ¶ added in v0.19.0
WithUploadRetries sets the total retries for an upload
func WithUploadRetryTime ¶ added in v0.19.0
WithUploadRetryTime sets the time between retries
type Status ¶
type Status int
Status describes specific statuses for the updates
func (Status) MarshalJSON ¶
MarshalJSON handles converting the int to a string
type StatusUpdate ¶
type StatusUpdate struct { Status Status `json:"status,omitempty"` SizeBytes int64 `json:"size_bytes,omitempty"` Speed float64 `json:"speed,omitempty"` TransferredBytes int64 `json:"transferred_bytes,omitempty"` PercentDone int `json:"percent_done,omitempty"` Name string `json:"-"` StartedAt *time.Time `json:"started_at,omitempty"` CompletedAt *time.Time `json:"completed_at,omitempty"` MetadataCheckSum string `json:"metadata_checksum,omitempty"` Metadata string `json:"metadata,omitempty"` SuitcasectlSource string `json:"suitcasectl_source,omitempty"` SuitcasectlDestination string `json:"suitcasectl_destination,omitempty"` }
StatusUpdate is a little structure that gives our TravelAgent more info on where we are in the process
func NewStatusUpdate ¶
func NewStatusUpdate(r rclone.TransferStatus) *StatusUpdate
NewStatusUpdate returns a new status update from an rclone.TransferStatus object
type StatusUpdateResponse ¶
type StatusUpdateResponse struct {
Messages []string `json:"messages,omitempty"`
}
StatusUpdateResponse is the actual text from a response
type TravelAgent ¶
type TravelAgent struct { URL *url.URL Token string UniquePrefix string // contains filtered or unexported fields }
TravelAgent is the main object that's gonna do all this work
func New ¶
func New(options ...Option) (*TravelAgent, error)
New returns a new TravelAgent using functional options
func (TravelAgent) StatusURL ¶
func (t TravelAgent) StatusURL() string
StatusURL is just the web url for viewing this stuff
func (TravelAgent) Update ¶
func (t TravelAgent) Update(s StatusUpdate) (*StatusUpdateResponse, error)
Update updates the status of an agent
func (TravelAgent) Upload ¶ added in v0.19.0
func (t TravelAgent) Upload(fn string, c chan rclone.TransferStatus) (int64, error)
Upload sends a file off to the cloud, given the file to upload
type TravelAgenter ¶
type TravelAgenter interface { StatusURL() string Update(StatusUpdate) (*StatusUpdateResponse, error) Upload(string, chan rclone.TransferStatus) (int64, error) }
TravelAgenter is the thing that describes what a travel agent is!