-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption.go
279 lines (226 loc) · 6.11 KB
/
option.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
package cloudinary
import (
"encoding/json"
)
type ResourceType string
type Options struct {
//AccessControl interface{} `json:"access_control,omitempty"`
AccessMode *string `json:"access_mode,omitempty"`
AllowedFormats *string `json:"allowed_formats,omitempty"`
Async *bool `json:"async,omitempty"`
AutoTagging *float64 `json:"auto_tagging,omitempty"`
BackgroundRemoval *string `json:"background_removal,omitempty"`
Backup *bool `json:"backup,omitempty"`
Callback *string `json:"callback,omitempty"`
Categorization *string `json:"categorization,omitempty"`
Colors *bool `json:"colors,omitempty"`
Context *string `json:"context,omitempty"`
CustomCoordinates *string `json:"custom_coordinates,omitempty"`
Detection *string `json:"detection,omitempty"`
DiscardOriginalFilename *bool `json:"discard_original_filename,omitempty"`
Eager *string `json:"eager,omitempty"`
EagerAsync *bool `json:"eager_async,omitempty"`
EagerNotificationURL *string `json:"eager_notification_url,omitempty"`
Exif *bool `json:"exif,omitempty"`
FaceCoordinates *string `json:"face_coordinates,omitempty"`
Faces *bool `json:"faces,omitempty"`
Folder *string `json:"folder,omitempty"`
Format *string `json:"format,omitempty"`
Headers *string `json:"headers,omitempty"`
ImageMetadata *bool `json:"image_metadata,omitempty"`
Invalidate *bool `json:"invalidate,omitempty"`
KeepOriginal *bool `json:"keep_original,omitempty"`
Moderation *string `json:"moderation,omitempty"`
NextCursor *string `json:"next_cursor,omitempty"`
NotificationURL *string `json:"notification_url,omitempty"`
OCR *string `json:"ocr,omitempty"`
Overwrite *bool `json:"overwrite,omitempty"`
Phash *bool `json:"phash,omitempty"`
Proxy *string `json:"proxy,omitempty"`
PublicId *string `json:"public_id,omitempty"`
QualityAnalysis *bool `json:"quality_analysis,omitempty"`
RawConvert *string `json:"raw_convert,omitempty"`
ReturnDeleteToken *bool `json:"return_delete_token,omitempty"`
ResourceType *string `json:"resource_type,omitempty"`
//ResponsiveBreakpoints interface{} `json:"responsive_breakpoints,omitempty"`
Tags *string `json:"tags,omitempty"`
Timestamp *string `json:"timestamp,omitempty"`
Transformations *string `json:"transformation,omitempty"`
Type *string `json:"type,omitempty"`
UniqueFilename *bool `json:"unique_filename,omitempty"`
// Upload Preset is required for unsigned uploading and
// optional for signed uploading
UploadPreset *string `json:"upload_preset,omitempty"`
UseFilename *bool `json:"use_filename,omitempty"`
isUnsignedUpload bool
}
type SetOpts func(opts *Options)
func WithUploadPreset(uploadPreset string) SetOpts {
return func(o *Options) {
o.UploadPreset = &uploadPreset
}
}
func WithPublicId(id string) SetOpts {
return func(o *Options) {
o.PublicId = &id
}
}
func WithFolder(folder string) SetOpts {
return func(o *Options) {
if folder != "" {
o.Folder = &folder
}
}
}
func WithUseFilename(isUseFilename bool) SetOpts {
return func(o *Options) {
o.UseFilename = &isUseFilename
}
}
func WithUniqueFilename(isUniqueFilename bool) SetOpts {
return func(o *Options) {
o.UniqueFilename = &isUniqueFilename
}
}
func WithType(typeStr string) SetOpts {
return func(o *Options) {
o.Type = &typeStr
}
}
func WithAccessMode(accessMode string) SetOpts {
return func(o *Options) {
o.AccessMode = &accessMode
}
}
func WithDiscardOriginalFilename(dof bool) SetOpts {
return func(o *Options) {
o.DiscardOriginalFilename = &dof
}
}
func WithOverwrite(isOverwrite bool) SetOpts {
return func(o *Options) {
o.Overwrite = &isOverwrite
}
}
func WithTags(tags string) SetOpts {
return func(o *Options) {
o.Tags = &tags
}
}
func WithContext(ctx string) SetOpts {
return func(o *Options) {
o.Context = &ctx
}
}
func WithColors(hasColor bool) SetOpts {
return func(o *Options) {
o.Colors = &hasColor
}
}
func WithFaces(returnFaces bool) SetOpts {
return func(o *Options) {
o.Faces = &returnFaces
}
}
func WithQualityAnalysis(returnQualityAnalysis bool) SetOpts {
return func(o *Options) {
o.QualityAnalysis = &returnQualityAnalysis
}
}
func WithImageMetadata(returnImageMetadata bool) SetOpts {
return func(o *Options) {
o.ImageMetadata = &returnImageMetadata
}
}
func WithPhash(returnPhash bool) SetOpts {
return func(o *Options) {
o.Phash = &returnPhash
}
}
func WithAutoTagging(autoTagging float64) SetOpts {
return func(o *Options) {
o.AutoTagging = &autoTagging
}
}
func WithCategorization(c string) SetOpts {
return func(o *Options) {
o.Categorization = &c
}
}
func WithDetection(d string) SetOpts {
return func(o *Options) {
o.Detection = &d
}
}
func WithOCR(ocr string) SetOpts {
return func(o *Options) {
o.OCR = &ocr
}
}
func WithExif(e bool) SetOpts {
return func(o *Options) {
o.Exif = &e
}
}
func WithKeepOriginal(ko bool) SetOpts {
return func(o *Options) {
o.KeepOriginal = &ko
}
}
func (o *Options) GetPublicId() string {
if o.PublicId != nil {
return *o.PublicId
}
return ""
}
func (o *Options) GetUploadPreset() string {
if o.UploadPreset != nil {
return *o.UploadPreset
}
return ""
}
func (o *Options) GetTimestamp() string {
if o.Timestamp != nil {
return *o.Timestamp
}
return ""
}
func (o *Options) GetResourceType() string {
if o.ResourceType != nil {
return *o.ResourceType
}
return ""
}
func (o *Options) GetType() string {
if o.Type != nil {
return *o.Type
}
return ""
}
func (o *Options) GetKeepOriginal() bool {
if o.KeepOriginal != nil {
return *o.KeepOriginal
}
return false
}
func (o *Options) GetInvalidate() bool {
if o.Invalidate != nil {
return *o.Invalidate
}
return false
}
func (o *Options) GetNextCursor() string {
if o.NextCursor != nil {
return *o.NextCursor
}
return ""
}
func WithResourceType(resourceType string) SetOpts {
return func(opts *Options) {
opts.ResourceType = &resourceType
}
}
func (o *Options) toJSON() string {
b, _ := json.Marshal(o)
return string(b)
}