github.com/artpar/rclone@v1.67.3/backend/mailru/api/m1.go (about) 1 // Package api provides types used by the Mail.ru API. 2 package api 3 4 import ( 5 "fmt" 6 ) 7 8 // M1 protocol constants and structures 9 const ( 10 APIServerURL = "https://cloud.mail.ru" 11 PublicLinkURL = "https://cloud.mail.ru/public/" 12 DispatchServerURL = "https://dispatcher.cloud.mail.ru" 13 OAuthURL = "https://o2.mail.ru/token" 14 OAuthClientID = "cloud-win" 15 ) 16 17 // ServerErrorResponse represents erroneous API response. 18 type ServerErrorResponse struct { 19 Message string `json:"body"` 20 Time int64 `json:"time"` 21 Status int `json:"status"` 22 } 23 24 func (e *ServerErrorResponse) Error() string { 25 return fmt.Sprintf("server error %d (%s)", e.Status, e.Message) 26 } 27 28 // FileErrorResponse represents erroneous API response for a file 29 type FileErrorResponse struct { 30 Body struct { 31 Home struct { 32 Value string `json:"value"` 33 Error string `json:"error"` 34 } `json:"home"` 35 } `json:"body"` 36 Status int `json:"status"` 37 Account string `json:"email,omitempty"` 38 Time int64 `json:"time,omitempty"` 39 Message string // non-json, calculated field 40 } 41 42 func (e *FileErrorResponse) Error() string { 43 return fmt.Sprintf("file error %d (%s)", e.Status, e.Body.Home.Error) 44 } 45 46 // UserInfoResponse contains account metadata 47 type UserInfoResponse struct { 48 Body struct { 49 AccountType string `json:"account_type"` 50 AccountVerified bool `json:"account_verified"` 51 Cloud struct { 52 Beta struct { 53 Allowed bool `json:"allowed"` 54 Asked bool `json:"asked"` 55 } `json:"beta"` 56 Billing struct { 57 ActiveCostID string `json:"active_cost_id"` 58 ActiveRateID string `json:"active_rate_id"` 59 AutoProlong bool `json:"auto_prolong"` 60 Basequota int64 `json:"basequota"` 61 Enabled bool `json:"enabled"` 62 Expires int64 `json:"expires"` 63 Prolong bool `json:"prolong"` 64 Promocodes struct { 65 } `json:"promocodes"` 66 Subscription []interface{} `json:"subscription"` 67 Version string `json:"version"` 68 } `json:"billing"` 69 Bonuses struct { 70 CameraUpload bool `json:"camera_upload"` 71 Complete bool `json:"complete"` 72 Desktop bool `json:"desktop"` 73 Feedback bool `json:"feedback"` 74 Links bool `json:"links"` 75 Mobile bool `json:"mobile"` 76 Registration bool `json:"registration"` 77 } `json:"bonuses"` 78 Enable struct { 79 Sharing bool `json:"sharing"` 80 } `json:"enable"` 81 FileSizeLimit int64 `json:"file_size_limit"` 82 Space struct { 83 BytesTotal int64 `json:"bytes_total"` 84 BytesUsed int64 `json:"bytes_used"` 85 Overquota bool `json:"overquota"` 86 } `json:"space"` 87 } `json:"cloud"` 88 Cloudflags struct { 89 Exists bool `json:"exists"` 90 } `json:"cloudflags"` 91 Domain string `json:"domain"` 92 Login string `json:"login"` 93 Newbie bool `json:"newbie"` 94 UI struct { 95 ExpandLoader bool `json:"expand_loader"` 96 Kind string `json:"kind"` 97 Sidebar bool `json:"sidebar"` 98 Sort struct { 99 Order string `json:"order"` 100 Type string `json:"type"` 101 } `json:"sort"` 102 Thumbs bool `json:"thumbs"` 103 } `json:"ui"` 104 } `json:"body"` 105 Email string `json:"email"` 106 Status int `json:"status"` 107 Time int64 `json:"time"` 108 } 109 110 // ListItem ... 111 type ListItem struct { 112 Count struct { 113 Folders int `json:"folders"` 114 Files int `json:"files"` 115 } `json:"count,omitempty"` 116 Kind string `json:"kind"` 117 Type string `json:"type"` 118 Name string `json:"name"` 119 Home string `json:"home"` 120 Size int64 `json:"size"` 121 Mtime uint64 `json:"mtime,omitempty"` 122 Hash string `json:"hash,omitempty"` 123 VirusScan string `json:"virus_scan,omitempty"` 124 Tree string `json:"tree,omitempty"` 125 Grev int `json:"grev,omitempty"` 126 Rev int `json:"rev,omitempty"` 127 } 128 129 // ItemInfoResponse ... 130 type ItemInfoResponse struct { 131 Email string `json:"email"` 132 Body ListItem `json:"body"` 133 Time int64 `json:"time"` 134 Status int `json:"status"` 135 } 136 137 // FolderInfoResponse ... 138 type FolderInfoResponse struct { 139 Body struct { 140 Count struct { 141 Folders int `json:"folders"` 142 Files int `json:"files"` 143 } `json:"count"` 144 Tree string `json:"tree"` 145 Name string `json:"name"` 146 Grev int `json:"grev"` 147 Size int64 `json:"size"` 148 Sort struct { 149 Order string `json:"order"` 150 Type string `json:"type"` 151 } `json:"sort"` 152 Kind string `json:"kind"` 153 Rev int `json:"rev"` 154 Type string `json:"type"` 155 Home string `json:"home"` 156 List []ListItem `json:"list"` 157 } `json:"body,omitempty"` 158 Time int64 `json:"time"` 159 Status int `json:"status"` 160 Email string `json:"email"` 161 } 162 163 // CleanupResponse ... 164 type CleanupResponse struct { 165 Email string `json:"email"` 166 Time int64 `json:"time"` 167 StatusStr string `json:"status"` 168 } 169 170 // GenericResponse ... 171 type GenericResponse struct { 172 Email string `json:"email"` 173 Time int64 `json:"time"` 174 Status int `json:"status"` 175 // ignore other fields 176 } 177 178 // GenericBodyResponse ... 179 type GenericBodyResponse struct { 180 Email string `json:"email"` 181 Body string `json:"body"` 182 Time int64 `json:"time"` 183 Status int `json:"status"` 184 }