drive

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// DefaultListLimit is the default value for the limit lists.
	DefaultListLimit = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FilesRequest

type FilesRequest struct {
	Limit    uint        `json:"limit"`
	SinceID  string      `json:"sinceId"`
	UntilID  string      `json:"untilId"`
	FolderID core.String `json:"folderId"`
	Type     core.String `json:"type"`
}

FilesRequest gets a list of files available in drive.

func (FilesRequest) Validate

func (r FilesRequest) Validate() error

Validate the request.

type FoldersRequest

type FoldersRequest struct {
	Limit    uint        `json:"limit"`
	SinceID  string      `json:"sinceId"`
	UntilID  string      `json:"untilId"`
	FolderID core.String `json:"folderId"`
}

FoldersRequest gets a list of folders available in drive.

func (FoldersRequest) Validate

func (r FoldersRequest) Validate() error

Validate the request.

type InformationRequest

type InformationRequest struct{}

InformationRequest is a pseudo type to get information about drive. No payload, but that way requests stay consistent.

func (InformationRequest) Validate

func (r InformationRequest) Validate() error

Validate the request.

type InformationResponse

type InformationResponse struct {
	Capacity core.DataSize `json:"capacity"`
	Usage    core.DataSize `json:"usage"`
}

InformationResponse is the representation of the /drive/files request.

type Service

type Service struct {
	Call core.RequestHandlerFunc
}

Service is the base for all the endpoints on this service.

func NewService

func NewService(requestHandler core.RequestHandlerFunc) *Service

NewService creates a new Service instance.

func (*Service) File

func (s *Service) File() *files.Service

File contains all endpoints under /drive/files.

func (*Service) Files

func (s *Service) Files(request FilesRequest) ([]models.File, error)

Files lists all files in drive.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))

fileList, err := client.Drive().Files(drive.FilesRequest{
	Limit: drive.DefaultListLimit,
})
if err != nil {
	log.Printf("[Drive/Files] %s", err)

	return
}

log.Printf("[Drive/Files] Number of files: %d", len(fileList))
Output:

func (*Service) Folder

func (s *Service) Folder() *folders.Service

Folder contains all endpoints under /drive/folders.

func (*Service) Folders

func (s *Service) Folders(request FoldersRequest) ([]models.Folder, error)

Folders lists all folders in drive.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))

folderList, err := client.Drive().Folders(drive.FoldersRequest{
	Limit: drive.DefaultListLimit,
})
if err != nil {
	log.Printf("[Drive/Folders] %s", err)

	return
}

log.Printf("[Drive/Folders] Number of files: %d", len(folderList))
Output:

func (*Service) Information

func (s *Service) Information() (InformationResponse, error)

Information gets drive information.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))

info, err := client.Drive().Information()
if err != nil {
	log.Printf("[Drive/Information] %s", err)

	return
}

log.Printf("[Drive/Information] Capacity: %.2f", info.Capacity.Gigabytes())
Output:

func (*Service) Stream

func (s *Service) Stream(request StreamRequest) ([]models.File, error)

Stream lists all folders in drive.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))

fileList, err := client.Drive().Stream(drive.StreamRequest{
	Limit: drive.DefaultListLimit,
})
if err != nil {
	log.Printf("[Drive/Stream] %s", err)

	return
}

log.Printf("[Drive/Stream] Number of files: %d", len(fileList))
Output:

type StreamRequest

type StreamRequest struct {
	Limit   uint   `json:"limit"`
	SinceID string `json:"sinceId"`
	UntilID string `json:"untilId"`
	Type    string `json:"type"`
}

StreamRequest gets a list of files available in drive as a flat list, all files are included and no filter on folder.

func (StreamRequest) Validate

func (r StreamRequest) Validate() error

Validate the request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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