box

package module
v0.0.0-...-851bfa9 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2021 License: MIT Imports: 20 Imported by: 0

README

GoBox

Build Status CircleCI

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PreflightCheck

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

PreflightCheck TODO: Add definition

Types

type AccessTokenObject

type AccessTokenObject struct {
	AccessToken     string `json:"access_token"`
	ExpiresIn       int    `json:"expires_in"`
	IssuedTokenType string `json:"issued_token_type,omitempty"`
	RefreshToken    string `json:"refresh_token"`
	RestrictedTo    []struct {
		Scope  string      `json:"scope,omitempty"`
		Object *FileObject `json:"object,omitempty`
	} `json:"restricted_to,omitempty"`
	TokenType string `json:"token_type,omitempty"`
}

AccessTokenObject is a token object returned by a successful request to the Box API.

type AppAuth

type AppAuth struct {
	PublicKeyID string `json:"publicKeyID"`
	PrivateKey  string `json:"privateKey"`
	Passphrase  string `json:"passphrase"`
}

AppAuth is the authentication details for the configuration.

type AppSettings

type AppSettings struct {
	ClientID     string  `json:"clientID"`
	ClientSecret string  `json:"clientSecret"`
	AppAuth      AppAuth `json:"appAuth"`
}

AppSettings is the structure of the configuration information.

type Config

type Config struct {
	BoxAppSettings AppSettings `json:"boxAppSettings"`
	EnterpriseID   string      `json:"enterpriseID"`
}

Config is the basic structure for a Box API JWT.

type EmbeddedFile

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

EmbeddedFile : An HTML embeddable file.

type Entries

type Entries struct {
	Type              string          `json:"type,omitempty"`
	ID                string          `json:"id,omitempty"`
	SequenceID        struct{}        `json:"sequence_id,omitempty"`
	Etag              string          `json:"etag,omitempty"`
	Name              string          `json:"name,omitempty"`
	Sha1              string          `json:"sha1,omitempty"`
	Description       string          `json:"description,omitempty"`
	Size              int             `json:"size,omitempty"`
	PathCollection    *PathCollection `json:"path_collection,omitempty"`
	CreatedAt         string          `json:"created_at,omitempty"`
	ModifiedAt        string          `json:"modified_at,omitempty"`
	TrashedAt         struct{}        `json:"trashed_at,omitempty"`
	PurgedAt          struct{}        `json:"purged_at,omitempty"`
	ContentCreatedAt  string          `json:"content_created_at,omitempty"`
	ContentModifiedAt string          `json:"content_modified_at,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"`
	Parent            *Parent         `json:"parent,omitempty"`
	ItemStatus        string          `json:"item_status,omitempty"`
}

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

type FileObject

type FileObject struct {
	Item
}

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.

type FileVersion

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

FileVersion : Contains version information of a FileObject.

type FolderObject

type FolderObject struct {
	Item
	ItemCollection *ItemCollection `json:"item_collection,omitempty"`
	Tags           []string        `json:"tags,omitempty"`
}

FolderObject : A Box Folder object.

type FolderUploadEmail

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

FolderUploadEmail : Access level and email address of upload folder.

type Item

type Item struct {
	Type           string          `json:"type"`
	ID             string          `json:"id"`
	FileVersion    *FileVersion    `json:"file_version,omitempty"`
	SequenceID     string          `json:"sequence_id,omitempty"`
	Etag           string          `json:"etag,omitempty"`
	Sha1           string          `json:"sha1,omitempty"`
	Name           string          `json:"name"`
	Description    string          `json:"description,omitempty"`
	Size           int             `json:"size"`
	PathCollection *PathCollection `json:"path_collection,omitempty"`
	CreatedAt      string          `json:"created_at,omitempty"`
	ModifiedAt     string          `json:"modified_at,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"`
	Parent         *Parent         `json:"parent,omitempty"`
	ItemStatus     string          `json:"item_status,omitempty"`
}

Item is the base structure of a Box object.

type ItemCollection

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

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

type Order

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

Order : Defines how to sort objects.

type Parent

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

Parent : Parent folder of a returned box object.

type PathCollection

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

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

type Permissions

