box

package module
v0.0.0-...-ca5f6aa Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: MIT Imports: 16 Imported by: 0

README

GoBox

Build Status CircleCI

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoxRequest

func BoxRequest(method string, url string, body io.Reader, headers map[string]string) ([]byte, error)

BoxRequest : Runs an HTTP request to the box app.

func DeleteFile

func DeleteFile(fileID string, etag string) error

DeleteFile : Deletes a file in a specific folder with 'ID" fileID.

func DeleteFolder

func DeleteFolder(folderID string)

DeleteFolder : Deletes the folder with 'ID' folderID.

func DownloadFile

func DownloadFile(fileID string, location string) error

DownloadFile : Retrieves the actual data of the file. An optional version parameter can be set to download a previous version of the file.

func GetFileCollaborations

func GetFileCollaborations()

func GetFileComments

func GetFileComments()

func GetFileTasks

func GetFileTasks()

func GetThumbnail

func GetThumbnail(fileID string, extension string, minHeight int32, minWidth int32)

GetThumbnail : Get a thumbnail image for a file.

func LockandUnlock

func LockandUnlock(fileID string, expiresAt time.Time, preventDownload bool)

LockandUnlock : Sets a lock, which expires within a specific time.

func PreflightCheck

func PreflightCheck(name string, parentID string, size int32) bool

func RequestAccessToken

func RequestAccessToken() error

RequestAccessToken : Get valid ACCESS_TOKEN using JWT.

func SetConfigFile

func SetConfigFile(name string)

SetConfigFile : Sets the config file to read Box info from.

func UploadFileVersion

func UploadFileVersion(fileID string, newName string)

UploadFileVersion : Uploading a new file version is performed in the same way as uploading a file. This method is used to upload a new version of an existing file in a user’s account.

Types

type AccessResponse

type AccessResponse struct {
	AccessToken  string        `json:"access_token"`
	ExpiresIn    int           `json:"expires_in"`
	RestrictedTo []interface{} `json:"restricted_to"`
	TokenType    string        `json:"token_type"`
}

AccessResponse : Object returned by a successful request to the Box API.

type BoxJWTRequest

type BoxJWTRequest struct {
	BoxAppSettings struct {
		ClientID     string `json:"clientID"`
		ClientSecret string `json:"clientSecret"`
		AppAuth      struct {
			PublicKeyID string `json:"publicKeyID"`
			PrivateKey  string `json:"privateKey"`
			Passphrase  string `json:"passphrase"`
		} `json:"appAuth"`
	} `json:"boxAppSettings"`
	EnterpriseID string `json:"enterpriseID"`
}

BoxJWTRequest : Basic structure for a Box API JWT.

type EmbeddedFile

type EmbeddedFile struct {
	Type              string `json:"type"`
	ID                string `json:"id"`
	Etag              string `json:"etag"`
	ExpiringEmbedLink struct {
		URL string `json:"url"`
	} `json:"expiring_embed_link"`
}

EmbeddedFile : An HTML embeddable file.

func GetEmbedLink(fileID string) (*EmbeddedFile, error)

GetEmbedLink : Returns information about the file with 'ID' fileID.

type Entries

type Entries struct {
	EntriesMini
	Sha1              string         `json:"sha1 "`
	Description       string         `json:"description"`
	Size              int            `json:"size"`
	PathCollection    PathCollection `json:"path_collection,omitempty"`
	CreatedAt         string         `json:"created_at"`
	ModifiedAt        string         `json:"modified_at"`
	TrashedAt         interface{}    `json:"trashed_at,omitempty"`
	PurgedAt          interface{}    `json:"purged_at,omitempty"`
	ContentCreatedAt  string         `json:"content_created_at"`
	ContentModifiedAt string         `json:"content_modified_at"`
	CreatedBy         User           `json:"created_by,omitempty"`
	ModifiedBy        User           `json:"modified_by,omitempty"`
	OwnedBy           User           `json:"owned_by,omitempty"`
	SharedLink        SharedLink     `json:"shared_link,omitempty"`
	Parent            Parent         `json:"parent,omitempty"`
	ItemStatus        string         `json:"item_status"`
}

Entries : A more in-depth response containing more information about box objects.

type EntriesMini

type EntriesMini struct {
	Type       string      `json:"type"`
	ID         string      `json:"id"`
	SequenceID interface{} `json:"sequence_id,omitempty"`
	Etag       string      `json:"etag,omitempty"`
	Name       string      `json:"name"`
}

EntriesMini : Basic structure for response carrying info about box objects.

type FileObject

type FileObject struct {
	Type           string         `json:"type"`
	ID             string         `json:"id"`
	FileVersion    FileVersion    `json:"file_version"`
	SequenceID     string         `json:"sequence_id"`
	Etag           string         `json:"etag"`
	Sha1           string         `json:"sha1"`
	Name           string         `json:"name"`
	Description    string         `json:"description"`
	Size           int            `json:"size"`
	PathCollection PathCollection `json:"path_collection"`
	CreatedAt      string         `json:"created_at"`
	ModifiedAt     string         `json:"modified_at"`
	CreatedBy      User           `json:"created_by"`
	ModifiedBy     User           `json:"modified_by"`
	OwnedBy        User           `json:"owned_by"`
	SharedLink     SharedLink     `json:"shared_link"`
	Parent         Parent         `json:"parent"`
	ItemStatus     string         `json:"item_status"`
}

FileObject : File information describe file objects in Box, with attributes like who created the file, when it was last modified, and other information. The actual content of the file itself is accessible through the /files/{id}/content endpoint. Italicized attributes are not returned by default and must be retrieved through the fields parameter.

