Skip to content

Commit 9aaa659

Browse files
feat(api): extract UpdateFileDetailsRequest to model
1 parent ba5a211 commit 9aaa659

File tree

14 files changed

+647
-509
lines changed

14 files changed

+647
-509
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-bc7c0d27962b30c19c778656988e154b54696819389289f34420a5e5fdfbd3b8.yml
33
openapi_spec_hash: 1bfde02a63416c036e9545927f727459
4-
config_hash: a652d68098d82eaf611a49507fb4b831
4+
config_hash: b415c06a3b29485af4601beb94ae1aeb

lib/imagekit.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
require_relative "imagekit/client"
5353
require_relative "imagekit/models/accounts/origin_request"
5454
require_relative "imagekit/models/accounts/url_endpoint_request"
55+
require_relative "imagekit/models/update_file_details_request"
5556
require_relative "imagekit/models/file"
5657
require_relative "imagekit/models/base_overlay"
5758
require_relative "imagekit/models/base_webhook_event"

lib/imagekit/models.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ module Imagekit
132132

133133
UnwrapWebhookEvent = Imagekit::Models::UnwrapWebhookEvent
134134

135+
UpdateFileDetailsRequest = Imagekit::Models::UpdateFileDetailsRequest
136+
135137
UploadPostTransformErrorEvent = Imagekit::Models::UploadPostTransformErrorEvent
136138

137139
UploadPostTransformSuccessEvent = Imagekit::Models::UploadPostTransformSuccessEvent

lib/imagekit/models/file_update_params.rb

Lines changed: 5 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -7,143 +7,14 @@ class FileUpdateParams < Imagekit::Internal::Type::BaseModel
77
extend Imagekit::Internal::Type::RequestParameters::Converter
88
include Imagekit::Internal::Type::RequestParameters
99

10-
# @!attribute custom_coordinates
11-
# Define an important area in the image in the format `x,y,width,height` e.g.
12-
# `10,10,100,100`. Send `null` to unset this value.
10+
# @!attribute update_file_details_request
1311
#
14-
# @return [String, nil]
15-
optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true
12+
# @return [Imagekit::Models::UpdateFileDetailsRequest::UpdateFileDetails, Imagekit::Models::UpdateFileDetailsRequest::ChangePublicationStatus]
13+
required :update_file_details_request, union: -> { Imagekit::UpdateFileDetailsRequest }
1614

