api

package
v1.50.21 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BinContentType    = "application/x-www-form-urlencoded"
	TreeIDLength      = 12
	DunnoNodeIDLength = 16
)

BIN protocol constants

View Source
const (
	OperationAddFile           = 103 // 0x67
	OperationRename            = 105 // 0x69
	OperationCreateFolder      = 106 // 0x6A
	OperationFolderList        = 117 // 0x75
	OperationSharedFoldersList = 121 // 0x79
	// TODO investigate opcodes below
	Operation154MaybeItemInfo = 154 // 0x9A
	Operation102MaybeAbout    = 102 // 0x66
	Operation104MaybeDelete   = 104 // 0x68
)

Operations in binary protocol

View Source
const (
	MkdirResultOK                  = 0
	MkdirResultSourceNotExists     = 1
	MkdirResultAlreadyExists       = 4
	MkdirResultExistsDifferentCase = 9
	MkdirResultInvalidName         = 10
	MkdirResultFailed254           = 254
)

CreateDir protocol constants

View Source
const (
	MoveResultOK              = 0
	MoveResultSourceNotExists = 1
	MoveResultFailed002       = 2
	MoveResultAlreadyExists   = 4
	MoveResultFailed005       = 5
	MoveResultFailed254       = 254
)

Move result codes

View Source
const (
	AddResultOK          = 0
	AddResultError01     = 1
	AddResultDunno04     = 4
	AddResultWrongPath   = 5
	AddResultNoFreeSpace = 7
	AddResultDunno09     = 9
	AddResultInvalidName = 10
	AddResultNotModified = 12
	AddResultFailedA     = 253
	AddResultFailedB     = 254
)

AddFile result codes

View Source
const (
	ListOptTotalSpace  = 1
	ListOptDelete      = 2
	ListOptFingerprint = 4
	ListOptUnknown8    = 8
	ListOptUnknown16   = 16
	ListOptFolderSize  = 32
	ListOptUsedSpace   = 64
	ListOptUnknown128  = 128
	ListOptUnknown256  = 256
)

List request options

View Source
const (
	ListParseDone      = 0
	ListParseReadItem  = 1
	ListParsePin       = 2
	ListParsePinUpper  = 3
	ListParseUnknown15 = 15
)

List parse flags

View Source
const (
	ListResultOK              = 0
	ListResultNotExists       = 1
	ListResultDunno02         = 2
	ListResultDunno03         = 3
	ListResultAlreadyExists04 = 4
	ListResultDunno05         = 5
	ListResultDunno06         = 6
	ListResultDunno07         = 7
	ListResultDunno08         = 8
	ListResultAlreadyExists09 = 9
	ListResultDunno10         = 10
	ListResultDunno11         = 11
	ListResultDunno12         = 12
	ListResultFailedB         = 253
	ListResultFailedA         = 254
)

List operation results

View Source
const (
	ListItemMountPoint   = 0
	ListItemFile         = 1
	ListItemFolder       = 2
	ListItemSharedFolder = 3
)

Directory item types

View Source
const (
	APIServerURL      = "https://cloud.mail.ru"
	PublicLinkURL     = "https://cloud.mail.ru/public/"
	DispatchServerURL = "https://dispatcher.cloud.mail.ru"
	OAuthURL          = "https://o2.mail.ru/token"
	OAuthClientID     = "cloud-win"
)

M1 protocol constants and structures

ListOptDefaults ...

Variables

View Source
var (
	ErrorPrematureEOF  = errors.New("Premature EOF")
	ErrorInvalidLength = errors.New("Invalid length")
	ErrorZeroTerminate = errors.New("String must end with zero")
)

protocol errors

Functions

This section is empty.

Types

type BinReader

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

BinReader is a binary protocol reader helper

func NewBinReader

func NewBinReader(reader io.Reader) *BinReader

NewBinReader creates a binary protocol reader helper

func (*BinReader) Count

func (r *BinReader) Count() uint64

Count returns number of bytes read

func (*BinReader) Error

func (r *BinReader) Error() error

Error returns first encountered error or nil

func (*BinReader) ReadByteAsInt

func (r *BinReader) ReadByteAsInt() int

ReadByteAsInt reads a single byte as uint32, returns -1 for EOF or errors

func (*BinReader) ReadByteAsShort

func (r *BinReader) ReadByteAsShort() int16

ReadByteAsShort reads a single byte as uint16, returns -1 for EOF or errors

