Skip to content

Commit 2f5a40a

Browse files
feat(api): manual updates
1 parent 428829b commit 2f5a40a

File tree

11 files changed

+261
-87
lines changed

11 files changed

+261
-87
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-dd864816d7f4316ae89f57394da2fd1926166d4704db5a0bb5d23461d2d75e49.yml
3-
openapi_spec_hash: 7f7c416563a15bbaea98804ecdc1a8f9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml
3+
openapi_spec_hash: 1d382866fce3284f26d341f112988d9d
44
config_hash: 54c05a157f2cc730fac9e1df5dc3ca29

lib/imagekit/models/file_update_params.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@
33
module Imagekit
44
module Models
55
# @see Imagekit::Resources::Files#update
6-
class FileUpdateParams < Imagekit::Models::UpdateFileRequest
6+
class FileUpdateParams < Imagekit::Internal::Type::BaseModel
77
extend Imagekit::Internal::Type::RequestParameters::Converter
88
include Imagekit::Internal::Type::RequestParameters
99

10-
# @!method initialize(request_options: {})
10+
# @!attribute update_file_request
11+
# Schema for update file update request.
12+
#
13+
# @return [Imagekit::Models::UpdateFileRequest::UpdateFileDetails, Imagekit::Models::UpdateFileRequest::ChangePublicationStatus]
14+
required :update_file_request, union: -> { Imagekit::UpdateFileRequest }
15+
16+
# @!method initialize(update_file_request:, request_options: {})
17+
# @param update_file_request [Imagekit::Models::UpdateFileRequest::UpdateFileDetails, Imagekit::Models::UpdateFileRequest::ChangePublicationStatus] Schema for update file update request.
18+
#
1119
# @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}]
1220
end
1321
end

lib/imagekit/models/update_file_request.rb

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module UpdateFileRequest
88

99
variant -> { Imagekit::UpdateFileRequest::UpdateFileDetails }
1010

11-
variant Imagekit::Internal::Type::Unknown
11+
variant -> { Imagekit::UpdateFileRequest::ChangePublicationStatus }
1212

1313
class UpdateFileDetails < Imagekit::Internal::Type::BaseModel
1414
# @!attribute custom_coordinates
@@ -115,8 +115,49 @@ module RemoveAITags
115115
end
116116
end
117117

118+
class ChangePublicationStatus < Imagekit::Internal::Type::BaseModel
119+
# @!attribute publish
120+
# Configure the publication status of a file and its versions.
121+
#
122+
# @return [Imagekit::Models::UpdateFileRequest::ChangePublicationStatus::Publish, nil]
123+
optional :publish, -> { Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish }
124+
125+
# @!method initialize(publish: nil)
126+
# Some parameter documentations has been truncated, see
127+
# {Imagekit::Models::UpdateFileRequest::ChangePublicationStatus} for more details.
128+
#
129+
# @param publish [Imagekit::Models::UpdateFileRequest::ChangePublicationStatus::Publish] Configure the publication status of a file and its versions.
130+
131+
# @see Imagekit::Models::UpdateFileRequest::ChangePublicationStatus#publish
132+
class Publish < Imagekit::Internal::Type::BaseModel
133+
# @!attribute is_published
134+
# Set to `true` to publish the file. Set to `false` to unpublish the file.
135+
#
136+
# @return [Boolean]
137+
required :is_published, Imagekit::Internal::Type::Boolean, api_name: :isPublished
138+
139+
# @!attribute include_file_versions
140+
# Set to `true` to publish/unpublish all versions of the file. Set to `false` to
141+
# publish/unpublish only the current version of the file.
142+
#
143+
# @return [Boolean, nil]
144+
optional :include_file_versions, Imagekit::Internal::Type::Boolean, api_name: :includeFileVersions
145+
146+
# @!method initialize(is_published:, include_file_versions: nil)
147+
# Some parameter documentations has been truncated, see
148+
# {Imagekit::Models::UpdateFileRequest::ChangePublicationStatus::Publish} for more
149+
# details.
150+
#
151+
# Configure the publication status of a file and its versions.
152+
#
153+
# @param is_published [Boolean] Set to `true` to publish the file. Set to `false` to unpublish the file.
154+
#
155+
# @param include_file_versions [Boolean] Set to `true` to publish/unpublish all versions of the file. Set to `false` to p
156+
end
157+
end
158+
118159
# @!method self.variants
119-
# @return [Array(Imagekit::Models::UpdateFileRequest::UpdateFileDetails, Object)]
160+
# @return [Array(Imagekit::Models::UpdateFileRequest::UpdateFileDetails, Imagekit::Models::UpdateFileRequest::ChangePublicationStatus)]
120161
end
121162
end
122163
end