type Permissions struct {
	CanDelete              bool `json:"can_delete,omitempty"`
	CanDownload            bool `json:"can_download,omitempty"`
	CanInviteCollaborator  bool `json:"can_invite_collaborator,omitempty"`
	CanRename              bool `json:"can_rename,omitempty"`
	CanSetShareAccess      bool `json:"can_set_share_access,omitempty"`
	CanShare               bool `json:"can_share,omitempty"`
	CanAnnotate            bool `json:"can_annotate,omitempty"`
	CanComment             bool `json:"can_comment,omitempty"`
	CanPreview             bool `json:"can_preview,omitempty"`
	CanUpload              bool `json:"can_upload,omitempty"`
	CanViewAnnotationsAll  bool `json:"can_view_annotations_all,omitempty"`
	CanViewAnnotationsSelf bool `json:"can_view_annotations_self,omitempty"`
}

Permissions : Flags for downloaded files.

type SDK

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

SDK is the structure for establishing the connection to the Box API.

func (*SDK) CopyFile

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

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

func (*SDK) CopyFolder

func (sdk *SDK) CopyFolder(folderID string, parentFolderID string, newName string) (*FolderObject, error)

CopyFolder copies a speified folder to a specified parent folder.

func (*SDK) CreateFolder

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

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

func (*SDK) DeleteFile

func (sdk *SDK) DeleteFile(fileID, etag string) error

DeleteFile deletes a file in a specific folder with an 'ID' matching fileID.

func (*SDK) DeleteFolder

func (sdk *SDK) DeleteFolder(folderID string)

DeleteFolder deletes the folder who's 'ID' matches folderID.

func (*SDK) DownloadFile

func (sdk *SDK) DownloadFile(fileID, 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 (sdk *SDK) GetEmbedLink(fileID string) (*EmbeddedFile, error)

GetEmbedLink returns information about the file with 'ID' fileID.

func (*SDK) GetFileInfo

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

GetFileInfo : Get information about a file.

func (*SDK) GetFolderInfo

func (sdk *SDK) GetFolderInfo(folderID string) (*FolderObject, error)

GetFolderInfo gets the information for the requested folder ID

func (*SDK) GetThumbnail

func (sdk *SDK) GetThumbnail(fileID, extension string, minHeight, minWidth int) (image.Image, error)

GetThumbnail gets a thumbnail image for the requested file.

func (*SDK) ListItemsInFolder

func (sdk *SDK) ListItemsInFolder(folderID string, limit int, offset int) (*ItemCollection, error)

ListItemsInFolder returns all the items contained inside the folder with 'ID' folderID.

func (*SDK) NewConfig

func (sdk *SDK) NewConfig(cfg *Config)

NewConfig sets the configuration for the SDK to establish it's connection.

func (*SDK) NewConfigFromFile

func (sdk *SDK) NewConfigFromFile(filename string) error

NewConfigFromFile sets the config file to read Box info from.

func (*SDK) RequestAccessToken

func (sdk *SDK) RequestAccessToken() error

RequestAccessToken requests a valid access token from the Box API.

func (*SDK) UpdateFile

func (sdk *SDK) UpdateFile(fileID, newFilename string) error

UpdateFile updates the file with a new name and content.

func (*SDK) UpdateFolder

func (sdk *SDK) UpdateFolder()

UpdateFolder updates a folder object.

func (*SDK) UploadFile

func (sdk *SDK) UploadFile(inFile interface{}, newFilename, folderID string) (*PathCollection, error)

UploadFile uses 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.

func (*SDK) UploadFileVersion

func (sdk *SDK) UploadFileVersion(fileID, 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.

type Session

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

Session TODO: Add definition

func (*Session) Abort

func (s *Session) Abort()

Abort TODO: Add definition

func (*Session) CommitUpload

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

CommitUpload TODO: Add definition

func (*Session) ListParts

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

ListParts TODO: Add definition

func (*Session) NewFile

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

NewFile TODO: Add definition

func (*Session) NewVersion

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

NewVersion TODO: Add definition

func (*Session) UploadPart

func (s *Session) UploadPart()

UploadPart TODO: Add definition

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

SharedLink : A shared link to a downloadable file.

type User

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

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