imagekitio 4.11.0 → 4.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/README.md +28 -1
  4. data/lib/imagekitio/client.rb +4 -0
  5. data/lib/imagekitio/internal/tag_cursor.rb +86 -0
  6. data/lib/imagekitio/models/accounts/contract_get_params.rb +16 -0
  7. data/lib/imagekitio/models/accounts/contract_get_response.rb +82 -0
  8. data/lib/imagekitio/models/accounts/contract_units.rb +42 -0
  9. data/lib/imagekitio/models/accounts/url_endpoint_request.rb +17 -1
  10. data/lib/imagekitio/models/accounts/url_endpoint_response.rb +17 -1
  11. data/lib/imagekitio/models/tag.rb +52 -0
  12. data/lib/imagekitio/models/tag_list_params.rb +143 -0
  13. data/lib/imagekitio/models.rb +4 -0
  14. data/lib/imagekitio/resources/accounts/contract.rb +47 -0
  15. data/lib/imagekitio/resources/accounts.rb +4 -0
  16. data/lib/imagekitio/resources/tags.rb +65 -0
  17. data/lib/imagekitio/version.rb +1 -1
  18. data/lib/imagekitio.rb +8 -0
  19. data/rbi/imagekitio/client.rbi +3 -0
  20. data/rbi/imagekitio/internal/tag_cursor.rbi +22 -0
  21. data/rbi/imagekitio/models/accounts/contract_get_params.rbi +34 -0
  22. data/rbi/imagekitio/models/accounts/contract_get_response.rbi +126 -0
  23. data/rbi/imagekitio/models/accounts/contract_units.rbi +66 -0
  24. data/rbi/imagekitio/models/accounts/url_endpoint_request.rbi +19 -1
  25. data/rbi/imagekitio/models/accounts/url_endpoint_response.rbi +19 -1
  26. data/rbi/imagekitio/models/tag.rbi +71 -0
  27. data/rbi/imagekitio/models/tag_list_params.rbi +236 -0
  28. data/rbi/imagekitio/models.rbi +4 -0
  29. data/rbi/imagekitio/resources/accounts/contract.rbi +36 -0
  30. data/rbi/imagekitio/resources/accounts.rbi +3 -0
  31. data/rbi/imagekitio/resources/tags.rbi +74 -0
  32. data/sig/imagekitio/client.rbs +2 -0
  33. data/sig/imagekitio/internal/tag_cursor.rbs +13 -0
  34. data/sig/imagekitio/models/accounts/contract_get_params.rbs +17 -0
  35. data/sig/imagekitio/models/accounts/contract_get_response.rbs +73 -0
  36. data/sig/imagekitio/models/accounts/contract_units.rbs +37 -0
  37. data/sig/imagekitio/models/accounts/url_endpoint_request.rbs +12 -2
  38. data/sig/imagekitio/models/accounts/url_endpoint_response.rbs +12 -2
  39. data/sig/imagekitio/models/tag.rbs +30 -0
  40. data/sig/imagekitio/models/tag_list_params.rbs +114 -0
  41. data/sig/imagekitio/models.rbs +4 -0
  42. data/sig/imagekitio/resources/accounts/contract.rbs +13 -0
  43. data/sig/imagekitio/resources/accounts.rbs +2 -0
  44. data/sig/imagekitio/resources/tags.rbs +18 -0
  45. metadata +26 -2
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Imagekitio
4
+ module Resources
5
+ class Tags
6
+ # Some parameter documentations has been truncated, see
7
+ # {Imagekitio::Models::TagListParams} for more details.
8
+ #
9
+ # This API lists the distinct tags in use across your media library, with the
10
+ # number of assets each tag is applied to and when it was last used. Tags are
11
+ # matched case-insensitively, so `Summer` and `summer` are one entry: `name` is
12
+ # the lowercased form and `label` is the spelling that was used most recently.
13
+ #
14
+ # Use `tagSource` and `fileType` to list only the tags in use on matching assets.
15
+ # `lastUsedAt` and the `ASC_LAST_USED` / `DESC_LAST_USED` sorts follow those
16
+ # filters, while `assetCount` always counts every asset carrying the tag. Use
17
+ # `search` or `prefix` to narrow the listing and `cursor` to page through it.
18
+ #
19
+ # Tag counts are updated asynchronously. Changes to a file's tags usually appear
20
+ # in this list within about a minute, but can take longer during heavy tagging
21
+ # activity, so a tag you just added or removed may not be reflected immediately.
22
+ #
23
+ # @overload list(cursor: nil, file_type: nil, limit: nil, prefix: nil, search: nil, sort: nil, tag_source: nil, request_options: {})
24
+ #
25
+ # @param cursor [String] The `nextCursor` value from the previous response, to fetch the next page. A cur
26
+ #
27
+ # @param file_type [Symbol, Imagekitio::Models::TagListParams::FileType] Filter tags by the type of asset they are applied to.
28
+ #
29
+ # @param limit [Integer] The maximum number of tags to return in response.
30
+ #
31
+ # @param prefix [String] Only return tags that begin with this value. Matching is case-insensitive.
32
+ #
33
+ # @param search [String] Only return tags that contain this text. Every word in the value must appear in
34
+ #
35
+ # @param sort [Symbol, Imagekitio::Models::TagListParams::Sort] Sort the results.
36
+ #
37
+ # @param tag_source [Symbol, Imagekitio::Models::TagListParams::TagSource] Filter tags by who added them.
38
+ #
39
+ # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil]
40
+ #
41
+ # @return [Imagekitio::Internal::TagCursor<Imagekitio::Models::Tag>]
42
+ #
43
+ # @see Imagekitio::Models::TagListParams
44
+ def list(params = {})
45
+ parsed, options = Imagekitio::TagListParams.dump_request(params)
46
+ query = Imagekitio::Internal::Util.encode_query_params(parsed)
47
+ @client.request(
48
+ method: :get,
49
+ path: "v1/tags",
50
+ query: query.transform_keys(file_type: "fileType", tag_source: "tagSource"),
51
+ page: Imagekitio::Internal::TagCursor,
52
+ model: Imagekitio::Tag,
53
+ options: options
54
+ )
55
+ end
56
+
57
+ # @api private
58
+ #
59
+ # @param client [Imagekitio::Client]
60
+ def initialize(client:)
61
+ @client = client
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Imagekitio
4
- VERSION = "4.11.0"
4
+ VERSION = "4.12.0"
5
5
  end
