1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
package mega
import "encoding/json"
type PreloginMsg struct {
Cmd string `json:"a"`
User string `json:"user"`
}
type PreloginResp struct {
Version int `json:"v"`
Salt string `json:"s"`
}
type LoginMsg struct {
Cmd string `json:"a"`
User string `json:"user"`
Handle string `json:"uh"`
SessionKey string `json:"sek,omitempty"`
Si string `json:"si,omitempty"`
Mfa string `json:"mfa,omitempty"`
}
type LoginResp struct {
Csid string `json:"csid"`
Privk string `json:"privk"`
Key string `json:"k"`
Ach int `json:"ach"`
SessionKey string `json:"sek"`
U string `json:"u"`
}
type UserMsg struct {
Cmd string `json:"a"`
}
type UserResp struct {
U string `json:"u"`
S int `json:"s"`
Email string `json:"email"`
Name string `json:"name"`
Key string `json:"k"`
C int `json:"c"`
Pubk string `json:"pubk"`
Privk string `json:"privk"`
Terms string `json:"terms"`
TS string `json:"ts"`
}
type QuotaMsg struct {
// Action, should be "uq" for quota request
Cmd string `json:"a"`
// xfer should be 1
Xfer int `json:"xfer"`
// Without strg=1 only reports total capacity for account
Strg int `json:"strg,omitempty"`
}
type QuotaResp struct {
// Mstrg is total capacity in bytes
Mstrg uint64 `json:"mstrg"`
// Cstrg is used capacity in bytes
Cstrg uint64 `json:"cstrg"`
// Per folder usage in bytes?
Cstrgn map[string][]int64 `json:"cstrgn"`
}
type FilesMsg struct {
Cmd string `json:"a"`
C int `json:"c"`
}
type FSNode struct {
Hash string `json:"h"`
Parent string `json:"p"`
User string `json:"u"`
T int `json:"t"`
Attr string `json:"a"`
Key string `json:"k"`
Ts int64 `json:"ts"`
SUser string `json:"su"`
SKey string `json:"sk"`
Sz int64 `json:"s"`
}
type FilesResp struct {
F []FSNode `json:"f"`
Ok []struct {
Hash string `json:"h"`
Key string `json:"k"`
} `json:"ok"`
S []struct {
Hash string `json:"h"`
User string `json:"u"`
} `json:"s"`
User []struct {
User string `json:"u"`
C int `json:"c"`
Email string `json:"m"`
} `json:"u"`
Sn string `json:"sn"`
}
type FileAttr struct {
Name string `json:"n"`
}
type GetLinkMsg struct {
Cmd string `json:"a"`
N string `json:"n"`
}
type DownloadMsg struct {
Cmd string `json:"a"`
G int `json:"g"`
P string `json:"p,omitempty"`
N string `json:"n,omitempty"`
SSL int `json:"ssl,omitempty"`
}
type DownloadResp struct {
G string `json:"g"`
Size uint64 `json:"s"`
Attr string `json:"at"`
Err ErrorMsg `json:"e"`
}
type UploadMsg struct {
Cmd string `json:"a"`
S int64 `json:"s"`
SSL int `json:"ssl,omitempty"`
}
type UploadResp struct {
P string `json:"p"`
}
type UploadCompleteMsg struct {
Cmd string `json:"a"`
T string `json:"t"`
N [1]struct {
H string `json:"h"`
T int `json:"t"`
A string `json:"a"`
K string `json:"k"`
} `json:"n"`
I string `json:"i,omitempty"`
}
type UploadCompleteResp struct {
F []FSNode `json:"f"`
}
type FileInfoMsg struct {
Cmd string `json:"a"`
F int `json:"f"`
P string `json:"p"`
}
type MoveFileMsg struct {
Cmd string `json:"a"`
N string `json:"n"`
T string `json:"t"`
I string `json:"i"`
}
type FileAttrMsg struct {
Cmd string `json:"a"`
Attr string `json:"attr"`
Key string `json:"key"`
N string `json:"n"`
I string `json:"i"`
}
type FileDeleteMsg struct {
Cmd string `json:"a"`
N string `json:"n"`
I string `json:"i"`
}
// GenericEvent is a generic event for parsing the Cmd type before
// decoding more specifically
type GenericEvent struct {
Cmd string `json:"a"`
}
// FSEvent - event for various file system events
//
// Delete (a=d)
// Update attr (a=u)
// New nodes (a=t)
type FSEvent struct {
Cmd string `json:"a"`
T struct {
Files []FSNode `json:"f"`
} `json:"t"`
Owner string `json:"ou"`
N string `json:"n"`
User string `json:"u"`
Attr string `json:"at"`
Key string `json:"k"`
Ts int64 `json:"ts"`
I string `json:"i"`
}
// Events is received from a poll of the server to read the events
//
// Each event can be an error message or a different field so we delay
// decoding
type Events struct {
W string `json:"w"`
Sn string `json:"sn"`
E []json.RawMessage `json:"a"`
}
|