func (*BinReader) ReadBytesByLength

func (r *BinReader) ReadBytesByLength() []byte

ReadBytesByLength reads buffer length and its bytes

func (*BinReader) ReadDate

func (r *BinReader) ReadDate() time.Time

ReadDate reads a Unix encoded time

func (*BinReader) ReadIntSpl

func (r *BinReader) ReadIntSpl() int

ReadIntSpl reads two bytes as little-endian uint16, returns -1 for EOF or errors

func (*BinReader) ReadNBytes

func (r *BinReader) ReadNBytes(len int) []byte

ReadNBytes reads given number of bytes, returns invalid data for EOF or errors

func (*BinReader) ReadPu32

func (r *BinReader) ReadPu32() int64

ReadPu32 returns -1 for EOF or errors

func (*BinReader) ReadString

func (r *BinReader) ReadString() string

ReadString reads a zero-terminated string with length

func (*BinReader) ReadULong

func (r *BinReader) ReadULong() uint64

ReadULong returns uint64 equivalent of -1 for EOF or errors

type BinWriter

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

BinWriter is a binary protocol writer

func NewBinWriter

func NewBinWriter() *BinWriter

NewBinWriter creates a binary protocol helper

func (*BinWriter) Bytes

func (w *BinWriter) Bytes() []byte

Bytes returns binary data

func (*BinWriter) Reader

func (w *BinWriter) Reader() io.Reader

Reader returns io.Reader with binary data

func (*BinWriter) Write

func (w *BinWriter) Write(buf []byte)

Write writes a byte buffer

func (*BinWriter) WritePu16

func (w *BinWriter) WritePu16(val int)

WritePu16 writes a short as unsigned varint

func (*BinWriter) WritePu32

func (w *BinWriter) WritePu32(val int64)

WritePu32 writes a signed long as unsigned varint

func (*BinWriter) WritePu64

func (w *BinWriter) WritePu64(val int64)

WritePu64 writes an unsigned (actually, signed) long as unsigned varint

func (*BinWriter) WriteString

func (w *BinWriter) WriteString(str string)

WriteString writes a zero-terminated string

func (*BinWriter) WriteWithLength

func (w *BinWriter) WriteWithLength(buf []byte)

WriteWithLength writes a byte buffer prepended with its length as varint

type CleanupResponse

type CleanupResponse struct {
	Email     string `json:"email"`
	Time      int64  `json:"time"`
	StatusStr string `json:"status"`
}

CleanupResponse ...

type FileErrorResponse

type FileErrorResponse struct {
	Body struct {
		Home struct {
			Value string `json:"value"`
			Error string `json:"error"`
		} `json:"home"`
	} `json:"body"`
	Status  int    `json:"status"`
	Account string `json:"email,omitempty"`
	Time    int64  `json:"time,omitempty"`
	Message string // non-json, calculated field
}

FileErrorResponse represents erroneous API response for a file

func (*FileErrorResponse) Error

func (e *FileErrorResponse) Error() string

type FolderInfoResponse

type FolderInfoResponse struct {
	Body struct {
		Count struct {
			Folders int `json:"folders"`
			Files   int `json:"files"`
		} `json:"count"`
		Tree string `json:"tree"`
		Name string `json:"name"`
		Grev int    `json:"grev"`
		Size int64  `json:"size"`
		Sort struct {
			Order string `json:"order"`
			Type  string `json:"type"`
		} `json:"sort"`
		Kind string     `json:"kind"`
		Rev  int        `json:"rev"`
		Type string     `json:"type"`
		Home string     `json:"home"`
		List []ListItem `json:"list"`
	} `json:"body,omitempty"`
	Time   int64  `json:"time"`
	Status int    `json:"status"`
	Email  string `json:"email"`
}

FolderInfoResponse ...

type GenericBodyResponse

type GenericBodyResponse struct {
	Email  string `json:"email"`
	Body   string `json:"body"`
	Time   int64  `json:"time"`
	Status int    `json:"status"`
}

GenericBodyResponse ...

type GenericResponse

type GenericResponse struct {
	Email  string `json:"email"`
	Time   int64  `json:"time"`
	Status int    `json:"status"`
}

GenericResponse ...

type ItemInfoResponse

type ItemInfoResponse struct {
	Email  string   `json:"email"`
	Body   ListItem `json:"body"`
	Time   int64    `json:"time"`
	Status int      `json:"status"`
}