data/lib/imagekitio.rb CHANGED
@@ -53,6 +53,7 @@ require_relative "imagekitio/errors"
53
53
  require_relative "imagekitio/internal/transport/base_client"
54
54
  require_relative "imagekitio/internal/transport/pooled_net_requester"
55
55
  require_relative "imagekitio/client"
56
+ require_relative "imagekitio/internal/tag_cursor"
56
57
  require_relative "imagekitio/models/accounts/origin_request"
57
58
  require_relative "imagekitio/models/accounts/url_endpoint_request"
58
59
  require_relative "imagekitio/models/accounts/request_bandwidth_entry"
@@ -61,6 +62,9 @@ require_relative "imagekitio/models/update_file_request"
61
62
  require_relative "imagekitio/models/file"
62
63
  require_relative "imagekitio/models/src_options"
63
64
  require_relative "imagekitio/models/base_overlay"
65
+ require_relative "imagekitio/models/accounts/contract_get_params"
66
+ require_relative "imagekitio/models/accounts/contract_get_response"
67
+ require_relative "imagekitio/models/accounts/contract_units"
64
68
  require_relative "imagekitio/models/accounts/origin_create_params"
65
69
  require_relative "imagekitio/models/accounts/origin_delete_params"
66
70
  require_relative "imagekitio/models/accounts/origin_get_params"
@@ -179,6 +183,8 @@ require_relative "imagekitio/models/solid_color_overlay_transformation"
179
183
  require_relative "imagekitio/models/streaming_resolution"
