Help us shape the future of Go! Take the 2026 Go Developer Survey

api

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package api has type definitions for filefabric

Converted from the API responses with help from https://mholt.github.io/json-to-go/

Index

Constants

This section is empty.

Variables

View Source
var ItemFields = mustFields(Item{})

ItemFields is a | separated list of fields in Item

Functions

This section is empty.

Types

type ApplianceInfo

type ApplianceInfo struct {
	Status
	Sitetitle            string `json:"sitetitle"`
	OauthLoginSupport    string `json:"oauthloginsupport"`
	IsAppliance          string `json:"isappliance"`
	SoftwareVersion      string `json:"softwareversion"`
	SoftwareVersionLabel string `json:"softwareversionlabel"`
}

ApplianceInfo is the response to getApplianceInfo

type BtData

type BtData struct {
	Callback string `json:"callback"`
}

BtData is part of TasksResponse

type CustomPermissions

type CustomPermissions struct {
	Upload            string `json:"upload"`
	CreateSubFolder   string `json:"createsubfolder"`
	Rename            string `json:"rename"`
	Delete            string `json:"delete"`
	Move              string `json:"move"`
	ManagePermissions string `json:"managepermissions"`
	ListOnly          string `json:"listonly"`
	VisibleInTrash    string `json:"visibleintrash"`
}

CustomPermissions is returned as part of GetFolderContentsResponse

type DeleteResponse

type DeleteResponse struct {
	Status
	Deleted        []string      `json:"deleted"`
	Errors         []interface{} `json:"errors"`
	ID             string        `json:"fi_id"`
	BackgroundTask int           `json:"backgroundtask"`
	UsSize         string        `json:"us_size"`
	PaSize         string        `json:"pa_size"`
}

DeleteResponse is returned from doDeleteFile

type DoCompleteUploadResponse

type DoCompleteUploadResponse struct {
	Status
	UploadedSize int64  `json:"uploadedsize,string"`
	StorageIP    string `json:"storageip"`
	UploadedName string `json:"uploadedname"`
	// Versioned    []interface{} `json:"versioned"`
	// VersionedID  int           `json:"versionedid"`
	// Comment      interface{}           `json:"comment"`
	File Item `json:"file"`
}

DoCompleteUploadResponse is the response to doCompleteUpload

type DoCreateNewFolderResponse

type DoCreateNewFolderResponse struct {
	Status
	Item Item `json:"file"`
}

DoCreateNewFolderResponse is response from foCreateNewFolder

type DoInitUploadResponse

type DoInitUploadResponse struct {
	Status
	ProviderID          string `json:"providerid"`
	UploadCode          string `json:"uploadcode"`
	FileType            string `json:"filetype"`
	DirectUploadSupport string `json:"directuploadsupport"`
	ResumeAllowed       string `json:"resumeallowed"`
}

DoInitUploadResponse is response from doInitUpload

type EmptyResponse

type EmptyResponse struct {
	Status
}

EmptyResponse is response which just returns the error condition

type FileResponse

type FileResponse struct {
	Status
	Item   Item   `json:"file"`
	Exists string `json:"exists"`
}

FileResponse is returned from doRenameFile

type GetFolderContentsResponse

type GetFolderContentsResponse struct {
	Status
	Total  int    `json:"total,string"`
	Items  []Item `json:"filelist"`
	Folder Item   `json:"folder"`
	From   Int    `json:"from"`
	//Count         int    `json:"count"`
	Pid           string `json:"pid"`
	RefreshResult Status `json:"refreshresult"`
	// Curfolder         Item              `json:"curfolder"` - sometimes returned as "ROOT"?
	Parents           []Item            `json:"parents"`
	CustomPermissions CustomPermissions `json:"custompermissions"`
}

GetFolderContentsResponse is returned from getFolderContents

type GetTokenByAuthTokenResponse

type GetTokenByAuthTokenResponse struct {
	Status
	Token              string `json:"token"`
	UserID             string `json:"userid"`
	AllowLoginRemember string `json:"allowloginremember"`
	LastLogin          Time   `json:"lastlogin"`
	AutoLoginCode      string `json:"autologincode"`
}