ItemInfoResponse ...

type ListItem

type ListItem struct {
	Count struct {
		Folders int `json:"folders"`
		Files   int `json:"files"`
	} `json:"count,omitempty"`
	Kind      string `json:"kind"`
	Type      string `json:"type"`
	Name      string `json:"name"`
	Home      string `json:"home"`
	Size      int64  `json:"size"`
	Mtime     int64  `json:"mtime,omitempty"`
	Hash      string `json:"hash,omitempty"`
	VirusScan string `json:"virus_scan,omitempty"`
	Tree      string `json:"tree,omitempty"`
	Grev      int    `json:"grev,omitempty"`
	Rev       int    `json:"rev,omitempty"`
}

ListItem ...

type ServerErrorResponse

type ServerErrorResponse struct {
	Message string `json:"body"`
	Time    int64  `json:"time"`
	Status  int    `json:"status"`
}

ServerErrorResponse represents erroneous API response.

func (*ServerErrorResponse) Error

func (e *ServerErrorResponse) Error() string

type ShardInfoResponse

type ShardInfoResponse struct {
	Email string `json:"email"`
	Body  struct {
		Video []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"video"`
		ViewDirect []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"view_direct"`
		WeblinkView []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"weblink_view"`
		WeblinkVideo []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"weblink_video"`
		WeblinkGet []struct {
			Count int    `json:"count"`
			URL   string `json:"url"`
		} `json:"weblink_get"`
		Stock []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"stock"`
		WeblinkThumbnails []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"weblink_thumbnails"`
		PublicUpload []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"public_upload"`
		Auth []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"auth"`
		Web []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"web"`
		View []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"view"`
		Upload []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"upload"`
		Get []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"get"`
		Thumbnails []struct {
			Count string `json:"count"`
			URL   string `json:"url"`
		} `json:"thumbnails"`
	} `json:"body"`
	Time   int64 `json:"time"`
	Status int   `json:"status"`
}

ShardInfoResponse ...

type UserInfoResponse

type UserInfoResponse struct {
	Body struct {
		AccountType     string `json:"account_type"`
		AccountVerified bool   `json:"account_verified"`
		Cloud           struct {
			Beta struct {
				Allowed bool `json:"allowed"`
				Asked   bool `json:"asked"`
			} `json:"beta"`
			Billing struct {
				ActiveCostID string `json:"active_cost_id"`
				ActiveRateID string `json:"active_rate_id"`
				AutoProlong  bool   `json:"auto_prolong"`
				Basequota    int64  `json:"basequota"`
				Enabled      bool   `json:"enabled"`
				Expires      int    `json:"expires"`
				Prolong      bool   `json:"prolong"`
				Promocodes   struct {
				} `json:"promocodes"`
				Subscription []interface{} `json:"subscription"`
				Version      string        `json:"version"`
			} `json:"billing"`
			Bonuses struct {
				CameraUpload bool `json:"camera_upload"`
				Complete     bool `json:"complete"`
				Desktop      bool `json:"desktop"`
				Feedback     bool `json:"feedback"`
				Links        bool `json:"links"`
				Mobile       bool `json:"mobile"`
				Registration bool `json:"registration"`
			} `json:"bonuses"`
			Enable struct {
				Sharing bool `json:"sharing"`
			} `json:"enable"`
			FileSizeLimit int64 `json:"file_size_limit"`
			Space         struct {
				BytesTotal int64 `json:"bytes_total"`
				BytesUsed  int   `json:"bytes_used"`
				Overquota  bool  `json:"overquota"`
			} `json:"space"`
		} `json:"cloud"`
		Cloudflags struct {
			Exists bool `json:"exists"`
		} `json:"cloudflags"`
		Domain string `json:"domain"`
		Login  string `json:"login"`
		Newbie bool   `json:"newbie"`
		UI     struct {
			ExpandLoader bool   `json:"expand_loader"`
			Kind         string `json:"kind"`
			Sidebar      bool   `json:"sidebar"`
			Sort         struct {
				Order string `json:"order"`
				Type  string `json:"type"`
			} `json:"sort"`
			Thumbs bool `json:"thumbs"`
		} `json:"ui"`
	} `json:"body"`
	Email  string `json:"email"`
	Status int    `json:"status"`
	Time   int64  `json:"time"`
}

UserInfoResponse contains account metadata

Jump to

Keyboard shortcuts

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