180
184
  require_relative "imagekitio/models/subtitle_overlay"
181
185
  require_relative "imagekitio/models/subtitle_overlay_transformation"
186
+ require_relative "imagekitio/models/tag"
187
+ require_relative "imagekitio/models/tag_list_params"
182
188
  require_relative "imagekitio/models/text_overlay"
183
189
  require_relative "imagekitio/models/text_overlay_transformation"
184
190
  require_relative "imagekitio/models/transformation"
@@ -198,6 +204,7 @@ require_relative "imagekitio/models/webhook_unsafe_unwrap_params"
198
204
  require_relative "imagekitio/models/webhook_unwrap_params"
199
205
  require_relative "imagekitio/models"
200
206
  require_relative "imagekitio/resources/accounts"
207
+ require_relative "imagekitio/resources/accounts/contract"
201
208
  require_relative "imagekitio/resources/accounts/origins"
202
209
  require_relative "imagekitio/resources/accounts/url_endpoints"
203
210
  require_relative "imagekitio/resources/accounts/usage"
@@ -218,5 +225,6 @@ require_relative "imagekitio/resources/folders"
218
225
  require_relative "imagekitio/resources/folders/job"
219
226
  require_relative "imagekitio/resources/named_transformations"
220
227
  require_relative "imagekitio/resources/saved_extensions"
228
+ require_relative "imagekitio/resources/tags"
221
229
  require_relative "imagekitio/resources/webhooks"
222
230
  require_relative "imagekitio/helpers/helper"
@@ -42,6 +42,9 @@ module Imagekitio
42
42
  sig { returns(Imagekitio::Resources::Assets) }
43
43
  attr_reader :assets
44
44
 
45
+ sig { returns(Imagekitio::Resources::Tags) }
46
+ attr_reader :tags
47
+
45
48
  sig { returns(Imagekitio::Resources::Cache) }
46
49
  attr_reader :cache
47
50
 