17-
# @!attribute custom_metadata
18-
# A key-value data to be associated with the asset. To unset a key, send `null`
19-
# value for that key. Before setting any custom metadata on an asset you have to
20-
# create the field using custom metadata fields API.
21-
#
22-
# @return [Hash{Symbol=>Object}, nil]
23-
optional :custom_metadata,
24-
Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown],
25-
api_name: :customMetadata
26-
27-
# @!attribute description
28-
# Optional text to describe the contents of the file.
29-
#
30-
# @return [String, nil]
31-
optional :description, String
32-
33-
# @!attribute extensions
34-
# Array of extensions to be applied to the asset. Each extension can be configured
35-
# with specific parameters based on the extension type.
36-
#
37-
# @return [Array<Imagekit::Models::ExtensionItem::RemoveBg, Imagekit::Models::ExtensionItem::AIAutoDescription, Imagekit::Models::ExtensionItem::AutoTaggingExtension>, nil]
38-
optional :extensions, -> { Imagekit::Internal::Type::ArrayOf[union: Imagekit::ExtensionItem] }
39-
40-
# @!attribute remove_ai_tags
41-
# An array of AITags associated with the file that you want to remove, e.g.
42-
# `["car", "vehicle", "motorsports"]`.
43-
#
44-
# If you want to remove all AITags associated with the file, send a string -
45-
# "all".
46-
#
47-
# Note: The remove operation for `AITags` executes before any of the `extensions`
48-
# are processed.
49-
#
50-
# @return [Array<String>, Symbol, :all, nil]
51-
optional :remove_ai_tags,
52-
union: -> {
53-
Imagekit::FileUpdateParams::RemoveAITags
54-
},
55-
api_name: :removeAITags
56-
57-
# @!attribute tags
58-
# An array of tags associated with the file, such as `["tag1", "tag2"]`. Send
59-
# `null` to unset all tags associated with the file.
60-
#
61-
# @return [Array<String>, nil]
62-
optional :tags, Imagekit::Internal::Type::ArrayOf[String], nil?: true
63-
64-
# @!attribute webhook_url
65-
# The final status of extensions after they have completed execution will be
66-
# delivered to this endpoint as a POST request.
67-
# [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure)
68-
# about the webhook payload structure.
69-
#
70-
# @return [String, nil]
71-
optional :webhook_url, String, api_name: :webhookUrl
72-
73-
# @!attribute publish
74-
# Configure the publication status of a file and its versions.
75-
#
76-
# @return [Imagekit::Models::FileUpdateParams::Publish, nil]
77-
optional :publish, -> { Imagekit::FileUpdateParams::Publish }
78-
79-
# @!method initialize(custom_coordinates: nil, custom_metadata: nil, description: nil, extensions: nil, remove_ai_tags: nil, tags: nil, webhook_url: nil, publish: nil, request_options: {})
80-
# Some parameter documentations has been truncated, see
81-
# {Imagekit::Models::FileUpdateParams} for more details.
82-
#
83-
# @param custom_coordinates [String, nil] Define an important area in the image in the format `x,y,width,height` e.g. `10,
84-
#
85-
# @param custom_metadata [Hash{Symbol=>Object}] A key-value data to be associated with the asset. To unset a key, send `null` va
86-
#
87-
# @param description [String] Optional text to describe the contents of the file.
88-
#
89-
# @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
90-
#
91-
# @param remove_ai_tags [Array<String>, Symbol, :all] An array of AITags associated with the file that you want to remove, e.g. `["car
92-
#
93-
# @param tags [Array<String>, nil] An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `nul
94-
#
95-
# @param webhook_url [String] The final status of extensions after they have completed execution will be deliv
96-
#
97-
# @param publish [Imagekit::Models::FileUpdateParams::Publish] Configure the publication status of a file and its versions.
98-
#
15+
# @!method initialize(update_file_details_request:, request_options: {})
16+
# @param update_file_details_request [Imagekit::Models::UpdateFileDetailsRequest::UpdateFileDetails, Imagekit::Models::UpdateFileDetailsRequest::ChangePublicationStatus]
9917
# @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}]
100-
101-
# An array of AITags associated with the file that you want to remove, e.g.
102-
# `["car", "vehicle", "motorsports"]`.
103-
#
104-
# If you want to remove all AITags associated with the file, send a string -
105-
# "all".
106-
#
107-
# Note: The remove operation for `AITags` executes before any of the `extensions`
108-
# are processed.
109-
module RemoveAITags
110-
extend Imagekit::Internal::Type::Union
111-
112-
variant -> { Imagekit::Models::FileUpdateParams::RemoveAITags::StringArray }
113-
114-
variant const: :all
115-
116-
# @!method self.variants
117-
# @return [Array(Array<String>, Symbol, :all)]
118-
119-
# @type [Imagekit::Internal::Type::Converter]
120-
StringArray = Imagekit::Internal::Type::ArrayOf[String]
121-
end
122-
123-
class Publish < Imagekit::Internal::Type::BaseModel
124-
# @!attribute is_published
125-
# Set to `true` to publish the file. Set to `false` to unpublish the file.
126-
#
127-
# @return [Boolean]
128-
required :is_published, Imagekit::Internal::Type::Boolean, api_name: :isPublished
129-
130-
# @!attribute include_file_versions
131-
# Set to `true` to publish/unpublish all versions of the file. Set to `false` to
132-
# publish/unpublish only the current version of the file.
133-
#
134-
# @return [Boolean, nil]
135-
optional :include_file_versions, Imagekit::Internal::Type::Boolean, api_name: :includeFileVersions
136-
137-
# @!method initialize(is_published:, include_file_versions: nil)
138-
# Some parameter documentations has been truncated, see
139-
# {Imagekit::Models::FileUpdateParams::Publish} for more details.
140-
#
141-
# Configure the publication status of a file and its versions.
142-
#
143-
# @param is_published [Boolean] Set to `true` to publish the file. Set to `false` to unpublish the file.
144-
#
145-
# @param include_file_versions [Boolean] Set to `true` to publish/unpublish all versions of the file. Set to `false` to p
146-
end
14718
end
14819
end
14920
end
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# frozen_string_literal: true
2+
3+
module Imagekit
4+
module Models
5+
module UpdateFileDetailsRequest
6+
extend Imagekit::Internal::Type::Union
7+
8+
variant -> { Imagekit::UpdateFileDetailsRequest::UpdateFileDetails }
9+
10+
variant -> { Imagekit::UpdateFileDetailsRequest::ChangePublicationStatus }
11+
12+
class UpdateFileDetails < Imagekit::Internal::Type::BaseModel
13+
# @!attribute custom_coordinates
14+
# Define an important area in the image in the format `x,y,width,height` e.g.
15+
# `10,10,100,100`. Send `null` to unset this value.
16+
#
17+
# @return [String, nil]
18+
optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true
19+
20+
# @!attribute custom_metadata
21+
# A key-value data to be associated with the asset. To unset a key, send `null`
22+
# value for that key. Before setting any custom metadata on an asset you have to
23+
# create the field using custom metadata fields API.
24+
#
25+
# @return [Hash{Symbol=>Object}, nil]
26+
optional :custom_metadata,
27+
Imagekit::Internal::Type::HashOf[Imagekit::Internal::Type::Unknown],
28+
api_name: :customMetadata
29+
30+
# @!attribute description
31+
# Optional text to describe the contents of the file.
32+
#
33+
# @return [String, nil]
34+
optional :description, String
35+
36+
# @!attribute extensions
37+
# Array of extensions to be applied to the asset. Each extension can be configured
38+
# with specific parameters based on the extension type.
39+
#
40+
# @return [Array<Imagekit::Models::ExtensionItem::RemoveBg, Imagekit::Models::ExtensionItem::AIAutoDescription, Imagekit::Models::ExtensionItem::AutoTaggingExtension>, nil]
41+
optional :extensions, -> { Imagekit::Internal::Type::ArrayOf[union: Imagekit::ExtensionItem] }
42+
43+
# @!attribute remove_ai_tags
44+
# An array of AITags associated with the file that you want to remove, e.g.
45+
# `["car", "vehicle", "motorsports"]`.
46+
#
47+
# If you want to remove all AITags associated with the file, send a string -
48+
# "all".
49+
#
50+
# Note: The remove operation for `AITags` executes before any of the `extensions`
51+
# are processed.
52+
#
53+
# @return [Array<String>, Symbol, :all, nil]
54+
optional :remove_ai_tags,
55+
union: -> { Imagekit::UpdateFileDetailsRequest::UpdateFileDetails::RemoveAITags },
56+
api_name: :removeAITags
57+
58+
# @!attribute tags
59+
# An array of tags associated with the file, such as `["tag1", "tag2"]`. Send
60+
# `null` to unset all tags associated with the file.
61+
#
62+
# @return [Array<String>, nil]
63+
optional :tags, Imagekit::Internal::Type::ArrayOf[String], nil?: true
64+
65+
# @!attribute webhook_url
66+
# The final status of extensions after they have completed execution will be
67+
# delivered to this endpoint as a POST request.
68+
# [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure)
69+
# about the webhook payload structure.
70+
#
71+
# @return [String, nil]
72+
optional :webhook_url, String, api_name: :webhookUrl
73+
74+
# @!method initialize(custom_coordinates: nil, custom_metadata: nil, description: nil, extensions: nil, remove_ai_tags: nil, tags: nil, webhook_url: nil)
75+
# Some parameter documentations has been truncated, see
76+
# {Imagekit::Models::UpdateFileDetailsRequest::UpdateFileDetails} for more
77+
# details.
78+
#
79+
# @param custom_coordinates [String, nil] Define an important area in the image in the format `x,y,width,height` e.g. `10,
80+
#
81+
# @param custom_metadata [Hash{Symbol=>Object}] A key-value data to be associated with the asset. To unset a key, send `null` va
82+
#
83+
# @param description [String] Optional text to describe the contents of the file.
84+
#
85+
# @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
86+
#
87+
# @param remove_ai_tags [Array<String>, Symbol, :all] An array of AITags associated with the file that you want to remove, e.g. `["car
88+
#
89+
# @param tags [Array<String>, nil] An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `nul
90+
#
91+
# @param webhook_url [String] The final status of extensions after they have completed execution will be deliv
92+
93+
# An array of AITags associated with the file that you want to remove, e.g.
94+
# `["car", "vehicle", "motorsports"]`.
95+
#
96+
# If you want to remove all AITags associated with the file, send a string -
97+
# "all".
98+
#
99+
# Note: The remove operation for `AITags` executes before any of the `extensions`
100+
# are processed.
101+
#
102+
# @see Imagekit::Models::UpdateFileDetailsRequest::UpdateFileDetails#remove_ai_tags
103+
module RemoveAITags
104+
extend Imagekit::Internal::Type::Union
105+
106+
variant -> { Imagekit::Models::UpdateFileDetailsRequest::UpdateFileDetails::RemoveAITags::StringArray }
107+
108+
variant const: :all
109+
110+
# @!method self.variants
111+
# @return [Array(Array<String>, Symbol, :all)]
112+
113+
# @type [Imagekit::Internal::Type::Converter]
114+
StringArray = Imagekit::Internal::Type::ArrayOf[String]
115+
end
116+
end
117+
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::UpdateFileDetailsRequest::ChangePublicationStatus::Publish, nil]
123+
optional :publish, -> { Imagekit::UpdateFileDetailsRequest::ChangePublicationStatus::Publish }
124+
125+
# @!method initialize(publish: nil)
126+
# Some parameter documentations has been truncated, see
127+
# {Imagekit::Models::UpdateFileDetailsRequest::ChangePublicationStatus} for more
128+
# details.
129+
#
130+
# @param publish [Imagekit::Models::UpdateFileDetailsRequest::ChangePublicationStatus::Publish] Configure the publication status of a file and its versions.
131+
132+
# @see Imagekit::Models::UpdateFileDetailsRequest::ChangePublicationStatus#publish
133+
class Publish < Imagekit::Internal::Type::BaseModel
134+
# @!attribute is_published
135+
# Set to `true` to publish the file. Set to `false` to unpublish the file.
136+
#
137+
# @return [Boolean]
138+
required :is_published, Imagekit::Internal::Type::Boolean, api_name: :isPublished
139+
140+
# @!attribute include_file_versions
141+
# Set to `true` to publish/unpublish all versions of the file. Set to `false` to
142+
# publish/unpublish only the current version of the file.
143+
#
144+
# @return [Boolean, nil]
145+
optional :include_file_versions, Imagekit::Internal::Type::Boolean, api_name: :includeFileVersions
146+
147+
# @!method initialize(is_published:, include_file_versions: nil)
148+
# Some parameter documentations has been truncated, see
149+
# {Imagekit::Models::UpdateFileDetailsRequest::ChangePublicationStatus::Publish}
150+
# for more details.
151+
#
152+
# Configure the publication status of a file and its versions.
153+
#
154+
# @param is_published [Boolean] Set to `true` to publish the file. Set to `false` to unpublish the file.
155+
#
156+
# @param include_file_versions [Boolean] Set to `true` to publish/unpublish all versions of the file. Set to `false` to p
157+
end
158+
end
159+
160+
# @!method self.variants
161+
# @return [Array(Imagekit::Models::UpdateFileDetailsRequest::UpdateFileDetails, Imagekit::Models::UpdateFileDetailsRequest::ChangePublicationStatus)]
162+
end
163+
end
164+
end

