imagekitio 4.7.0 → 4.8.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.
@@ -12,6 +12,12 @@ module Imagekitio
12
12
  # other words, the data covers the period starting from the specified start date
13
13
  # up to, but not including, the end date.
14
14
  #
15
+ # For an agency account, the returned usage is aggregated across the agency and
16
+ # all of its child accounts that are billed to it.
17
+ #
18
+ # The response is cached for 6 hours per account, date range and requested
19
+ # metrics.
20
+ #
15
21
  # @overload get(end_date:, start_date:, request_options: {})
16
22
  #
17
23
  # @param end_date [Date] Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`.
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Imagekitio
4
+ module Resources
5
+ class Accounts
6
+ class UsageAnalytics
7
+ # Some parameter documentations has been truncated, see
8
+ # {Imagekitio::Models::Accounts::UsageAnalyticsGetParams} for more details.
9
+ #
10
+ # **Note:** This API is currently in beta.
11
+ #
12
+ # Get the account analytics data between two dates. The response covers the period
13
+ # from the start date to the end date, both dates inclusive. Both dates are
14
+ # interpreted as UTC calendar days.
15
+ #
16
+ # The returned data is scoped to the requesting account only. Unlike
17
+ # `/v1/accounts/usage`, an agency account's analytics are not aggregated across
18
+ # its child accounts.
19
+ #
20
+ # The response is cached for 5 minutes per account and date range. Use
21
+ # `generatedAt` to check how fresh the returned data is.
22
+ #
23
+ # @overload get(end_date:, start_date:, request_options: {})
24
+ #
25
+ # @param end_date [Date] Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
26
+ #
27
+ # @param start_date [Date] Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
28
+ #
29
+ # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil]
30
+ #
31
+ # @return [Imagekitio::Models::Accounts::UsageAnalyticsResponse]
32
+ #
33
+ # @see Imagekitio::Models::Accounts::UsageAnalyticsGetParams
34
+ def get(params)
35
+ parsed, options = Imagekitio::Accounts::UsageAnalyticsGetParams.dump_request(params)
36
+ query = Imagekitio::Internal::Util.encode_query_params(parsed)
37
+ @client.request(
38
+ method: :get,
39
+ path: "v1/accounts/usage-analytics",
40
+ query: query.transform_keys(end_date: "endDate", start_date: "startDate"),
41
+ model: Imagekitio::Accounts::UsageAnalyticsResponse,
42
+ options: options
43
+ )
44
+ end
45
+
46
+ # @api private
47
+ #
48
+ # @param client [Imagekitio::Client]
49
+ def initialize(client:)
50
+ @client = client
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -6,6 +6,9 @@ module Imagekitio
6
6
  # @return [Imagekitio::Resources::Accounts::Usage]
7
7
  attr_reader :usage
8
8
 
9
+ # @return [Imagekitio::Resources::Accounts::UsageAnalytics]
10
+ attr_reader :usage_analytics
11
+
9
12
  # @return [Imagekitio::Resources::Accounts::Origins]
10
13
  attr_reader :origins
11
14
 
@@ -18,6 +21,7 @@ module Imagekitio
18
21
  def initialize(client:)
19
22
  @client = client
20
23
  @usage = Imagekitio::Resources::Accounts::Usage.new(client: client)
24
+ @usage_analytics = Imagekitio::Resources::Accounts::UsageAnalytics.new(client: client)
21
25
  @origins = Imagekitio::Resources::Accounts::Origins.new(client: client)
22
26
  @url_endpoints = Imagekitio::Resources::Accounts::URLEndpoints.new(client: client)
23
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Imagekitio
4
- VERSION = "4.7.0"
4
+ VERSION = "4.8.0"
5
5
  end
data/lib/imagekitio.rb CHANGED
@@ -55,6 +55,7 @@ require_relative "imagekitio/internal/transport/pooled_net_requester"
55
55
  require_relative "imagekitio/client"
56
56
  require_relative "imagekitio/models/accounts/origin_request"
57
57
  require_relative "imagekitio/models/accounts/url_endpoint_request"
58
+ require_relative "imagekitio/models/accounts/request_bandwidth_entry"
58
59
  require_relative "imagekitio/models/base_webhook_event"
