github.com/artpar/rclone@v1.67.3/backend/seafile/api/types.go (about) 1 // Package api provides types used by the Seafile API. 2 package api 3 4 // Some api objects are duplicated with only small differences, 5 // it's because the returned JSON objects are very inconsistent between api calls 6 7 // AuthenticationRequest contains user credentials 8 type AuthenticationRequest struct { 9 Username string `json:"username"` 10 Password string `json:"password"` 11 } 12 13 // AuthenticationResult is returned by a call to the authentication api 14 type AuthenticationResult struct { 15 Token string `json:"token"` 16 Errors []string `json:"non_field_errors"` 17 } 18 19 // AccountInfo contains simple user properties 20 type AccountInfo struct { 21 Usage int64 `json:"usage"` 22 Total int64 `json:"total"` 23 Email string `json:"email"` 24 Name string `json:"name"` 25 } 26 27 // ServerInfo contains server information 28 type ServerInfo struct { 29 Version string `json:"version"` 30 } 31 32 // DefaultLibrary when none specified 33 type DefaultLibrary struct { 34 ID string `json:"repo_id"` 35 Exists bool `json:"exists"` 36 } 37 38 // CreateLibraryRequest contains the information needed to create a library 39 type CreateLibraryRequest struct { 40 Name string `json:"name"` 41 Description string `json:"desc"` 42 Password string `json:"passwd"` 43 } 44 45 // Library properties. Please note not all properties are going to be useful for rclone 46 type Library struct { 47 Encrypted bool `json:"encrypted"` 48 Owner string `json:"owner"` 49 ID string `json:"id"` 50 Size int64 `json:"size"` 51 Name string `json:"name"` 52 Modified int64 `json:"mtime"` 53 } 54 55 // CreateLibrary properties. Seafile is not consistent and returns different types for different API calls 56 type CreateLibrary struct { 57 ID string `json:"repo_id"` 58 Name string `json:"repo_name"` 59 } 60 61 // FileType is either "dir" or "file" 62 type FileType string 63 64 // File types 65 var ( 66 FileTypeDir FileType = "dir" 67 FileTypeFile FileType = "file" 68 ) 69 70 // FileDetail contains file properties (for older api v2.0) 71 type FileDetail struct { 72 ID string `json:"id"` 73 Type FileType `json:"type"` 74 Name string `json:"name"` 75 Size int64 `json:"size"` 76 Parent string `json:"parent_dir"` 77 Modified string `json:"last_modified"` 78 } 79 80 // DirEntries contains a list of DirEntry 81 type DirEntries struct { 82 Entries []DirEntry `json:"dirent_list"` 83 } 84 85 // DirEntry contains a directory entry 86 type DirEntry struct { 87 ID string `json:"id"` 88 Type FileType `json:"type"` 89 Name string `json:"name"` 90 Size int64 `json:"size"` 91 Path string `json:"parent_dir"` 92 Modified int64 `json:"mtime"` 93 } 94 95 // Operation is move, copy or rename 96 type Operation string 97 98 // Operations 99 var ( 100 CopyFileOperation Operation = "copy" 101 MoveFileOperation Operation = "move" 102 RenameFileOperation Operation = "rename" 103 ) 104 105 // FileOperationRequest is sent to the api to copy, move or rename a file 106 type FileOperationRequest struct { 107 Operation Operation `json:"operation"` 108 DestinationLibraryID string `json:"dst_repo"` // For copy/move operation 109 DestinationPath string `json:"dst_dir"` // For copy/move operation 110 NewName string `json:"newname"` // Only to be used by the rename operation 111 } 112 113 // FileInfo is returned by a server file copy/move/rename (new api v2.1) 114 type FileInfo struct { 115 Type string `json:"type"` 116 LibraryID string `json:"repo_id"` 117 Path string `json:"parent_dir"` 118 Name string `json:"obj_name"` 119 ID string `json:"obj_id"` 120 Size int64 `json:"size"` 121 } 122 123 // CreateDirRequest only contain an operation field 124 type CreateDirRequest struct { 125 Operation string `json:"operation"` 126 } 127 128 // DirectoryDetail contains the directory details specific to the getDirectoryDetails call 129 type DirectoryDetail struct { 130 ID string `json:"repo_id"` 131 Name string `json:"name"` 132 Path string `json:"path"` 133 } 134 135 // ShareLinkRequest contains the information needed to create or list shared links 136 type ShareLinkRequest struct { 137 LibraryID string `json:"repo_id"` 138 Path string `json:"path"` 139 } 140 141 // SharedLink contains the information returned by a call to shared link creation 142 type SharedLink struct { 143 Link string `json:"link"` 144 IsExpired bool `json:"is_expired"` 145 } 146 147 // BatchSourceDestRequest contains JSON parameters for sending a batch copy or move operation 148 type BatchSourceDestRequest struct { 149 SrcLibraryID string `json:"src_repo_id"` 150 SrcParentDir string `json:"src_parent_dir"` 151 SrcItems []string `json:"src_dirents"` 152 DstLibraryID string `json:"dst_repo_id"` 153 DstParentDir string `json:"dst_parent_dir"` 154 }