-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfiles.go
More file actions
522 lines (448 loc) · 14.3 KB
/
files.go
File metadata and controls
522 lines (448 loc) · 14.3 KB
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
// Code generated by Fern. DO NOT EDIT.
package api
import (
json "encoding/json"
fmt "fmt"
internal "github.com/VapiAI/server-sdk-go/v505/internal"
io "io"
big "math/big"
time "time"
)
type CreateFileDto struct {
File io.Reader `json:"-" url:"-"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (c *CreateFileDto) require(field *big.Int) {
if c.explicitFields == nil {
c.explicitFields = big.NewInt(0)
}
c.explicitFields.Or(c.explicitFields, field)
}
var (
deleteFilesRequestFieldId = big.NewInt(1 << 0)
)
type DeleteFilesRequest struct {
Id string `json:"-" url:"-"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (d *DeleteFilesRequest) require(field *big.Int) {
if d.explicitFields == nil {
d.explicitFields = big.NewInt(0)
}
d.explicitFields.Or(d.explicitFields, field)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (d *DeleteFilesRequest) SetId(id string) {
d.Id = id
d.require(deleteFilesRequestFieldId)
}
var (
getFilesRequestFieldId = big.NewInt(1 << 0)
)
type GetFilesRequest struct {
Id string `json:"-" url:"-"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (g *GetFilesRequest) require(field *big.Int) {
if g.explicitFields == nil {
g.explicitFields = big.NewInt(0)
}
g.explicitFields.Or(g.explicitFields, field)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (g *GetFilesRequest) SetId(id string) {
g.Id = id
g.require(getFilesRequestFieldId)
}
var (
fileFieldObject = big.NewInt(1 << 0)
fileFieldStatus = big.NewInt(1 << 1)
fileFieldName = big.NewInt(1 << 2)
fileFieldOriginalName = big.NewInt(1 << 3)
fileFieldBytes = big.NewInt(1 << 4)
fileFieldPurpose = big.NewInt(1 << 5)
fileFieldMimetype = big.NewInt(1 << 6)
fileFieldKey = big.NewInt(1 << 7)
fileFieldPath = big.NewInt(1 << 8)
fileFieldBucket = big.NewInt(1 << 9)
fileFieldUrl = big.NewInt(1 << 10)
fileFieldParsedTextUrl = big.NewInt(1 << 11)
fileFieldParsedTextBytes = big.NewInt(1 << 12)
fileFieldMetadata = big.NewInt(1 << 13)
fileFieldId = big.NewInt(1 << 14)
fileFieldOrgId = big.NewInt(1 << 15)
fileFieldCreatedAt = big.NewInt(1 << 16)
fileFieldUpdatedAt = big.NewInt(1 << 17)
)
type File struct {
Object *FileObject `json:"object,omitempty" url:"object,omitempty"`
Status *FileStatus `json:"status,omitempty" url:"status,omitempty"`
// This is the name of the file. This is just for your own reference.
Name *string `json:"name,omitempty" url:"name,omitempty"`
OriginalName *string `json:"originalName,omitempty" url:"originalName,omitempty"`
Bytes *float64 `json:"bytes,omitempty" url:"bytes,omitempty"`
Purpose *string `json:"purpose,omitempty" url:"purpose,omitempty"`
Mimetype *string `json:"mimetype,omitempty" url:"mimetype,omitempty"`
Key *string `json:"key,omitempty" url:"key,omitempty"`
Path *string `json:"path,omitempty" url:"path,omitempty"`
Bucket *string `json:"bucket,omitempty" url:"bucket,omitempty"`
Url *string `json:"url,omitempty" url:"url,omitempty"`
ParsedTextUrl *string `json:"parsedTextUrl,omitempty" url:"parsedTextUrl,omitempty"`
ParsedTextBytes *float64 `json:"parsedTextBytes,omitempty" url:"parsedTextBytes,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty" url:"metadata,omitempty"`
// This is the unique identifier for the file.
Id string `json:"id" url:"id"`
// This is the unique identifier for the org that this file belongs to.
OrgId string `json:"orgId" url:"orgId"`
// This is the ISO 8601 date-time string of when the file was created.
CreatedAt time.Time `json:"createdAt" url:"createdAt"`
// This is the ISO 8601 date-time string of when the file was last updated.
UpdatedAt time.Time `json:"updatedAt" url:"updatedAt"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (f *File) GetObject() *FileObject {
if f == nil {
return nil
}
return f.Object
}
func (f *File) GetStatus() *FileStatus {
if f == nil {
return nil
}
return f.Status
}
func (f *File) GetName() *string {
if f == nil {
return nil
}
return f.Name
}
func (f *File) GetOriginalName() *string {
if f == nil {
return nil
}
return f.OriginalName
}
func (f *File) GetBytes() *float64 {
if f == nil {
return nil
}
return f.Bytes
}
func (f *File) GetPurpose() *string {
if f == nil {
return nil
}
return f.Purpose
}
func (f *File) GetMimetype() *string {
if f == nil {
return nil
}
return f.Mimetype
}
func (f *File) GetKey() *string {
if f == nil {
return nil
}
return f.Key
}
func (f *File) GetPath() *string {
if f == nil {
return nil
}
return f.Path
}
func (f *File) GetBucket() *string {
if f == nil {
return nil
}
return f.Bucket
}
func (f *File) GetUrl() *string {
if f == nil {
return nil
}
return f.Url
}
func (f *File) GetParsedTextUrl() *string {
if f == nil {
return nil
}
return f.ParsedTextUrl
}
func (f *File) GetParsedTextBytes() *float64 {
if f == nil {
return nil
}
return f.ParsedTextBytes
}
func (f *File) GetMetadata() map[string]interface{} {
if f == nil {
return nil
}
return f.Metadata
}
func (f *File) GetId() string {
if f == nil {
return ""
}
return f.Id
}
func (f *File) GetOrgId() string {
if f == nil {
return ""
}
return f.OrgId
}
func (f *File) GetCreatedAt() time.Time {
if f == nil {
return time.Time{}
}
return f.CreatedAt
}
func (f *File) GetUpdatedAt() time.Time {
if f == nil {
return time.Time{}
}
return f.UpdatedAt
}
func (f *File) GetExtraProperties() map[string]interface{} {
return f.extraProperties
}
func (f *File) require(field *big.Int) {
if f.explicitFields == nil {
f.explicitFields = big.NewInt(0)
}
f.explicitFields.Or(f.explicitFields, field)
}
// SetObject sets the Object field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetObject(object *FileObject) {
f.Object = object
f.require(fileFieldObject)
}
// SetStatus sets the Status field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetStatus(status *FileStatus) {
f.Status = status
f.require(fileFieldStatus)
}
// SetName sets the Name field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetName(name *string) {
f.Name = name
f.require(fileFieldName)
}
// SetOriginalName sets the OriginalName field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetOriginalName(originalName *string) {
f.OriginalName = originalName
f.require(fileFieldOriginalName)
}
// SetBytes sets the Bytes field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetBytes(bytes *float64) {
f.Bytes = bytes
f.require(fileFieldBytes)
}
// SetPurpose sets the Purpose field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetPurpose(purpose *string) {
f.Purpose = purpose
f.require(fileFieldPurpose)
}
// SetMimetype sets the Mimetype field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetMimetype(mimetype *string) {
f.Mimetype = mimetype
f.require(fileFieldMimetype)
}
// SetKey sets the Key field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetKey(key *string) {
f.Key = key
f.require(fileFieldKey)
}
// SetPath sets the Path field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetPath(path *string) {
f.Path = path
f.require(fileFieldPath)
}
// SetBucket sets the Bucket field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetBucket(bucket *string) {
f.Bucket = bucket
f.require(fileFieldBucket)
}
// SetUrl sets the Url field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetUrl(url *string) {
f.Url = url
f.require(fileFieldUrl)
}
// SetParsedTextUrl sets the ParsedTextUrl field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetParsedTextUrl(parsedTextUrl *string) {
f.ParsedTextUrl = parsedTextUrl
f.require(fileFieldParsedTextUrl)
}
// SetParsedTextBytes sets the ParsedTextBytes field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetParsedTextBytes(parsedTextBytes *float64) {
f.ParsedTextBytes = parsedTextBytes
f.require(fileFieldParsedTextBytes)
}
// SetMetadata sets the Metadata field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetMetadata(metadata map[string]interface{}) {
f.Metadata = metadata
f.require(fileFieldMetadata)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetId(id string) {
f.Id = id
f.require(fileFieldId)
}
// SetOrgId sets the OrgId field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetOrgId(orgId string) {
f.OrgId = orgId
f.require(fileFieldOrgId)
}
// SetCreatedAt sets the CreatedAt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetCreatedAt(createdAt time.Time) {
f.CreatedAt = createdAt
f.require(fileFieldCreatedAt)
}
// SetUpdatedAt sets the UpdatedAt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (f *File) SetUpdatedAt(updatedAt time.Time) {
f.UpdatedAt = updatedAt
f.require(fileFieldUpdatedAt)
}
func (f *File) UnmarshalJSON(data []byte) error {
type embed File
var unmarshaler = struct {
embed
CreatedAt *internal.DateTime `json:"createdAt"`
UpdatedAt *internal.DateTime `json:"updatedAt"`
}{
embed: embed(*f),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*f = File(unmarshaler.embed)
f.CreatedAt = unmarshaler.CreatedAt.Time()
f.UpdatedAt = unmarshaler.UpdatedAt.Time()
extraProperties, err := internal.ExtractExtraProperties(data, *f)
if err != nil {
return err
}
f.extraProperties = extraProperties
f.rawJSON = json.RawMessage(data)
return nil
}
func (f *File) MarshalJSON() ([]byte, error) {
type embed File
var marshaler = struct {
embed
CreatedAt *internal.DateTime `json:"createdAt"`
UpdatedAt *internal.DateTime `json:"updatedAt"`
}{
embed: embed(*f),
CreatedAt: internal.NewDateTime(f.CreatedAt),
UpdatedAt: internal.NewDateTime(f.UpdatedAt),
}
explicitMarshaler := internal.HandleExplicitFields(marshaler, f.explicitFields)
return json.Marshal(explicitMarshaler)
}
func (f *File) String() string {
if len(f.rawJSON) > 0 {
if value, err := internal.StringifyJSON(f.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(f); err == nil {
return value
}
return fmt.Sprintf("%#v", f)
}
type FileObject string
const (
FileObjectFile FileObject = "file"
)
func NewFileObjectFromString(s string) (FileObject, error) {
switch s {
case "file":
return FileObjectFile, nil
}
var t FileObject
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (f FileObject) Ptr() *FileObject {
return &f
}
type FileStatus string
const (
FileStatusProcessing FileStatus = "processing"
FileStatusDone FileStatus = "done"
FileStatusFailed FileStatus = "failed"
)
func NewFileStatusFromString(s string) (FileStatus, error) {
switch s {
case "processing":
return FileStatusProcessing, nil
case "done":
return FileStatusDone, nil
case "failed":
return FileStatusFailed, nil
}
var t FileStatus
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (f FileStatus) Ptr() *FileStatus {
return &f
}
var (
updateFileDtoFieldId = big.NewInt(1 << 0)
updateFileDtoFieldName = big.NewInt(1 << 1)
)
type UpdateFileDto struct {
Id string `json:"-" url:"-"`
// This is the name of the file. This is just for your own reference.
Name *string `json:"name,omitempty" url:"-"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (u *UpdateFileDto) require(field *big.Int) {
if u.explicitFields == nil {
u.explicitFields = big.NewInt(0)
}
u.explicitFields.Or(u.explicitFields, field)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (u *UpdateFileDto) SetId(id string) {
u.Id = id
u.require(updateFileDtoFieldId)
}
// SetName sets the Name field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (u *UpdateFileDto) SetName(name *string) {
u.Name = name
u.require(updateFileDtoFieldName)
}