-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfilebulk.go
More file actions
205 lines (180 loc) · 7.8 KB
/
filebulk.go
File metadata and controls
205 lines (180 loc) · 7.8 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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package imagekit
import (
"context"
"net/http"
"slices"
"github.com/imagekit-developer/imagekit-go/v2/internal/apijson"
"github.com/imagekit-developer/imagekit-go/v2/internal/requestconfig"
"github.com/imagekit-developer/imagekit-go/v2/option"
"github.com/imagekit-developer/imagekit-go/v2/packages/param"
"github.com/imagekit-developer/imagekit-go/v2/packages/respjson"
)
// FileBulkService contains methods and other services that help with interacting
// with the ImageKit API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewFileBulkService] method instead.
type FileBulkService struct {
Options []option.RequestOption
}
// NewFileBulkService generates a new service that applies the given options to
// each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewFileBulkService(opts ...option.RequestOption) (r FileBulkService) {
r = FileBulkService{}
r.Options = opts
return
}
// This API deletes multiple files and all their file versions permanently.
//
// Note: If a file or specific transformation has been requested in the past, then
// the response is cached. Deleting a file does not purge the cache. You can purge
// the cache using purge cache API.
//
// A maximum of 100 files can be deleted at a time.
func (r *FileBulkService) Delete(ctx context.Context, body FileBulkDeleteParams, opts ...option.RequestOption) (res *FileBulkDeleteResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/files/batch/deleteByFileIds"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// This API adds tags to multiple files in bulk. A maximum of 50 files can be
// specified at a time.
func (r *FileBulkService) AddTags(ctx context.Context, body FileBulkAddTagsParams, opts ...option.RequestOption) (res *FileBulkAddTagsResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/files/addTags"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// This API removes AITags from multiple files in bulk. A maximum of 50 files can
// be specified at a time.
func (r *FileBulkService) RemoveAITags(ctx context.Context, body FileBulkRemoveAITagsParams, opts ...option.RequestOption) (res *FileBulkRemoveAITagsResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/files/removeAITags"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// This API removes tags from multiple files in bulk. A maximum of 50 files can be
// specified at a time.
func (r *FileBulkService) RemoveTags(ctx context.Context, body FileBulkRemoveTagsParams, opts ...option.RequestOption) (res *FileBulkRemoveTagsResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/files/removeTags"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
type FileBulkDeleteResponse struct {
// An array of fileIds that were successfully deleted.
SuccessfullyDeletedFileIDs []string `json:"successfullyDeletedFileIds"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
SuccessfullyDeletedFileIDs respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FileBulkDeleteResponse) RawJSON() string { return r.JSON.raw }
func (r *FileBulkDeleteResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileBulkAddTagsResponse struct {
// An array of fileIds that in which tags were successfully added.
SuccessfullyUpdatedFileIDs []string `json:"successfullyUpdatedFileIds"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
SuccessfullyUpdatedFileIDs respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FileBulkAddTagsResponse) RawJSON() string { return r.JSON.raw }
func (r *FileBulkAddTagsResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileBulkRemoveAITagsResponse struct {
// An array of fileIds that in which AITags were successfully removed.
SuccessfullyUpdatedFileIDs []string `json:"successfullyUpdatedFileIds"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
SuccessfullyUpdatedFileIDs respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FileBulkRemoveAITagsResponse) RawJSON() string { return r.JSON.raw }
func (r *FileBulkRemoveAITagsResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileBulkRemoveTagsResponse struct {
// An array of fileIds that in which tags were successfully removed.
SuccessfullyUpdatedFileIDs []string `json:"successfullyUpdatedFileIds"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
SuccessfullyUpdatedFileIDs respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FileBulkRemoveTagsResponse) RawJSON() string { return r.JSON.raw }
func (r *FileBulkRemoveTagsResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileBulkDeleteParams struct {
// An array of fileIds which you want to delete.
FileIDs []string `json:"fileIds,omitzero" api:"required"`
paramObj
}
func (r FileBulkDeleteParams) MarshalJSON() (data []byte, err error) {
type shadow FileBulkDeleteParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *FileBulkDeleteParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileBulkAddTagsParams struct {
// An array of fileIds to which you want to add tags.
FileIDs []string `json:"fileIds,omitzero" api:"required"`
// An array of tags that you want to add to the files.
Tags []string `json:"tags,omitzero" api:"required"`
paramObj
}
func (r FileBulkAddTagsParams) MarshalJSON() (data []byte, err error) {
type shadow FileBulkAddTagsParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *FileBulkAddTagsParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileBulkRemoveAITagsParams struct {
// An array of AITags that you want to remove from the files.
AITags []string `json:"AITags,omitzero" api:"required"`
// An array of fileIds from which you want to remove AITags.
FileIDs []string `json:"fileIds,omitzero" api:"required"`
paramObj
}
func (r FileBulkRemoveAITagsParams) MarshalJSON() (data []byte, err error) {
type shadow FileBulkRemoveAITagsParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *FileBulkRemoveAITagsParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileBulkRemoveTagsParams struct {
// An array of fileIds from which you want to remove tags.
FileIDs []string `json:"fileIds,omitzero" api:"required"`
// An array of tags that you want to remove from the files.
Tags []string `json:"tags,omitzero" api:"required"`
paramObj
}
func (r FileBulkRemoveTagsParams) MarshalJSON() (data []byte, err error) {
type shadow FileBulkRemoveTagsParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *FileBulkRemoveTagsParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}