api

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

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

Go to latest
Published: Mar 2, 2021 License: MIT Imports: 13 Imported by: 0

README

teambition-pan-api

This is a Go language package to manage your Teambition files.

This is also the basis for https://github.com/K265/rclone/tree/teambition-backend

Usage

see https://github.com/K265/teambition-pan-api/blob/main/pkg/teambition/pan/api/teambition_test.go

Features

  • cookie login

  • list/create/rename/move/delete folder

  • create/rename/move/open/delete file

Thanks

https://github.com/zxbu/webdav-teambition

License

This is free software under the terms of MIT the license (check the LICENSE file included in this package).

Documentation

Index

Constants

View Source
const AnyKind = "any"
View Source
const FileKind = "file"
View Source
const FolderKind = "folder"

Variables

View Source
var BaseUrl = "https://pan.teambition.com"

Functions

This section is empty.

Types

type CacheImpl

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

func (*CacheImpl) Clear

func (c *CacheImpl) Clear()

func (*CacheImpl) Get

func (c *CacheImpl) Get(key string) (*Node, bool)

func (*CacheImpl) Put

func (c *CacheImpl) Put(key string, node *Node)

type Config

type Config struct {
	Cookie string
}

func (Config) String

func (config Config) String() string

type Drive

type Drive struct {
	Data struct {
		DriveId string `json:"driveId"`
	} `json:"data"`
}

type FolderCache

type FolderCache interface {
	Get(string) (*Node, bool)
	Put(string, *Node)
	Clear()
}

func NewCache

func NewCache(size int) (FolderCache, error)

type Fs

type Fs interface {
	Get(ctx context.Context, path string, kind string) (*Node, error)
	GetbyNodeId(ctx context.Context, nodeId string) (*Node, error)
	GetIn(ctx context.Context, parent *Node, name string, kind string) (*Node, error)
	List(ctx context.Context, path string) ([]Node, error)
	CreateFolder(ctx context.Context, path string) (*Node, error)
	CreateFolderIn(ctx context.Context, parent *Node, name string) (*Node, error)
	Rename(ctx context.Context, node *Node, newName string) error
	Move(ctx context.Context, node *Node, parent *Node) error
	Remove(ctx context.Context, node *Node) error
	Open(ctx context.Context, node *Node, headers map[string]string) (io.ReadCloser, error)
	CreateFile(ctx context.Context, path string, size int64, in io.Reader, overwrite bool) (*Node, error)
	CreateFileIn(ctx context.Context, parent *Node, name string, size int64, in io.Reader, overwrite bool) (*Node, error)
	Delete(ctx context.Context, node *Node) error
	Copy(ctx context.Context, node *Node, parent *Node) error
}

func NewFs

func NewFs(ctx context.Context, config *Config) (Fs, error)

type Node

type Node struct {
	DownloadUrl string `json:"downloadUrl,omitempty"`
	Kind        string `json:"kind"`
	Name        string `json:"name"`
	NodeId      string `json:"nodeId"`
	ParentId    string `json:"parentId,omitempty"`
	Size        int64  `json:"size,omitempty"`
	Updated     string `json:"updated"`
}

func (*Node) GetName

func (n *Node) GetName() string

func (*Node) GetTime

func (n *Node) GetTime() (time.Time, error)

func (*Node) IsDirectory

func (n *Node) IsDirectory() bool

func (Node) String

func (n Node) String() string

type Nodes

type Nodes struct {
	Data []Node `json:"data"`
}

type Personal

type Personal struct {
	Id        string `json:"_id"`
	CreatorId string `json:"_creatorId"`
}

func (Personal) String

func (p Personal) String() string

type Space

type Space struct {
	RootId string `json:"rootId"`
}

type Teambition

type Teambition struct {
	ApiBaseUrl string
	// contains filtered or unexported fields
}

func (*Teambition) Copy

func (teambition *Teambition) Copy(ctx context.Context, node *Node, parent *Node) error

func (*Teambition) CreateFile

func (teambition *Teambition) CreateFile(ctx context.Context, path string, size int64, in io.Reader, overwrite bool) (*Node, error)

func (*Teambition) CreateFileIn

func (teambition *Teambition) CreateFileIn(ctx context.Context, parent *Node, name string, size int64, in io.Reader, overwrite bool) (*Node, error)

func (*Teambition) CreateFolder

func (teambition *Teambition) CreateFolder(ctx context.Context, path string) (*Node, error)

func (*Teambition) CreateFolderIn

func (teambition *Teambition) CreateFolderIn(ctx context.Context, parent *Node, name string) (*Node, error)

func (*Teambition) Delete

func (teambition *Teambition) Delete(ctx context.Context, node *Node) error

func (*Teambition) Get

func (teambition *Teambition) Get(ctx context.Context, path string, kind string) (*Node, error)

func (*Teambition) GetIn

func (teambition *Teambition) GetIn(ctx context.Context, parent *Node, name string, kind string) (*Node, error)

func (*Teambition) GetbyNodeId

func (teambition *Teambition) GetbyNodeId(ctx context.Context, nodeId string) (*Node, error)

func (*Teambition) List

func (teambition *Teambition) List(ctx context.Context, path string) ([]Node, error)

func (*Teambition) Move

func (teambition *Teambition) Move(ctx context.Context, node *Node, parent *Node) error

func (*Teambition) Open

func (teambition *Teambition) Open(ctx context.Context, node *Node, headers map[string]string) (io.ReadCloser, error)

func (*Teambition) Remove

func (teambition *Teambition) Remove(ctx context.Context, node *Node) error

func (*Teambition) Rename

func (teambition *Teambition) Rename(ctx context.Context, node *Node, newName string) error

func (*Teambition) String

func (teambition *Teambition) String() string

type UploadResult

type UploadResult struct {
	NodeId    string   `json:"nodeId"`
	Name      string   `json:"name"`
	UploadId  string   `json:"uploadId"`
	UploadUrl []string `json:"uploadUrl"`
}

Jump to

Keyboard shortcuts

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