folders

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: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOptions

type CreateOptions struct {
	Name     string
	ParentID core.String
}

CreateOptions are the possible parameters for a Create request.

type CreateRequest

type CreateRequest struct {
	Name     string      `json:"name"`
	ParentID core.String `json:"parentId"`
}

CreateRequest is the request to create a folder.

func (CreateRequest) Validate

func (r CreateRequest) Validate() error

Validate the request.

type DeleteRequest

type DeleteRequest struct {
	FolderID string `json:"folderId"`
}

DeleteRequest is the request to delete a folder.

func (DeleteRequest) Validate

func (r DeleteRequest) Validate() error

Validate the request.

type FindRequest

type FindRequest struct {
	Name     string      `json:"name"`
	ParentID core.String `json:"parentId"`
}

FindRequest is the request to find folder(s) by their and parent folder.

func (FindRequest) Validate

func (r FindRequest) Validate() error

Validate the request.

type Service

type Service struct {
	Call core.RequestHandlerFunc
}

Service is the service for all the endpoints under /drive/folders/*.

func NewService

func NewService(requestHandler core.RequestHandlerFunc) *Service

NewService creates a new Service instance.

func (*Service) Create

func (s *Service) Create(request CreateRequest) (models.Folder, error)

Create a folder.

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

folder, err := client.Drive().Folder().Create(folders.CreateRequest{
	Name: "Test with Go library",
})
if err != nil {
	log.Printf("[Drive/Folder/Create] %s", err)

	return
}

log.Printf(
	"[Drive/Folder/Create] '%s' folder created. (%s)",
	folder.Name,
	folder.ID,
)
Output:

func (*Service) Delete

func (s *Service) Delete(folderID string) error

Delete folder.

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

err := client.Drive().Folder().Delete("8dmwq3bhtw")
if err != nil {
	log.Printf("[Drive/Folder/Delete] %s", err)

	return
}
Output:

func (*Service) Find

func (s *Service) Find(request FindRequest) ([]models.Folder, error)

Find gets folder(s) by their name and parent folder.

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

folderList, err := client.Drive().Folder().Find(folders.FindRequest{
	Name: "Board Games",
})
if err != nil {
	log.Printf("[Drive/Folder/Find] %s", err)

	return
}

for _, folder := range folderList {
	log.Printf(
		"[Drive/Folder/Find] <%s> %s -> %s",
		folder.CreatedAt,
		folder.ID,
		folder.Name,
	)
}
Output:

func (*Service) Show

func (s *Service) Show(folderID string) (models.Folder, error)

Show gets a folder by its ID.

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

folder, err := client.Drive().Folder().Show("8dmwisynnu")
if err != nil {
	log.Printf("[Drive/Folder/Show] %s", err)

	return
}

log.Printf(
	"[Drive/Folder/Show] <%s> %s (%d files and %d folders)",
	folder.CreatedAt,
	folder.Name,
	folder.FilesCount,
	folder.FoldersCount,
)
Output:

func (*Service) Update

func (s *Service) Update(folder models.Folder) (models.Folder, error)

Update a folder.

The request uses only the ID, Name and ParentID values.

Warning: both Name and ParentID will be updated, so if you want to change only the name, fill in the ParentID with its current value, if you leave it as null, it will be moved to the root of the drive.

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

folder, err := client.Drive().Folder().Show("8dmwisynnu")
if err != nil {
	log.Printf("[Drive/Folder/Update] %s", err)

	return
}

folder.Name = "New Name"

folder, err = client.Drive().Folder().Update(folder)
if err != nil {
	log.Printf("[Drive/Folder/Update] %s", err)

	return
}
Output:

type ShowRequest

type ShowRequest struct {
	FolderID string `json:"folderId"`
}

ShowRequest is the request to show a folder.

func (ShowRequest) Validate

func (r ShowRequest) Validate() error

Validate the request.

type UpdateRequest

type UpdateRequest struct {
	FolderID string      `json:"folderId"`
	Name     string      `json:"name"`
	ParentID core.String `json:"parentId"`
}

UpdateRequest is the request object for an Update request.

func (UpdateRequest) Validate

func (r UpdateRequest) Validate() error

Validate the request.

Jump to

Keyboard shortcuts

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