59
60
  require_relative "imagekitio/models/update_file_request"
60
61
  require_relative "imagekitio/models/file"
@@ -74,6 +75,8 @@ require_relative "imagekitio/models/accounts/url_endpoint_list_params"
74
75
  require_relative "imagekitio/models/accounts/url_endpoint_list_response"
75
76
  require_relative "imagekitio/models/accounts/url_endpoint_response"
76
77
  require_relative "imagekitio/models/accounts/url_endpoint_update_params"
78
+ require_relative "imagekitio/models/accounts/usage_analytics_get_params"
79
+ require_relative "imagekitio/models/accounts/usage_analytics_response"
77
80
  require_relative "imagekitio/models/accounts/usage_get_params"
78
81
  require_relative "imagekitio/models/accounts/usage_get_response"
79
82
  require_relative "imagekitio/models/ai_tag"
@@ -185,6 +188,7 @@ require_relative "imagekitio/resources/accounts"
185
188
  require_relative "imagekitio/resources/accounts/origins"
186
189
  require_relative "imagekitio/resources/accounts/url_endpoints"
187
190
  require_relative "imagekitio/resources/accounts/usage"
191
+ require_relative "imagekitio/resources/accounts/usage_analytics"
188
192
  require_relative "imagekitio/resources/assets"
189
193
  require_relative "imagekitio/resources/beta"
190
194
  require_relative "imagekitio/resources/beta/v2"
@@ -0,0 +1,44 @@
1
+ # typed: strong
2
+
3
+ module Imagekitio
4
+ module Models
5
+ module Accounts
6
+ class RequestBandwidthEntry < Imagekitio::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ Imagekitio::Accounts::RequestBandwidthEntry,
11
+ Imagekitio::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ # Total bandwidth used in bytes.
16
+ sig { returns(Float) }
17
+ attr_accessor :bandwidth_bytes
18
+
19
+ # Number of requests.
20
+ sig { returns(Float) }
21
+ attr_accessor :request_count
22
+
23
+ sig do
24
+ params(bandwidth_bytes: Float, request_count: Float).returns(
25
+ T.attached_class
26
+ )
27
+ end
28
+ def self.new(
29
+ # Total bandwidth used in bytes.
30
+ bandwidth_bytes:,
31
+ # Number of requests.
32
+ request_count:
33
+ )
34
+ end
35
+
36
+ sig do
37
+ override.returns({ bandwidth_bytes: Float, request_count: Float })
38
+ end
39
+ def to_hash
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,64 @@
1
+ # typed: strong
2
+
3
+ module Imagekitio
4
+ module Models
5
+ module Accounts
6
+ class UsageAnalyticsGetParams < 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::UsageAnalyticsGetParams,
14
+ Imagekitio::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ # Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
19
+ # It should be after the `startDate`. The difference between `startDate` and
20
+ # `endDate` should be less than 90 days.
21
+ sig { returns(Date) }
22
+ attr_accessor :end_date
23
+
24
+ # Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
25
+ # It should be before the `endDate`. The difference between `startDate` and
26
+ # `endDate` should be less than 90 days.
27
+ sig { returns(Date) }
28
+ attr_accessor :start_date
29
+
30
+ sig do
31
+ params(
32
+ end_date: Date,
33
+ start_date: Date,
34
+ request_options: Imagekitio::RequestOptions::OrHash
35
+ ).returns(T.attached_class)
36
+ end
37
+ def self.new(
38
+ # Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
39
+ # It should be after the `startDate`. The difference between `startDate` and
40
+ # `endDate` should be less than 90 days.
41
+ end_date:,
42
+ # Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
43
+ # It should be before the `endDate`. The difference between `startDate` and
44
+ # `endDate` should be less than 90 days.
45
+ start_date:,
46
+ request_options: {}
47
+ )
48
+ end
49
+
50
+ sig do
51
+ override.returns(
52
+ {
53
+ end_date: Date,
54
+ start_date: Date,
55
+ request_options: Imagekitio::RequestOptions
56
+ }
57
+ )
58
+ end
59
+ def to_hash
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end