@@ -0,0 +1,22 @@
1
+ # typed: strong
2
+
3
+ module Imagekitio
4
+ module Internal
5
+ class TagCursor
6
+ include Imagekitio::Internal::Type::BasePage
7
+
8
+ Elem = type_member
9
+
10
+ sig { returns(T.nilable(T::Array[Elem])) }
11
+ attr_accessor :tags
12
+
13
+ sig { returns(T.nilable(String)) }
14
+ attr_accessor :next_cursor
15
+
16
+ # @api private
17
+ sig { returns(String) }
18
+ def inspect
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,34 @@
1
+ # typed: strong
2
+
3
+ module Imagekitio
4
+ module Models
5
+ module Accounts
6
+ class ContractGetParams < Imagekitio::Internal::Type::BaseModel
7
+ extend Imagekitio::Internal::Type::RequestParameters::Converter
8
+ include Imagekitio::Internal::Type::RequestParameters
9
+
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Imagekitio::Accounts::ContractGetParams,
14
+ Imagekitio::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ sig do
19
+ params(request_options: Imagekitio::RequestOptions::OrHash).returns(
20
+ T.attached_class
21
+ )
22
+ end
23
+ def self.new(request_options: {})
24
+ end
25
+
26
+ sig do
27
+ override.returns({ request_options: Imagekitio::RequestOptions })
28
+ end
29
+ def to_hash
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,126 @@
1
+ # typed: strong
2
+
3
+ module Imagekitio
4
+ module Models
5
+ module Accounts
6
+ class ContractGetResponse < Imagekitio::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ Imagekitio::Models::Accounts::ContractGetResponse,
11
+ Imagekitio::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ # Whether the account has an active contract. The other fields are present only
16
+ # when it does.
17
+ sig { returns(T::Boolean) }
18
+ attr_accessor :has_contract
19
+
20
+ # When `consumed` was last computed. `null` if it has not been computed for the
21
+ # contract yet; `consumed` is then all zeros.
22
+ sig { returns(T.nilable(Time)) }
23
+ attr_accessor :as_of
24
+
25
+ # Usage consumed in the current contract term. For an agency account, this
26
+ # includes the child accounts billed to it.
27
+ sig { returns(T.nilable(Imagekitio::Accounts::ContractUnits)) }
28
+ attr_reader :consumed
29
+
30
+ sig do
31
+ params(consumed: Imagekitio::Accounts::ContractUnits::OrHash).void
32
+ end
33
+ attr_writer :consumed
34
+
35
+ # Length of each contract term in months.
36
+ sig { returns(T.nilable(Integer)) }
37
+ attr_reader :contract_months
38
+
39
+ sig { params(contract_months: Integer).void }
40
+ attr_writer :contract_months
41
+
42
+ # End date of the current contract term.
43
+ sig { returns(T.nilable(Date)) }
44
+ attr_reader :effective_contract_end_date
45
+
46
+ sig { params(effective_contract_end_date: Date).void }
47
+ attr_writer :effective_contract_end_date
48
+
49
+ # Start date of the current contract term. It moves forward when the contract
50
+ # renews.
51
+ sig { returns(T.nilable(Date)) }
52
+ attr_reader :effective_contract_start_date
53
+
54
+ sig { params(effective_contract_start_date: Date).void }
55
+ attr_writer :effective_contract_start_date
56
+
57
+ # Start date of the first contract term.
58
+ sig { returns(T.nilable(Date)) }
59
+ attr_reader :original_contract_start_date
60
+
61
+ sig { params(original_contract_start_date: Date).void }
62
+ attr_writer :original_contract_start_date
63
+
64
+ # Usage included in the current contract term.
65
+ sig { returns(T.nilable(Imagekitio::Accounts::ContractUnits)) }
66
+ attr_reader :quota
67
+
68
+ sig { params(quota: Imagekitio::Accounts::ContractUnits::OrHash).void }
69
+ attr_writer :quota
70
+
71
+ sig do
72
+ params(
73
+ has_contract: T::Boolean,
74
+ as_of: T.nilable(Time),
75
+ consumed: Imagekitio::Accounts::ContractUnits::OrHash,
76
+ contract_months: Integer,
77
+ effective_contract_end_date: Date,
78
+ effective_contract_start_date: Date,
79
+ original_contract_start_date: Date,
80
+ quota: Imagekitio::Accounts::ContractUnits::OrHash
81
+ ).returns(T.attached_class)
82
+ end
83
+ def self.new(
84
+ # Whether the account has an active contract. The other fields are present only
85
+ # when it does.
86
+ has_contract:,
87
+ # When `consumed` was last computed. `null` if it has not been computed for the
88
+ # contract yet; `consumed` is then all zeros.
89
+ as_of: nil,
90
+ # Usage consumed in the current contract term. For an agency account, this
91
+ # includes the child accounts billed to it.
92
+ consumed: nil,
93
+ # Length of each contract term in months.
94
+ contract_months: nil,
95
+ # End date of the current contract term.
96
+ effective_contract_end_date: nil,
97
+ # Start date of the current contract term. It moves forward when the contract
98
+ # renews.
99
+ effective_contract_start_date: nil,
100
+ # Start date of the first contract term.
101
+ original_contract_start_date: nil,
102
+ # Usage included in the current contract term.
103
+ quota: nil
104
+ )
105
+ end
106
+
107
+ sig do
108
+ override.returns(
109
+ {
110
+ has_contract: T::Boolean,
111
+ as_of: T.nilable(Time),
112
+ consumed: Imagekitio::Accounts::ContractUnits,
113
+ contract_months: Integer,
114
+ effective_contract_end_date: Date,
115
+ effective_contract_start_date: Date,
116
+ original_contract_start_date: Date,
117
+ quota: Imagekitio::Accounts::ContractUnits
118
+ }
119
+ )
120
+ end
121
+ def to_hash
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,66 @@
1
+ # typed: strong
2
+
3
+ module Imagekitio
4
+ module Models
5
+ module Accounts
6
+ class ContractUnits < Imagekitio::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ Imagekitio::Accounts::ContractUnits,
11
+ Imagekitio::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ # Bandwidth in bytes.
16
+ sig { returns(Integer) }
17
+ attr_accessor :bandwidth_bytes
18
+
19
+ # Number of extension units.
20
+ sig { returns(Integer) }
21
+ attr_accessor :extension_units_count
22
+
23
+ # Number of purge cache requests.
24
+ sig { returns(Integer) }
25
+ attr_accessor :purge_cache_requests
26
+
27
+ # Number of video processing units.
28
+ sig { returns(Integer) }
29
+ attr_accessor :video_processing_units_count
30
+
31
+ sig do
32
+ params(
33
+ bandwidth_bytes: Integer,
34
+ extension_units_count: Integer,
35
+ purge_cache_requests: Integer,
36
+ video_processing_units_count: Integer
37
+ ).returns(T.attached_class)
38
+ end
39
+ def self.new(
40
+ # Bandwidth in bytes.
41
+ bandwidth_bytes:,
42
+ # Number of extension units.
43
+ extension_units_count:,
44
+ # Number of purge cache requests.
45
+ purge_cache_requests:,
46
+ # Number of video processing units.
47
+ video_processing_units_count:
48
+ )
49
+ end
50
+
51
+ sig do
52
+ override.returns(
53
+ {
54
+ bandwidth_bytes: Integer,
55
+ extension_units_count: Integer,
56
+ purge_cache_requests: Integer,
57
+ video_processing_units_count: Integer
58
+ }
59
+ )
60
+ end
61
+ def to_hash
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -138,22 +138,40 @@ module Imagekitio
138
138
  sig { params(preserve_asset_delivery_types: T::Boolean).void }
