sdk

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UploadSessionFileSizeLimit int = 4 * 1000 * 1000 // 4 MB
	UploadSessionMultiple      int = 320 * 1024      // 320 KB
	UploadSessionRangeSize     int = UploadSessionMultiple * 10
)
View Source
var (
	GraphURL = "https://graph.microsoft.com/v1.0/"
)

Functions

func IsHTTPStatusOK added in v0.4.1

func IsHTTPStatusOK(status int) bool

func UnmarshalJSON

func UnmarshalJSON(o interface{}, body []byte) error

Types

type Client

type Client struct {
	Config                  *Config
	Verbose                 bool
	UseTransferSignals      bool
	ChannelTransferStart    chan fs.FileInfo
	ChannelTransferProgress chan int64
	ChannelTransferFinish   chan bool
}

func CreateClient

func CreateClient(conf *Config) *Client

func (*Client) CreateDir

func (client *Client) CreateDir(path string) error

func (*Client) Delete

func (client *Client) Delete(path string) error

func (*Client) Download

func (client *Client) Download(sourceFilePath, targetFolder string) error

func (*Client) GetLoginURL

func (client *Client) GetLoginURL() string

func (*Client) Info added in v0.4.0

func (client *Client) Info(path string) (*DriveItem, error)

func (*Client) List

func (client *Client) List(path string) ([]*DriveItem, error)

func (*Client) Login

func (client *Client) Login() error

func (*Client) RenewAccessToken

func (client *Client) RenewAccessToken() (*LoginRedeemCodeResponse, error)

func (*Client) ResetChannels added in v0.5.0

func (client *Client) ResetChannels()

func (*Client) ShouldRenewAccessToken

func (client *Client) ShouldRenewAccessToken() bool

func (*Client) UpdateSecretStore

func (client *Client) UpdateSecretStore(grant *LoginRedeemCodeResponse) error

func (*Client) Upload

func (client *Client) Upload(localFilePath, targetFolder string) error

type Config

type Config struct {
	ConfigFilePath string    `json:"-"`
	ClientID       string    `json:"client_id"`
	ClientSecret   string    `json:"client_secret"`
	Scopes         []string  `json:"scopes"`
	RedirectURL    string    `json:"redirect_uri"`
	Root           string    `json:"root"`
	AccessToken    string    `json:"access_token"`
	RefreshToken   string    `json:"refresh_token"`
	Expiry         time.Time `json:"expiry"`
	SecretStore    string    `json:"secret_store,omitempty"`
}

func ReadConfig

func ReadConfig(filename string) (*Config, error)

func ReadConfigData added in v0.4.3

func ReadConfigData(data []byte) (*Config, error)

func (*Config) Write added in v0.6.0

func (config *Config) Write() error

type CreateFolderRequest

type CreateFolderRequest struct {
	Name             string           `json:"name"`
	Folder           FolderProperties `json:"folder"`
	ConflictBehavior string           `json:"@microsoft.graph.conflictBehavior"`
}

type DownloadFileStat added in v0.5.0

type DownloadFileStat struct {
	FileName  string
	SizeBytes int64
}

func (*DownloadFileStat) IsDir added in v0.5.0

func (s *DownloadFileStat) IsDir() bool

func (*DownloadFileStat) ModTime added in v0.5.0

func (s *DownloadFileStat) ModTime() time.Time

func (*DownloadFileStat) Mode added in v0.5.0

func (s *DownloadFileStat) Mode() fs.FileMode

func (*DownloadFileStat) Name added in v0.5.0

func (s *DownloadFileStat) Name() string

func (*DownloadFileStat) Size added in v0.5.0

func (s *DownloadFileStat) Size() int64

func (*DownloadFileStat) Sys added in v0.5.0

func (s *DownloadFileStat) Sys() any

type DriveItem

type DriveItem struct {
	Name           string         `json:"name"`
	SizeBytes      int64          `json:"size"`
	File           FileItem       `json:"file"`
	Folder         FolderItem     `json:"folder"`
	FileSystemInfo FileSystemInfo `json:"fileSystemInfo"`
	Type           DriveItemType
}

type DriveItemType added in v0.4.6

type DriveItemType int
const (
	DriveItemTypeFile   DriveItemType = 1
	DriveItemTypeFolder DriveItemType = 2
)

type EmptyStruct

type EmptyStruct struct{}

type ErrorResponse added in v0.4.5

type ErrorResponse struct {
	Error ErrorType `json:"error"`
}

type ErrorType added in v0.4.5

type ErrorType struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type FileHashes added in v0.4.0

type FileHashes struct {
	QuickXOR string `json:"quickXorHash"`
	SHA1     string `json:"sha1Hash"`
	SHA256   string `json:"sha256Hash"`
}

type FileItem

type FileItem struct {
	MimeType string     `json:"mimeType"`
	Hashes   FileHashes `json:"hashes"`
}

type FileSystemInfo added in v0.4.0

type FileSystemInfo struct {
	Created      time.Time `json:"createdDateTime"`
	LastModified time.Time `json:"lastModifiedDateTime"`
}

type FolderItem

type FolderItem struct {
	ChildCount int `json:"childCount"`
}

type FolderProperties

type FolderProperties struct {
}

type HTTPRequestParams

type HTTPRequestParams map[string]string

type ListResponse

type ListResponse struct {
	Items    []DriveItem `json:"value"`
	NextLink string      `json:"@odata.nextLink"`
}

type LoginRedeemCodeResponse

type LoginRedeemCodeResponse struct {
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	Scope        string `json:"scope"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

type ProgressReader added in v0.5.0

type ProgressReader struct {
	Reader         io.Reader
	OnReadProgress func(r int64)
}

func (*ProgressReader) Close added in v0.5.0

func (r *ProgressReader) Close() error

func (*ProgressReader) Len added in v0.5.0

func (r *ProgressReader) Len() int

func (*ProgressReader) Read added in v0.5.0

func (r *ProgressReader) Read(b []byte) (n int, err error)

type UploadSessionResponse

type UploadSessionResponse struct {
	UploadURL string    `json:"uploadUrl"`
	Expiry    time.Time `json:"expirationDateTime"`
}

Jump to

Keyboard shortcuts

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