func CopyFile

func CopyFile(fileID string, folderID, version string, name string) (*FileObject, error)

CopyFile : Copy a file. The version and a new name can be optionally supplied.

func GetFileInfo

func GetFileInfo(fileID string) (*FileObject, error)

GetFileInfo : Get information about a file.

type FileVersion

type FileVersion struct {
	Type string `json:"type"`
	ID   string `json:"id"`
	Sha1 string `json:"sha1"`
}

FileVersion : Contains version information of a FileObject.

type FileVersionObject

type FileVersionObject struct {
	Type       string `json:"type"`
	ID         string `json:"id"`
	Sha1       string `json:"sha1"`
	Name       string `json:"name"`
	Size       int    `json:"size"`
	CreatedAt  string `json:"created_at"`
	ModifiedAt string `json:"modified_at"`
	ModifiedBy User
	TrashedAt  string `json:"trashed_at"`
	PurgedAt   string `json:"purged_at"`
}

type FolderObject

type FolderObject struct {
	Type              string            `json:"type"`
	ID                string            `json:"id"`
	SequenceID        string            `json:"sequence_id"`
	Etag              string            `json:"etag"`
	Name              string            `json:"name"`
	CreatedAt         string            `json:"created_at"`
	ModifiedAt        string            `json:"modified_at"`
	Description       string            `json:"description"`
	Size              int               `json:"size"`
	PathCollection    PathCollection    `json:"path_collection,omitempty"`
	CreatedBy         User              `json:"created_by,omitempty"`
	ModifiedBy        User              `json:"modified_by,omitempty"`
	OwnedBy           User              `json:"owned_by,omitempty"`
	SharedLink        SharedLink        `json:"shared_link,omitempty"`
	FolderUploadEmail FolderUploadEmail `json:"folder_upload_email,omitempty"`
	Parent            Parent            `json:"parent,omitempty"`
	ItemStatus        string            `json:"item_status"`
	ItemCollection    ItemCollection    `json:"item_collection,omitempty"`
	Tags              []string          `json:"tags"`
}

FolderObject : A Box Folder object.

func CreateFolder

func CreateFolder(name string, parentFolderID string) (*FolderObject, error)

CreateFolder : Creates a new folder under the parent folder that has 'ID' parentFolderID.

type FolderUploadEmail

type FolderUploadEmail struct {
	Access string `json:"access"`
	Email  string `json:"email"`
}

FolderUploadEmail : Access level and email address of upload folder.

type ItemCollection

type ItemCollection struct {
	TotalCount int           `json:"total_count"`
	Entries    []EntriesMini `json:"entries"`
	Offset     int           `json:"offset"`
	Limit      int           `json:"limit"`
}

ItemCollection : Total count up to the limit of the number of entries in a folder, as well as the entries themselves.

func GetFolderItems

func GetFolderItems(folderID string, limit int, offset int) (*ItemCollection, error)

GetFolderItems : Returns all the items contained inside the folder with 'ID' folderID.

type Order

type Order struct {
	By        string `json:"by"`
	Direction string `json:"direction"`
}

Order : Defines how to sort objects.

type Parent

type Parent struct {
	Type       string      `json:"type"`
	ID         string      `json:"id"`
	SequenceID interface{} `json:"sequence_id,omitempty"`
	Etag       interface{} `json:"etag,omitempty"`
	Name       string      `json:"name"`
}

Parent : Parent folder of a returned box object.

type PathCollection

type PathCollection struct {
	TotalCount int       `json:"total_count"`
	Entries    []Entries `json:"entries"`
}

PathCollection : The total amount of entries in a given path, as well as the entries themselves.

func UploadFile

func UploadFile(file interface{}, newName string, folderID string) (*PathCollection, error)

UploadFile : Use the Upload API to allow users to add a new file. The user can then upload a file by specifying the destination folder for the file. If the user provides a file name that already exists in the destination folder, the user will receive an error.

type Permissions

type Permissions struct {
	CanDownload bool `json:"can_download"`
	CanPreview  bool `json:"can_preview"`
}

Permissions : Flags for downloaded files.

type Session

type Session struct {
	// contains filtered or unexported fields
}

func (*Session) Abort

func (s *Session) Abort()

func (*Session) CommitUpload

func (s *Session) CommitUpload(partID string, offset int, size int32)

func (*Session) ListParts

func (s *Session) ListParts(offset int, limit int)

func (*Session) NewFile

func (s *Session) NewFile(folderID string, fileSize int32, fileName string)

func (*Session) NewVersion

func (s *Session) NewVersion(folderID string, fileSize int32, fileName string)

func (*Session) UploadPart

func (s *Session) UploadPart()
type SharedLink struct {
	URL               string      `json:"url"`
	DownloadURL       interface{} `json:"download_url,omitempty"`
	VanityURL         interface{} `json:"vanity_url,omitempty"`
	IsPasswordEnabled bool        `json:"is_password_enabled"`
	UnsharedAt        interface{} `json:"unshared_at,omitempty"`
	DownloadCount     int         `json:"download_count"`
	PreviewCount      int         `json:"preview_count"`
	Access            string      `json:"access"`
	Permissions       Permissions `json:"permissions,omitempty"`
}

SharedLink : A shared link to a downloadable file.

type User

type User struct {
	Type  string `json:"type"`
	ID    string `json:"id"`
	Name  string `json:"name"`
	Login string `json:"login"`
}

User : Contains information about a Box user.

Jump to

Keyboard shortcuts

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