api

package
v1.69.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package api has type definitions for gofile

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

Index

Constants

View Source
const (
	ItemTypeFolder = "folder"
	ItemTypeFile   = "file"
)

Types of things in Item

Variables

This section is empty.

Functions

func FromNativeTime

func FromNativeTime(t int64) time.Time

FromNativeTime converts native time to a go time

func ToNativeTime

func ToNativeTime(t time.Time) int64

ToNativeTime converts a go time to a native time

Types

type AccountsGet

type AccountsGet struct {
	Error
	Data struct {
		ID                             string `json:"id"`
		Email                          string `json:"email"`
		Tier                           string `json:"tier"`
		PremiumType                    string `json:"premiumType"`
		Token                          string `json:"token"`
		RootFolder                     string `json:"rootFolder"`
		SubscriptionProvider           string `json:"subscriptionProvider"`
		SubscriptionEndDate            int    `json:"subscriptionEndDate"`
		SubscriptionLimitDirectTraffic int64  `json:"subscriptionLimitDirectTraffic"`
		SubscriptionLimitStorage       int64  `json:"subscriptionLimitStorage"`
		StatsCurrent                   Stats  `json:"statsCurrent"`
	} `json:"data"`
}

AccountsGet is the result of /accounts/{id}

type AccountsGetID

type AccountsGetID struct {
	Error
	Data struct {
		ID string `json:"id"`
	} `json:"data"`
}

AccountsGetID is the result of /accounts/getid

type Contents

type Contents struct {
	Error
	Data struct {
		Item
	} `json:"data"`
	Metadata Metadata `json:"metadata"`
}

Contents is returned from the /contents call

type CopyRequest

type CopyRequest struct {
	FolderID   string `json:"folderId"`
	ContentsID string `json:"contentsId"` // comma separated list of IDs
}

CopyRequest is the input to /contents/copy

type CopyResponse

type CopyResponse struct {
	Error
	Data map[string]struct {
		Error
		Item `json:"data"`
	} `json:"data"`
}

CopyResponse is returned by POST /contents/copy

type CreateFolderRequest

type CreateFolderRequest struct {
	ParentFolderID string `json:"parentFolderId"`
	FolderName     string `json:"folderName"`
	ModTime        int64  `json:"modTime,omitempty"`
}

CreateFolderRequest is the input to /contents/createFolder

type CreateFolderResponse

type CreateFolderResponse struct {
	Error
	Data Item `json:"data"`
}

CreateFolderResponse is the output from /contents/createFolder

type DeleteRequest

type DeleteRequest struct {
	ContentsID string `json:"contentsId"` // comma separated list of IDs
}

DeleteRequest is the input to DELETE /contents

type DeleteResponse

type DeleteResponse struct {
	Error
	Data map[string]Error
}

DeleteResponse is the input to DELETE /contents

type DirectLink struct {
	ExpireTime       int64  `json:"expireTime"`
	SourceIpsAllowed []any  `json:"sourceIpsAllowed"`
	DomainsAllowed   []any  `json:"domainsAllowed"`
	Auth             []any  `json:"auth"`
	IsReqLink        bool   `json:"isReqLink"`
	DirectLink       string `json:"directLink"`
}

DirectLink describes a direct link to a file so it can be downloaded by third parties.

type DirectLinksRequest

type DirectLinksRequest struct {
	ExpireTime       int64 `json:"expireTime,omitempty"`
	SourceIpsAllowed []any `json:"sourceIpsAllowed,omitempty"`
	DomainsAllowed   []any `json:"domainsAllowed,omitempty"`
	Auth             []any `json:"auth,omitempty"`
}

DirectLinksRequest specifies the parameters for the direct link

type DirectLinksResult

type DirectLinksResult struct {
	Error
	Data struct {
		ExpireTime       int64  `json:"expireTime"`
		SourceIpsAllowed []any  `json:"sourceIpsAllowed"`
		DomainsAllowed   []any  `json:"domainsAllowed"`
		Auth             []any  `json:"auth"`
		IsReqLink        bool   `json:"isReqLink"`
		ID               string `json:"id"`
		DirectLink       string `json:"directLink"`
	} `json:"data"`
}

DirectLinksResult is returned from POST /contents/{id}/directlinks

type Error

type Error struct {
	Status string `json:"status"`
}

Error is returned from gofile when things go wrong

func (Error) Err

func (e Error) Err(err error) error

Err returns err if not nil, or e if IsError or nil

func (Error) Error

func (e Error) Error() string