139
139
  attr_writer :preserve_asset_delivery_types
140
140
 
141
+ # Whether to always rewrite Cloudinary layers to the improved ImageKit layer
142
+ # specification (`l-image`, `l-text`, ..., `l-end`). When `false` or omitted, the
143
+ # improved specification is used only for transformations that require it.
144
+ sig { returns(T.nilable(T::Boolean)) }
145
+ attr_reader :use_improved_layer_spec
146
+
147
+ sig { params(use_improved_layer_spec: T::Boolean).void }
148
+ attr_writer :use_improved_layer_spec
149
+
141
150
  sig do
142
151
  params(
143
152
  preserve_asset_delivery_types: T::Boolean,
153
+ use_improved_layer_spec: T::Boolean,
144
154
  type: Symbol
145
155
  ).returns(T.attached_class)
146
156
  end
147
157
  def self.new(
148
158
  # Whether to preserve `<asset_type>/<delivery_type>` in the rewritten URL.
149
159
  preserve_asset_delivery_types: nil,
160
+ # Whether to always rewrite Cloudinary layers to the improved ImageKit layer
161
+ # specification (`l-image`, `l-text`, ..., `l-end`). When `false` or omitted, the
162
+ # improved specification is used only for transformations that require it.
163
+ use_improved_layer_spec: nil,
150
164
  type: :CLOUDINARY
151
165
  )
152
166
  end
153
167
 
154
168
  sig do
155
169
  override.returns(
156
- { type: Symbol, preserve_asset_delivery_types: T::Boolean }
170
+ {
171
+ type: Symbol,
172
+ preserve_asset_delivery_types: T::Boolean,
173
+ use_improved_layer_spec: T::Boolean
174
+ }
157
175
  )
158
176
  end
159
177
  def to_hash
@@ -133,22 +133,40 @@ module Imagekitio
133
133
  sig { returns(Symbol) }
134
134
  attr_accessor :type
135
135
 