lib/imagekit/resources/files.rb

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,11 @@ class Files
1919
# You can update `tags`, `customCoordinates`, `customMetadata`, publication
2020
# status, remove existing `AITags` and apply extensions using this API.
2121
#
22-
# @overload update(file_id, body:, custom_coordinates: nil, custom_metadata: nil, description: nil, extensions: nil, remove_ai_tags: nil, tags: nil, webhook_url: nil, request_options: {})
22+
# @overload update(file_id, update_file_request:, request_options: {})
2323
#
2424
# @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc
2525
#
26-
# @param body [Object]
27-
#
28-
# @param custom_coordinates [String, nil] Define an important area in the image in the format `x,y,width,height` e.g. `10,
29-
#
30-
# @param custom_metadata [Hash{Symbol=>Object}] A key-value data to be associated with the asset. To unset a key, send `null` va
31-
#
32-
# @param description [String] Optional text to describe the contents of the file.
33-
#
34-
# @param extensions [Array<Imagekit::Models::ExtensionItem::RemoveBg, Imagekit::Models::ExtensionItem::AIAutoDescription, Imagekit::Models::ExtensionItem::AutoTaggingExtension>] Array of extensions to be applied to the asset. Each extension can be configured
35-
#
36-
# @param remove_ai_tags [Array<String>, Symbol, :all] An array of AITags associated with the file that you want to remove, e.g. `["car
37-
#
38-
# @param tags [Array<String>, nil] An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `nul
39-
#
40-
# @param webhook_url [String] The final status of extensions after they have completed execution will be deliv
26+
# @param update_file_request [Imagekit::UpdateFileRequest] Schema for update file update request.
4127
#
4228
# @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil]
4329
#
@@ -46,6 +32,11 @@ class Files
4632
# @see Imagekit::Models::FileUpdateParams
4733
def update(file_id, params)
4834
parsed, options = Imagekit::FileUpdateParams.dump_request(params)
35+
case parsed
36+
in {update_file_request: Hash => union, **rest}
37+
parsed = {**rest, **union}
38+
else
39+
end
4940
@client.request(
5041
method: :patch,
5142
path: ["v1/files/%1$s/details", file_id],

rbi/imagekit/models/file_update_params.rbi

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Imagekit
44
module Models
5-
class FileUpdateParams < Imagekit::Models::UpdateFileRequest
5+
class FileUpdateParams < Imagekit::Internal::Type::BaseModel
66
extend Imagekit::Internal::Type::RequestParameters::Converter
77
include Imagekit::Internal::Type::RequestParameters
88

@@ -11,15 +11,46 @@ module Imagekit
1111
T.any(Imagekit::FileUpdateParams, Imagekit::Internal::AnyHash)
1212
end
1313

14+
# Schema for update file update request.
1415
sig do
15-
params(request_options: Imagekit::RequestOptions::OrHash).returns(
16-
T.attached_class
16+
returns(
17+
T.any(
18+
Imagekit::UpdateFileRequest::UpdateFileDetails,
19+
Imagekit::UpdateFileRequest::ChangePublicationStatus
20+
)
1721
)
1822
end
19-
def self.new(request_options: {})
23+
attr_accessor :update_file_request
24+
25+
sig do
26+
params(
27+
update_file_request:
28+
T.any(
29+
Imagekit::UpdateFileRequest::UpdateFileDetails::OrHash,
30+
Imagekit::UpdateFileRequest::ChangePublicationStatus::OrHash
31+
),
32+
request_options: Imagekit::RequestOptions::OrHash
33+
).returns(T.attached_class)
34+
end
35+
def self.new(
36+
# Schema for update file update request.
37+
update_file_request:,
38+
request_options: {}
39+
)
2040
end
2141

22-
sig { override.returns({ request_options: Imagekit::RequestOptions }) }
42+
sig do
43+
override.returns(
44+
{
45+
update_file_request:
46+
T.any(
47+
Imagekit::UpdateFileRequest::UpdateFileDetails,
48+
Imagekit::UpdateFileRequest::ChangePublicationStatus
49+
),
50+
request_options: Imagekit::RequestOptions
51+
}
52+
)
53+
end
2354
def to_hash
2455
end
2556
end

rbi/imagekit/models/update_file_request.rbi

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ module Imagekit
88

99
Variants =
1010
T.type_alias do
11-
T.any(Imagekit::UpdateFileRequest::UpdateFileDetails, T.anything)
11+
T.any(
12+
Imagekit::UpdateFileRequest::UpdateFileDetails,
13+
Imagekit::UpdateFileRequest::ChangePublicationStatus
14+
)
1215
end
1316

1417
class UpdateFileDetails < Imagekit::Internal::Type::BaseModel
@@ -206,6 +209,103 @@ module Imagekit
206209
end
207210
end
208211

212+
class ChangePublicationStatus < Imagekit::Internal::Type::BaseModel
213+
OrHash =
214+
T.type_alias do
215+
T.any(
216+
Imagekit::UpdateFileRequest::ChangePublicationStatus,
217+
Imagekit::Internal::AnyHash
218+
)
219+
end
220+
221+
# Configure the publication status of a file and its versions.
222+
sig do
223+
returns(
224+
T.nilable(
225+
Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish
226+
)
227+
)
228+
end
229+
attr_reader :publish
230+
231+
sig do
232+
params(
233+
publish:
234+
Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish::OrHash
235+
).void
236+
end
237+
attr_writer :publish
238+
239+
sig do
240+
params(
241+
publish:
242+
Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish::OrHash
243+
).returns(T.attached_class)
244+
end
245+
def self.new(
246+
# Configure the publication status of a file and its versions.
247+
publish: nil
248+
)
249+
end
250+
251+
sig do
252+
override.returns(
253+
{
254+
publish:
255+
Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish
256+
}
257+
)
258+
end
259+
def to_hash
260+
end
261+
262+
class Publish < Imagekit::Internal::Type::BaseModel
263+
OrHash =
264+
T.type_alias do
265+
T.any(
266+
Imagekit::UpdateFileRequest::ChangePublicationStatus::Publish,
267+
Imagekit::Internal::AnyHash
268+
)
269+
end
270+
271+
# Set to `true` to publish the file. Set to `false` to unpublish the file.
272+
sig { returns(T::Boolean) }
273+
attr_accessor :is_published
274+
275+
# Set to `true` to publish/unpublish all versions of the file. Set to `false` to
276+
# publish/unpublish only the current version of the file.
277+
sig { returns(T.nilable(T::Boolean)) }
278+
attr_reader :include_file_versions
279+
280+
sig { params(include_file_versions: T::Boolean).void }
281+
attr_writer :include_file_versions
282+
283+
# Configure the publication status of a file and its versions.
284+
sig do
285+
params(
286+
is_published: T::Boolean,
287+
include_file_versions: T::Boolean
288+
).returns(T.attached_class)
289+
end
290+
def self.new(
291+
# Set to `true` to publish the file. Set to `false` to unpublish the file.
292+
is_published:,
293+
# Set to `true` to publish/unpublish all versions of the file. Set to `false` to
294+
# publish/unpublish only the current version of the file.
295+
include_file_versions: nil
296+
)
297+
end
298+
299+
sig do
300+
override.returns(
301+
{ is_published: T::Boolean, include_file_versions: T::Boolean }
302+
)
303+
end
304+
def to_hash
305+
end
306+
end
307+
end
308+
209309
sig { override.returns(T::Array[Imagekit::UpdateFileRequest::Variants]) }
210310
def self.variants
211311
end

rbi/imagekit/resources/files.rbi

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,58 +18,16 @@ module Imagekit
1818
sig do
1919
params(
2020
file_id: String,
21-
body: T.anything,
22-
custom_coordinates: T.nilable(String),
23-
custom_metadata: T::Hash[Symbol, T.anything],
24-
description: String,
25-
extensions:
26-
T::Array[
27-
T.any(
28-
Imagekit::ExtensionItem::RemoveBg::OrHash,
29-
Imagekit::ExtensionItem::AIAutoDescription::OrHash,
30-
Imagekit::ExtensionItem::AutoTaggingExtension::OrHash
31-
)
32-
],
33-
remove_ai_tags: T.any(T::Array[String], Symbol),
34-
tags: T.nilable(T::Array[String]),
35-
webhook_url: String,
21+
update_file_request: Imagekit::UpdateFileRequest,
3622
request_options: Imagekit::RequestOptions::OrHash
3723
).returns(Imagekit::Models::FileUpdateResponse)
3824
end
3925
def update(
4026
# The unique `fileId` of the uploaded file. `fileId` is returned in list and
4127
# search assets API and upload API.
4228
file_id,
43-
body:,
44-
# Define an important area in the image in the format `x,y,width,height` e.g.
45-
# `10,10,100,100`. Send `null` to unset this value.
46-
custom_coordinates: nil,
47-
# A key-value data to be associated with the asset. To unset a key, send `null`
48-
# value for that key. Before setting any custom metadata on an asset you have to
49-
# create the field using custom metadata fields API.
50-
custom_metadata: nil,
51-
# Optional text to describe the contents of the file.
52-
description: nil,
53-
# Array of extensions to be applied to the asset. Each extension can be configured
54-
# with specific parameters based on the extension type.
55-
extensions: nil,
56-
# An array of AITags associated with the file that you want to remove, e.g.
57-
# `["car", "vehicle", "motorsports"]`.
58-
#
59-
# If you want to remove all AITags associated with the file, send a string -
60-
# "all".
61-
#
62-
# Note: The remove operation for `AITags` executes before any of the `extensions`
63-
# are processed.
64-
remove_ai_tags: nil,
65-
# An array of tags associated with the file, such as `["tag1", "tag2"]`. Send
66-
# `null` to unset all tags associated with the file.
67-
tags: nil,
68-
# The final status of extensions after they have completed execution will be
69-
# delivered to this endpoint as a POST request.
70-
# [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure)
71-
# about the webhook payload structure.
72-
webhook_url: nil,
29+
# Schema for update file update request.
30+
update_file_request:,
7331
request_options: {}
7432
)
7533
end
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
module Imagekit
22
module Models
33
type file_update_params =
4-
{ } & Imagekit::Internal::Type::request_parameters
4+
{ update_file_request: Imagekit::Models::update_file_request }
5+
& Imagekit::Internal::Type::request_parameters
56

6-
class FileUpdateParams < Imagekit::Models::UpdateFileRequest
7+
class FileUpdateParams < Imagekit::Internal::Type::BaseModel
78
extend Imagekit::Internal::Type::RequestParameters::Converter
89
include Imagekit::Internal::Type::RequestParameters
910

10-
def initialize: (?request_options: Imagekit::request_opts) -> void
11+
def update_file_request: -> Imagekit::Models::update_file_request
1112

12-
def to_hash: -> { request_options: Imagekit::RequestOptions }
13+
def update_file_request=: (
14+
Imagekit::Models::update_file_request _
15+
) -> Imagekit::Models::update_file_request
16+
17+
def initialize: (
18+
update_file_request: Imagekit::Models::update_file_request,
19+
?request_options: Imagekit::request_opts
20+
) -> void
21+
22+
def to_hash: -> {
23+
update_file_request: Imagekit::Models::update_file_request,
24+
request_options: Imagekit::RequestOptions
25+
}
1326
end
1427
end
1528
end

0 commit comments

Comments
 (0)