Error returns a string for the error and satisfies the error interface

func (Error) IsError

func (e Error) IsError() bool

IsError returns true if there is an error

type Item

type Item struct {
	ID            string                 `json:"id"`
	ParentFolder  string                 `json:"parentFolder"`
	Type          string                 `json:"type"`
	Name          string                 `json:"name"`
	Size          int64                  `json:"size"`
	Code          string                 `json:"code"`
	CreateTime    int64                  `json:"createTime"`
	ModTime       int64                  `json:"modTime"`
	Link          string                 `json:"link"`
	MD5           string                 `json:"md5"`
	MimeType      string                 `json:"mimetype"`
	ChildrenCount int                    `json:"childrenCount"`
	DirectLinks   map[string]*DirectLink `json:"directLinks"`
	//Public         bool     `json:"public"`
	//ServerSelected string   `json:"serverSelected"`
	//Thumbnail      string   `json:"thumbnail"`
	//DownloadCount int      `json:"downloadCount"`
	//TotalDownloadCount int64            `json:"totalDownloadCount"`
	//TotalSize int64            `json:"totalSize"`
	//ChildrenIDs   []string               `json:"childrenIds"`
	Children map[string]*Item `json:"children"`
}

Item describes a folder or a file as returned by /contents

type Metadata

type Metadata struct {
	TotalCount  int  `json:"totalCount"`
	TotalPages  int  `json:"totalPages"`
	Page        int  `json:"page"`
	PageSize    int  `json:"pageSize"`
	HasNextPage bool `json:"hasNextPage"`
}

Metadata is returned when paging is in use

type MoveRequest

type MoveRequest struct {
	FolderID   string `json:"folderId"`
	ContentsID string `json:"contentsId"` // comma separated list of IDs
}

MoveRequest is the input to /contents/move

type MoveResponse

type MoveResponse struct {
	Error
	Data map[string]struct {
		Error
		Item `json:"data"`
	} `json:"data"`
}

MoveResponse is returned by POST /contents/move

type Server

type Server struct {
	Name string `json:"name"`
	Zone string `json:"zone"`
}

Server is an upload server

func (*Server) Root

func (s *Server) Root() string

Root returns the root URL for the server

func (*Server) String

func (s *Server) String() string

String returns a string representation of the Server

func (*Server) URL

func (s *Server) URL() string

URL returns the upload URL for the server

type ServersResponse

type ServersResponse struct {
	Error
	Data struct {
		Servers []Server `json:"servers"`
	} `json:"data"`
}

ServersResponse is the output from /servers

type Stats

type Stats struct {
	FolderCount            int64 `json:"folderCount"`
	FileCount              int64 `json:"fileCount"`
	Storage                int64 `json:"storage"`
	TrafficDirectGenerated int64 `json:"trafficDirectGenerated"`
	TrafficReqDownloaded   int64 `json:"trafficReqDownloaded"`
	TrafficWebDownloaded   int64 `json:"trafficWebDownloaded"`
}

Stats of storage and traffic

type Time

type Time time.Time

Time represents date and time information for the gofile API, by using RFC3339

func (*Time) MarshalJSON

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

MarshalJSON turns a Time into JSON (in UTC)

func (*Time) UnmarshalJSON

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

UnmarshalJSON turns JSON into a Time

type UpdateItemRequest

type UpdateItemRequest struct {
	Attribute string `json:"attribute"`
	Value     any    `json:"attributeValue"`
}

UpdateItemRequest describes the updates to be done to an item for PUT /contents/{id}/update

The Value of the attribute to define : For Attribute "name" : The name of the content (file or folder) For Attribute "description" : The description displayed on the download page (folder only) For Attribute "tags" : A comma-separated list of tags (folder only) For Attribute "public" : either true or false (folder only) For Attribute "expiry" : A unix timestamp of the expiration date (folder only) For Attribute "password" : The password to set (folder only)

type UpdateItemResponse

type UpdateItemResponse struct {
	Error
	Data Item `json:"data"`
}

UpdateItemResponse is returned by PUT /contents/{id}/update

type UploadResponse

type UploadResponse struct {
	Error
	Data Item `json:"data"`
}

UploadResponse is returned by POST /contents/uploadfile

type UploadServerStatus

type UploadServerStatus struct {
	Error
	Data struct {
		Server string `json:"server"`
		Test   string `json:"test"`
	} `json:"data"`
}

UploadServerStatus is returned when fetching the root of an upload server

Jump to

Keyboard shortcuts

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