136
+ # Whether to always rewrite Cloudinary layers to the improved ImageKit layer
137
+ # specification (`l-image`, `l-text`, ..., `l-end`). When `false` or omitted, the
138
+ # improved specification is used only for transformations that require it.
139
+ sig { returns(T.nilable(T::Boolean)) }
140
+ attr_reader :use_improved_layer_spec
141
+
142
+ sig { params(use_improved_layer_spec: T::Boolean).void }
143
+ attr_writer :use_improved_layer_spec
144
+
136
145
  sig do
137
146
  params(
138
147
  preserve_asset_delivery_types: T::Boolean,
148
+ use_improved_layer_spec: T::Boolean,
139
149
  type: Symbol
140
150
  ).returns(T.attached_class)
141
151
  end
142
152
  def self.new(
143
153
  # Whether to preserve `<asset_type>/<delivery_type>` in the rewritten URL.
144
154
  preserve_asset_delivery_types:,
155
+ # Whether to always rewrite Cloudinary layers to the improved ImageKit layer
156
+ # specification (`l-image`, `l-text`, ..., `l-end`). When `false` or omitted, the
157
+ # improved specification is used only for transformations that require it.
158
+ use_improved_layer_spec: nil,
145
159
  type: :CLOUDINARY
146
160
  )
147
161
  end
148
162
 
149
163
  sig do
150
164
  override.returns(
151
- { preserve_asset_delivery_types: T::Boolean, type: Symbol }
165
+ {
166
+ preserve_asset_delivery_types: T::Boolean,
167
+ type: Symbol,
168
+ use_improved_layer_spec: T::Boolean
169
+ }
152
170
  )
153
171
  end
154
172
  def to_hash
@@ -0,0 +1,71 @@
1
+ # typed: strong
2
+
3
+ module Imagekitio
4
+ module Models
5
+ class Tag < Imagekitio::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias { T.any(Imagekitio::Tag, Imagekitio::Internal::AnyHash) }
8
+
9
+ # The number of assets carrying the tag, counted across both tag sources
10
+ # (user-generated tags and AI-generated tags) and all file types regardless of the
11
+ # request's filters.
12
+ sig { returns(Integer) }
13
+ attr_accessor :asset_count
14
+
15
+ # The tag as it was spelled when it was last applied to any asset. Use it for
16
+ # display.
17
+ sig { returns(String) }
18
+ attr_accessor :label
19
+
20
+ # When the tag was last applied to an asset matching the `tagSource` and
21
+ # `fileType` filters of the request, in ISO 8601 format.
22
+ sig { returns(Time) }
23
+ attr_accessor :last_used_at
24
+
25
+ # The tag in lowercase. Tags are case-insensitive, so this is the unique key of
26
+ # the tag within your account.
27
+ sig { returns(String) }
28
+ attr_accessor :name
29
+
30
+ # A tag in use in your media library, aggregated case-insensitively across the
31
+ # assets that carry it.
32
+ sig do
33
+ params(
34
+ asset_count: Integer,
35
+ label: String,
36
+ last_used_at: Time,
37
+ name: String
38
+ ).returns(T.attached_class)
39
+ end
40
+ def self.new(
41
+ # The number of assets carrying the tag, counted across both tag sources
42
+ # (user-generated tags and AI-generated tags) and all file types regardless of the
43
+ # request's filters.
44
+ asset_count:,
45
+ # The tag as it was spelled when it was last applied to any asset. Use it for
46
+ # display.
47
+ label:,
48
+ # When the tag was last applied to an asset matching the `tagSource` and
49
+ # `fileType` filters of the request, in ISO 8601 format.
50
+ last_used_at:,
51
+ # The tag in lowercase. Tags are case-insensitive, so this is the unique key of
52
+ # the tag within your account.
53
+ name:
54
+ )
55
+ end
56
+
57
+ sig do
58
+ override.returns(
59
+ {
60
+ asset_count: Integer,
61
+ label: String,
62
+ last_used_at: Time,
63
+ name: String
64
+ }
65
+ )
66
+ end
67
+ def to_hash
68
+ end
69
+ end
70
+ end
71
+ end