GetTokenByAuthTokenResponse is the response to getTokenByAuthToken

type Int

type Int int

Int represents an integer which can be represented in JSON as a quoted integer or an integer.

func (*Int) MarshalJSON

func (i *Int) MarshalJSON() (out []byte, err error)

MarshalJSON turns a Int into JSON

func (*Int) UnmarshalJSON

func (i *Int) UnmarshalJSON(data []byte) error

UnmarshalJSON turns JSON into a Int

type Item

type Item struct {
	ID  string `json:"fi_id"`
	PID string `json:"fi_pid"`
	// UID             string   `json:"fi_uid"`
	Name string `json:"fi_name"`
	// S3Name          string   `json:"fi_s3name"`
	// Extension       string   `json:"fi_extension"`
	// Description     string   `json:"fi_description"`
	Type ItemType `json:"fi_type,string"`
	// Created         Time     `json:"fi_created"`
	Size        int64  `json:"fi_size,string"`
	ContentType string `json:"fi_contenttype"`
	// Tags            string   `json:"fi_tags"`
	// MainCode        string   `json:"fi_maincode"`
	// Public          int      `json:"fi_public,string"`
	// Provider        string   `json:"fi_provider"`
	// ProviderFolder  string   `json:"fi_providerfolder"` // folder
	// Encrypted       int      `json:"fi_encrypted,string"`
	// StructType      string   `json:"fi_structtype"`
	// Bname           string   `json:"fi_bname"` // folder
	// OrgID           string   `json:"fi_orgid"`
	// Favorite        int      `json:"fi_favorite,string"`
	// IspartOf        string   `json:"fi_ispartof"` // folder
	Modified Time `json:"fi_modified"`
	// LastAccessed    Time     `json:"fi_lastaccessed"`
	// Hits            int64    `json:"fi_hits,string"`
	// IP              string   `json:"fi_ip"` // folder
	// BigDescription  string   `json:"fi_bigdescription"`
	LocalTime Time `json:"fi_localtime"`
	// OrgfolderID     string   `json:"fi_orgfolderid"`
	// StorageIP       string   `json:"fi_storageip"` // folder
	// RemoteTime      Time     `json:"fi_remotetime"`
	// ProviderOptions string   `json:"fi_provideroptions"`
	// Access          string   `json:"fi_access"`
	// Hidden          string   `json:"fi_hidden"` // folder
	// VersionOf       string   `json:"fi_versionof"`
	Trash bool `json:"trash"`
	// Isbucket        string   `json:"isbucket"` // filelist
	SubFolders int64 `json:"subfolders"` // folder
}

Item ia a File or a Folder

type ItemType

type ItemType uint8

ItemType determine whether it is a file or a folder

const (
	ItemTypeFile   ItemType = 0
	ItemTypeFolder ItemType = 1
)

Types of things in Item

type MoveFilesResponse

type MoveFilesResponse struct {
	Status
	Filesleft         string   `json:"filesleft"`
	Addedtobackground string   `json:"addedtobackground"`
	Moved             string   `json:"moved"`
	Item              Item     `json:"file"`
	IDs               []string `json:"fi_ids"`
	Length            int      `json:"length"`
	DirID             string   `json:"dir_id"`
	MovedObjects      []Item   `json:"movedobjects"`
}

MoveFilesResponse is returned from doMoveFiles

type OKError

type OKError interface {
	error
	OK() bool
	GetCode() string
}

OKError defines an interface for items which can be OK or be an error

type Providers

type Providers struct {
	Max     string `json:"max"`
	Used    string `json:"used"`
	ID      string `json:"id"`
	Private string `json:"private"`
	Limit   string `json:"limit"`
	Percent int    `json:"percent"`
}

Providers is returned as part of UploadResponse

type SpaceInfo

type SpaceInfo struct {
	Response UploadResponse `json:"response"`
	Status   string         `json:"status"`
}

SpaceInfo is returned as part of DoCompleteUploadResponse

type Status

type Status struct {
	Code    string `json:"status"`
	Message string `json:"statusmessage"`
	TaskID  String `json:"taskid"`
}

Status return returned in all status responses

