-
Notifications
You must be signed in to change notification settings - Fork 1
/
files.go
206 lines (175 loc) · 5.13 KB
/
files.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
// This file was auto-generated by Fern from our API Definition.
package api
import (
json "encoding/json"
fmt "fmt"
core "github.com/FlatFilers/flatfile-go/core"
)
type ListFilesRequest struct {
SpaceId *string `json:"-" url:"spaceId,omitempty"`
// Number of files to return in a page (default 20)
PageSize *int `json:"-" url:"pageSize,omitempty"`
// Based on pageSize, which page of files to return
PageNumber *int `json:"-" url:"pageNumber,omitempty"`
// The storage mode of file to fetch, defaults to "import"
Mode *Mode `json:"-" url:"mode,omitempty"`
}
type FileOrigin string
const (
FileOriginFilesystem FileOrigin = "filesystem"
FileOriginGoogledrive FileOrigin = "googledrive"
FileOriginBox FileOrigin = "box"
FileOriginOnedrive FileOrigin = "onedrive"
)
func NewFileOriginFromString(s string) (FileOrigin, error) {
switch s {
case "filesystem":
return FileOriginFilesystem, nil
case "googledrive":
return FileOriginGoogledrive, nil
case "box":
return FileOriginBox, nil
case "onedrive":
return FileOriginOnedrive, nil
}
var t FileOrigin
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (f FileOrigin) Ptr() *FileOrigin {
return &f
}
type FileResponse struct {
Data *File `json:"data,omitempty" url:"data,omitempty"`
extraProperties map[string]interface{}
_rawJSON json.RawMessage
}
func (f *FileResponse) GetExtraProperties() map[string]interface{} {
return f.extraProperties
}
func (f *FileResponse) UnmarshalJSON(data []byte) error {
type unmarshaler FileResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*f = FileResponse(value)
extraProperties, err := core.ExtractExtraProperties(data, *f)
if err != nil {
return err
}
f.extraProperties = extraProperties
f._rawJSON = json.RawMessage(data)
return nil
}
func (f *FileResponse) String() string {
if len(f._rawJSON) > 0 {
if value, err := core.StringifyJSON(f._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(f); err == nil {
return value
}
return fmt.Sprintf("%#v", f)
}
type ListFilesResponse struct {
Pagination *Pagination `json:"pagination,omitempty" url:"pagination,omitempty"`
Data []*File `json:"data,omitempty" url:"data,omitempty"`
extraProperties map[string]interface{}
_rawJSON json.RawMessage
}
func (l *ListFilesResponse) GetExtraProperties() map[string]interface{} {
return l.extraProperties
}
func (l *ListFilesResponse) UnmarshalJSON(data []byte) error {
type unmarshaler ListFilesResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = ListFilesResponse(value)
extraProperties, err := core.ExtractExtraProperties(data, *l)
if err != nil {
return err
}
l.extraProperties = extraProperties
l._rawJSON = json.RawMessage(data)
return nil
}
func (l *ListFilesResponse) String() string {
if len(l._rawJSON) > 0 {
if value, err := core.StringifyJSON(l._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}
type Mode string
const (
ModeImport Mode = "import"
ModeExport Mode = "export"
)
func NewModeFromString(s string) (Mode, error) {
switch s {
case "import":
return ModeImport, nil
case "export":
return ModeExport, nil
}
var t Mode
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (m Mode) Ptr() *Mode {
return &m
}
type ModelFileStatusEnum string
const (
ModelFileStatusEnumPartial ModelFileStatusEnum = "partial"
ModelFileStatusEnumComplete ModelFileStatusEnum = "complete"
ModelFileStatusEnumArchived ModelFileStatusEnum = "archived"
ModelFileStatusEnumPurged ModelFileStatusEnum = "purged"
ModelFileStatusEnumFailed ModelFileStatusEnum = "failed"
)
func NewModelFileStatusEnumFromString(s string) (ModelFileStatusEnum, error) {
switch s {
case "partial":
return ModelFileStatusEnumPartial, nil
case "complete":
return ModelFileStatusEnumComplete, nil
case "archived":
return ModelFileStatusEnumArchived, nil
case "purged":
return ModelFileStatusEnumPurged, nil
case "failed":
return ModelFileStatusEnumFailed, nil
}
var t ModelFileStatusEnum
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (m ModelFileStatusEnum) Ptr() *ModelFileStatusEnum {
return &m
}
type UpdateFileRequest struct {
WorkbookId *WorkbookId `json:"workbookId,omitempty" url:"-"`
// The name of the file
Name *string `json:"name,omitempty" url:"-"`
// The storage mode of file to update
Mode *Mode `json:"mode,omitempty" url:"-"`
// Status of the file
Status *ModelFileStatusEnum `json:"status,omitempty" url:"-"`
// The actions attached to the file
Actions []*Action `json:"actions,omitempty" url:"-"`
}
type CreateFileRequest struct {
SpaceId SpaceId `json:"spaceId" url:"-"`
EnvironmentId EnvironmentId `json:"environmentId" url:"-"`
// The storage mode of file to insert, defaults to "import"
Mode *Mode `json:"mode,omitempty" url:"-"`
// The actions attached to the file
Actions []*Action `json:"actions,omitempty" url:"-"`
// The origin of the file, ie filesystem
Origin *FileOrigin `json:"origin,omitempty" url:"-"`
}