lib/imagekit/resources/files.rb

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,24 @@ 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, custom_coordinates: nil, custom_metadata: nil, description: nil, extensions: nil, remove_ai_tags: nil, tags: nil, webhook_url: nil, publish: nil, request_options: {})
22+
# @overload update(file_id, update_file_details_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 custom_coordinates [String, nil] Define an important area in the image in the format `x,y,width,height` e.g. `10,
27-
#
28-
# @param custom_metadata [Hash{Symbol=>Object}] A key-value data to be associated with the asset. To unset a key, send `null` va
29-
#
30-
# @param description [String] Optional text to describe the contents of the file.
31-
#
32-
# @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
33-
#
34-
# @param remove_ai_tags [Array<String>, Symbol, :all] An array of AITags associated with the file that you want to remove, e.g. `["car
35-
#
36-
# @param tags [Array<String>, nil] An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `nul
37-
#
38-
# @param webhook_url [String] The final status of extensions after they have completed execution will be deliv
39-
#
40-
# @param publish [Imagekit::Models::FileUpdateParams::Publish] Configure the publication status of a file and its versions.
26+
# @param update_file_details_request [Imagekit::UpdateFileDetailsRequest]
4127
#
4228
# @param request_options [Imagekit::RequestOptions, Hash{Symbol=>Object}, nil]
4329
#
4430
# @return [Imagekit::Models::FileUpdateResponse]
4531
#
4632
# @see Imagekit::Models::FileUpdateParams
47-
def update(file_id, params = {})
33+
def update(file_id, params)
4834
parsed, options = Imagekit::FileUpdateParams.dump_request(params)
35+
case parsed
36+
in {update_file_details_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.rbi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ module Imagekit
100100

101101
UnwrapWebhookEvent = Imagekit::Models::UnwrapWebhookEvent
102102

103+
UpdateFileDetailsRequest = Imagekit::Models::UpdateFileDetailsRequest
104+
103105
UploadPostTransformErrorEvent =
104106
Imagekit::Models::UploadPostTransformErrorEvent
105107

0 commit comments

Comments
 (0)