func (*Status) Error

func (e *Status) Error() string

Status satisfies the error interface

func (*Status) GetCode

func (e *Status) GetCode() string

GetCode returns the status code if any

func (*Status) OK

func (e *Status) OK() bool

OK returns true if the status is all good

type String

type String string

String represents an string which can be represented in JSON as a quoted string or an integer.

func (*String) MarshalJSON

func (s *String) MarshalJSON() (out []byte, err error)

MarshalJSON turns a String into JSON

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(data []byte) error

UnmarshalJSON turns JSON into a String

type Task

type Task struct {
	BtID             string `json:"bt_id"`
	UsID             string `json:"us_id"`
	BtType           string `json:"bt_type"`
	BtData           BtData `json:"bt_data"`
	BtStatustext     string `json:"bt_statustext"`
	BtStatusdata     string `json:"bt_statusdata"`
	BtMessage        string `json:"bt_message"`
	BtProcent        string `json:"bt_procent"`
	BtAdded          string `json:"bt_added"`
	BtStatus         string `json:"bt_status"`
	BtCompleted      string `json:"bt_completed"`
	BtTitle          string `json:"bt_title"`
	BtCredentials    string `json:"bt_credentials"`
	BtHidden         string `json:"bt_hidden"`
	BtAutoremove     string `json:"bt_autoremove"`
	BtDevsite        string `json:"bt_devsite"`
	BtPriority       string `json:"bt_priority"`
	BtReport         string `json:"bt_report"`
	BtSitemarker     string `json:"bt_sitemarker"`
	BtExecuteafter   string `json:"bt_executeafter"`
	BtCompletestatus string `json:"bt_completestatus"`
	BtSubtype        string `json:"bt_subtype"`
	BtCanceled       string `json:"bt_canceled"`
	Callback         string `json:"callback"`
	CanBeCanceled    bool   `json:"canbecanceled"`
	CanBeRestarted   bool   `json:"canberestarted"`
	Type             string `json:"type"`
	Status           string `json:"status"`
	Settings         string `json:"settings"`
}

Task describes a task returned in TasksResponse

type TasksResponse

type TasksResponse struct {
	Status
	Tasks []Task `json:"tasks"`
	Total string `json:"total"`
}

TasksResponse is the response to getUserBackgroundTasks

type Time

type Time time.Time

Time represents date and time information for the filefabric API

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() (out []byte, err error)

MarshalJSON turns a Time into JSON (in UTC)

func (Time) String

func (t Time) String() string

String turns a Time into a string in UTC suitable for the API parameters

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON turns JSON into a Time (in UTC)

type Total

type Total struct {
	Max        string `json:"max"`
	Used       string `json:"used"`
	ID         string `json:"id"`
	Priused    string `json:"priused"`
	Primax     string `json:"primax"`
	Limit      string `json:"limit"`
	Percent    int    `json:"percent"`
	Pripercent int    `json:"pripercent"`
}

Total is returned as part of UploadResponse

type UploadResponse

type UploadResponse struct {
	Providers []Providers `json:"providers"`
	Total     Total       `json:"total"`
}

UploadResponse is returned as part of SpaceInfo

type UploadStatus

type UploadStatus struct {
	Status
	UploadCode     string `json:"uploadcode"`
	Metafile       string `json:"metafile"`
	Percent        int    `json:"percent,string"`
	Uploaded       int64  `json:"uploaded,string"`
	Size           int64  `json:"size,string"`
	Filename       string `json:"filename"`
	Nofile         string `json:"nofile"`
	Completed      string `json:"completed"`
	Completsuccess string `json:"completsuccess"`
	Completerror   string `json:"completerror"`
}

UploadStatus is returned from getUploadStatus

type UploaderResponse

type UploaderResponse struct {
	FileSize int64  `xml:"filesize" json:"filesize,string"`
	MD5      string `xml:"md5" json:"md5"`
	Success  string `xml:"success" json:"success"`
}

UploaderResponse is returned from /cgi-bin/uploader/uploader1.cgi

Sometimes the response is returned as XML and sometimes as JSON

Jump to

Keyboard shortcuts

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