-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.go
144 lines (116 loc) · 3.2 KB
/
types.go
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
package dropboxclient
import (
"io"
"time"
"github.com/koofr/go-httpclient"
)
const SpaceAllocationIndividual = "individual"
const SpaceAllocationTeam = "team"
type SpaceAllocation struct {
Tag string `json:".tag"`
Used int64 `json:"used"`
Allocated int64 `json:"allocated"`
}
type SpaceUsage struct {
Used int64 `json:"used"`
Allocation *SpaceAllocation `json:"allocation"`
}
const MetadataFile = "file"
const MetadataFolder = "folder"
const MetadataDeleted = "deleted"
type Metadata struct {
Tag string `json:".tag"`
Name string `json:"name"`
PathLower string `json:"path_lower"`
ClientModified time.Time `json:"client_modified"`
ServerModified time.Time `json:"server_modified"`
Rev string `json:"rev"`
Size int64 `json:"size"`
Id string `json:"id"`
ETag string
ContentLength int64
}
type GetMetadataArg struct {
Path string `json:"path"`
IncludeMediaInfo bool `json:"include_media_info"`
}
type ListFolderArg struct {
Path string `json:"path"`
Recursive bool `json:"recursive"`
IncludeMediaInfo bool `json:"include_media_info"`
IncludeDeleted bool `json:"include_deleted"`
}
type ListFolderResult struct {
Entries []*Metadata `json:"entries"`
Cursor string `json:"cursor"`
HasMore bool `json:"has_more"`
}
type ListFolderContinueArg struct {
Cursor string `json:"cursor"`
}
type DownloadArg struct {
Path string `json:"path"`
}
type CreateFolderArg struct {
Path string `json:"path"`
}
type DeleteArg struct {
Path string `json:"path"`
}
type RelocationArg struct {
FromPath string `json:"from_path"`
ToPath string `json:"to_path"`
}
type UploadSessionStartResult struct {
SessionId string `json:"session_id"`
}
type UploadSessionCursor struct {
SessionId string `json:"session_id"`
Offset int64 `json:"offset"`
}
const WriteModeAdd = "add"
const WriteModeOverwrite = "overwrite"
const WriteModeUpdate = "update"
type WriteMode struct {
Tag string `json:".tag"`
Update string `json:"update,omitempty"`
}
type CommitInfo struct {
Path string `json:"path"`
Mode *WriteMode `json:"mode"`
Autorename bool `json:"autorename"`
ClientModified *string `json:"client_modified,omitempty"`
Mute bool `json:"mute"`
}
type UploadSessionFinishArg struct {
Cursor *UploadSessionCursor `json:"cursor"`
Commit *CommitInfo `json:"commit"`
}
type DownloadV1 struct {
ContentLength int64
ETag string
Reader io.ReadCloser
}
type DropboxErrorDetails struct {
Tag string `json:".tag"`
Path *LookupError `json:"path"`
PathLookup *LookupError `json:"path_lookup"`
}
type LookupError struct {
Tag string `json:".tag"`
}
type DropboxError struct {
ErrorSummary string `json:"error_summary"`
Err DropboxErrorDetails `json:"error"`
HttpClientError *httpclient.InvalidStatusError
}
func (e *DropboxError) Error() string {
return e.ErrorSummary
}
func IsDropboxError(err error) (dropboxErr *DropboxError, ok bool) {
if dbe, ok := err.(*DropboxError); ok {
return dbe, true
} else {
return nil, false
}
}