Documentation
¶
Overview ¶
Package api has type definitions and code related to API-calls for the HiDrive-API.
Index ¶
- Constants
- Variables
- type DirectoryContent
- type Error
- type HiDriveObject
- type QueryParameters
- func (p *QueryParameters) AddFields(prefix string, fields ...string)
- func (p *QueryParameters) AddList(key string, separator string, values ...string)
- func (p *QueryParameters) SetFileInDirectory(filePath string)
- func (p *QueryParameters) SetPath(objectPath string)
- func (p *QueryParameters) SetTime(key string, value time.Time) error
- type Time
Constants ¶
const ( HiDriveObjectTypeDirectory = "dir" HiDriveObjectTypeFile = "file" HiDriveObjectTypeSymlink = "symlink" )
possible types for HiDriveObject
Variables ¶
var ( HiDriveObjectNoMetadataFields = []string{"name", "type"} HiDriveObjectWithMetadataFields = append(HiDriveObjectNoMetadataFields, "id", "size", "mtime", "chash") HiDriveObjectWithDirectoryMetadataFields = append(HiDriveObjectWithMetadataFields, "nmembers") DirectoryContentFields = []string{"nmembers"} )
Some presets for different amounts of information that can be requested for fields; it is recommended to only request the information that is actually needed.
Functions ¶
This section is empty.
Types ¶
type DirectoryContent ¶
type DirectoryContent struct { TotalCount int64 `json:"nmembers"` Entries []HiDriveObject `json:"members"` }
DirectoryContent describes the content of a directory.
func (*DirectoryContent) UnmarshalJSON ¶
func (d *DirectoryContent) UnmarshalJSON(data []byte) error
UnmarshalJSON turns JSON into DirectoryContent and introduces specific default-values where necessary.
type Error ¶
type Error struct { Code json.Number `json:"code"` ContextInfo json.RawMessage Message string `json:"msg"` }
Error is returned from the API when things go wrong.
type HiDriveObject ¶
type HiDriveObject struct { Type string `json:"type"` ID string `json:"id"` ParentID string `json:"parent_id"` Name string `json:"name"` Path string `json:"path"` Size int64 `json:"size"` MemberCount int64 `json:"nmembers"` ModifiedAt Time `json:"mtime"` ChangedAt Time `json:"ctime"` MetaHash string `json:"mhash"` MetaOnlyHash string `json:"mohash"` NameHash string `json:"nhash"` ContentHash string `json:"chash"` IsTeamfolder bool `json:"teamfolder"` Readable bool `json:"readable"` Writable bool `json:"writable"` MIMEType string `json:"mime_type"` }
HiDriveObject describes a folder, a symlink or a file. Depending on the type and content, not all fields are present.
func (*HiDriveObject) ModTime ¶
func (i *HiDriveObject) ModTime() time.Time
ModTime returns the modification time of the HiDriveObject.
func (*HiDriveObject) UnmarshalJSON ¶
func (i *HiDriveObject) UnmarshalJSON(data []byte) error
UnmarshalJSON turns JSON into HiDriveObject and introduces specific default-values where necessary.
type QueryParameters ¶
QueryParameters represents the parameters passed to an API-call.
func NewQueryParameters ¶
func NewQueryParameters() *QueryParameters
NewQueryParameters initializes an instance of QueryParameters and returns a pointer to it.
func (*QueryParameters) AddFields ¶
func (p *QueryParameters) AddFields(prefix string, fields ...string)
AddFields sets the appropriate parameter to access the given fields. The given fields will be appended to any other existing fields.
func (*QueryParameters) AddList ¶
func (p *QueryParameters) AddList(key string, separator string, values ...string)
AddList adds the given values as a list with each value separated by the separator. It appends to any existing values associated with key.
func (*QueryParameters) SetFileInDirectory ¶
func (p *QueryParameters) SetFileInDirectory(filePath string)
SetFileInDirectory sets the appropriate parameters to specify a path to a file in a directory. This is used by requests that work with paths for files that do not exist yet. (For example when creating a file). Most requests use the format produced by SetPath(...).
func (*QueryParameters) SetPath ¶
func (p *QueryParameters) SetPath(objectPath string)
SetPath sets the appropriate parameters to access the given path.
type Time ¶
Time represents date and time information for the API.
func (*Time) MarshalJSON ¶
MarshalJSON turns Time into JSON (in Unix-time/UTC).
func (*Time) UnmarshalJSON ¶
UnmarshalJSON turns JSON into Time.