github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/backend/seafile/api/types.go (about)

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