github.com/artpar/rclone@v1.67.3/backend/sugarsync/api/types.go (about)

     1  // Package api has type definitions for sugarsync
     2  //
     3  // Converted from the API docs with help from https://www.onlinetool.io/xmltogo/
     4  package api
     5  
     6  import (
     7  	"encoding/xml"
     8  	"time"
     9  )
    10  
    11  // AppAuthorization is used to request a refresh token
    12  //
    13  // The token is returned in the Location: field
    14  type AppAuthorization struct {
    15  	XMLName          xml.Name `xml:"appAuthorization"`
    16  	Username         string   `xml:"username"`
    17  	Password         string   `xml:"password"`
    18  	Application      string   `xml:"application"`
    19  	AccessKeyID      string   `xml:"accessKeyId"`
    20  	PrivateAccessKey string   `xml:"privateAccessKey"`
    21  }
    22  
    23  // TokenAuthRequest is the request to get Authorization
    24  type TokenAuthRequest struct {
    25  	XMLName          xml.Name `xml:"tokenAuthRequest"`
    26  	AccessKeyID      string   `xml:"accessKeyId"`
    27  	PrivateAccessKey string   `xml:"privateAccessKey"`
    28  	RefreshToken     string   `xml:"refreshToken"`
    29  }
    30  
    31  // Authorization is returned from the TokenAuthRequest
    32  type Authorization struct {
    33  	XMLName    xml.Name  `xml:"authorization"`
    34  	Expiration time.Time `xml:"expiration"`
    35  	User       string    `xml:"user"`
    36  }
    37  
    38  // File represents a single file
    39  type File struct {
    40  	Name            string    `xml:"displayName"`
    41  	Ref             string    `xml:"ref"`
    42  	DsID            string    `xml:"dsid"`
    43  	TimeCreated     time.Time `xml:"timeCreated"`
    44  	Parent          string    `xml:"parent"`
    45  	Size            int64     `xml:"size"`
    46  	LastModified    time.Time `xml:"lastModified"`
    47  	MediaType       string    `xml:"mediaType"`
    48  	PresentOnServer bool      `xml:"presentOnServer"`
    49  	FileData        string    `xml:"fileData"`
    50  	Versions        string    `xml:"versions"`
    51  	PublicLink      PublicLink
    52  }
    53  
    54  // Collection represents
    55  // - Workspace Collection
    56  // - Sync Folders collection
    57  // - Folder
    58  type Collection struct {
    59  	Type        string    `xml:"type,attr"`
    60  	Name        string    `xml:"displayName"`
    61  	Ref         string    `xml:"ref"` // only for Folder
    62  	DsID        string    `xml:"dsid"`
    63  	TimeCreated time.Time `xml:"timeCreated"`
    64  	Parent      string    `xml:"parent"`
    65  	Collections string    `xml:"collections"`
    66  	Files       string    `xml:"files"`
    67  	Contents    string    `xml:"contents"`
    68  	// Sharing     bool      `xml:"sharing>enabled,attr"`
    69  }
    70  
    71  // CollectionContents is the result of a list call
    72  type CollectionContents struct {
    73  	//XMLName     xml.Name     `xml:"collectionContents"`
    74  	Start       int          `xml:"start,attr"`
    75  	HasMore     bool         `xml:"hasMore,attr"`
    76  	End         int          `xml:"end,attr"`
    77  	Collections []Collection `xml:"collection"`
    78  	Files       []File       `xml:"file"`
    79  }
    80  
    81  // User is returned from the /user call
    82  type User struct {
    83  	XMLName  xml.Name `xml:"user"`
    84  	Username string   `xml:"username"`
    85  	Nickname string   `xml:"nickname"`
    86  	Quota    struct {
    87  		Limit int64 `xml:"limit"`
    88  		Usage int64 `xml:"usage"`
    89  	} `xml:"quota"`
    90  	Workspaces            string `xml:"workspaces"`
    91  	SyncFolders           string `xml:"syncfolders"`
    92  	Deleted               string `xml:"deleted"`
    93  	MagicBriefcase        string `xml:"magicBriefcase"`
    94  	WebArchive            string `xml:"webArchive"`
    95  	MobilePhotos          string `xml:"mobilePhotos"`
    96  	Albums                string `xml:"albums"`
    97  	RecentActivities      string `xml:"recentActivities"`
    98  	ReceivedShares        string `xml:"receivedShares"`
    99  	PublicLinks           string `xml:"publicLinks"`
   100  	MaximumPublicLinkSize int    `xml:"maximumPublicLinkSize"`
   101  }
   102  
   103  // CreateFolder is posted to a folder URL to create a folder
   104  type CreateFolder struct {
   105  	XMLName xml.Name `xml:"folder"`
   106  	Name    string   `xml:"displayName"`
   107  }
   108  
   109  // MoveFolder is posted to a folder URL to move a folder
   110  type MoveFolder struct {
   111  	XMLName xml.Name `xml:"folder"`
   112  	Name    string   `xml:"displayName"`
   113  	Parent  string   `xml:"parent"`
   114  }
   115  
   116  // CreateSyncFolder is posted to the root folder URL to create a sync folder
   117  type CreateSyncFolder struct {
   118  	XMLName xml.Name `xml:"syncFolder"`
   119  	Name    string   `xml:"displayName"`
   120  }
   121  
   122  // CreateFile is posted to a folder URL to create a file
   123  type CreateFile struct {
   124  	XMLName   xml.Name `xml:"file"`
   125  	Name      string   `xml:"displayName"`
   126  	MediaType string   `xml:"mediaType"`
   127  }
   128  
   129  // MoveFile is posted to a file URL to create a file
   130  type MoveFile struct {
   131  	XMLName xml.Name `xml:"file"`
   132  	Name    string   `xml:"displayName"`
   133  	Parent  string   `xml:"parent"`
   134  }
   135  
   136  // CopyFile copies a file from source
   137  type CopyFile struct {
   138  	XMLName xml.Name `xml:"fileCopy"`
   139  	Source  string   `xml:"source,attr"`
   140  	Name    string   `xml:"displayName"`
   141  }
   142  
   143  // PublicLink is the URL and enabled flag for a public link
   144  type PublicLink struct {
   145  	XMLName xml.Name `xml:"publicLink"`
   146  	URL     string   `xml:",chardata"`
   147  	Enabled bool     `xml:"enabled,attr"`
   148  }
   149  
   150  // SetPublicLink can be used to enable the file for sharing
   151  type SetPublicLink struct {
   152  	XMLName    xml.Name `xml:"file"`
   153  	PublicLink PublicLink
   154  }
   155  
   156  // SetLastModified sets the modified time for a file
   157  type SetLastModified struct {
   158  	XMLName      xml.Name  `xml:"file"`
   159  	LastModified time.Time `xml:"lastModified"`
   160  }