import { APIResource } from '../resource.js'; import { APIPromise } from '../api-promise.js'; import type { RequestOptions } from '../internal/request-options.js'; export declare class ImageUsageAnalytics extends APIResource { /** * This endpoint helps you get image analytics data like bandwidth consumption, request count, CDN hit ratio, etc. * * @param {ImageUsageAnalyticRetrieveParams} body - The request body to send. * @param {RequestOptions} [options] - Options to apply to the request, such as headers and an abort signal. * @returns {APIPromise} 200 * * @example * ```ts * const imageUsageAnalytic = await client.imageUsageAnalytics.retrieve({ * metrics: ['bandwidth_consumption'], * date_range: { * start_at: '2024-01-01', * end_at: '2024-01-01', * }, * group_by: 'daily', * }); * ``` */ retrieve(body: ImageUsageAnalyticRetrieveParams, options?: RequestOptions): APIPromise; } export interface ImageUsageAnalyticRetrieveParams { /** * Define the metric you need the data for. Supported values: `bandwidth_consumption`, `requests_count`, `transformations_count`, `bandwidth_savings`, `origin_hit_rate`, `avg_transformation_response_time`, `status_4xx`, `status_5xx`, `cdn_hit_rate`, `content_type`, `status_2xx`, `avg_response_time`, `top_assets`, `bandwidth_consumption_by_source`, and `ai_credit_usage`. */ metrics: Array<'bandwidth_consumption' | 'requests_count' | 'transformations_count' | 'bandwidth_savings' | 'origin_hit_rate' | 'avg_transformation_response_time' | 'status_4xx' | 'status_5xx' | 'cdn_hit_rate' | 'content_type' | 'status_2xx' | 'avg_response_time' | 'top_assets' | 'bandwidth_consumption_by_source' | 'ai_credit_usage'>; /** * The timeframe to get the data for. Currently we only support a maximum of 30 days between `start_at` and `end_at`. */ date_range: ImageUsageAnalyticRetrieveParams.DateRange; /** * @default daily */ group_by?: 'daily' | 'weekly' | 'monthly' | 'hourly'; filters?: ImageUsageAnalyticRetrieveParams.Filters; } export declare namespace ImageUsageAnalyticRetrieveParams { interface DateRange { /** * Date in yyyy-MM-dd format * @format date */ start_at: string; /** * Date in yyyy-MM-dd format * @format date */ end_at: string; } interface Filters { /** * Source ID */ source_id?: string; } } export interface ImageUsageAnalyticRetrieveResponse { bandwidth_consumption?: Array; requests_count?: Array; status_2xx?: Array; status_4xx?: Array; status_5xx?: Array; avg_response_time?: Array; cdn_hit_rate?: Array; transformations_count?: Array; origin_hit_rate?: Array; avg_transformation_response_time?: Array; content_type?: Array; bandwidth_savings?: Array; bandwidth_consumption_by_source?: Array; ai_credit_usage?: Array; } export declare namespace ImageUsageAnalyticRetrieveResponse { interface BandwidthConsumption { /** * Value of bandwidth consumption in bytes. */ units: number; /** * Seconds since epoch for the unit given. */ timestamp: number; } interface RequestsCount { /** * Count of requests. */ units: number; /** * Seconds since epoch for the unit given. */ timestamp: number; } interface Status2xx { /** * Value between 0 and 1 depicting percentage of 2xx requests. * @format float * @minimum 0 * @maximum 1 */ units: number; /** * Seconds since epoch for the unit given. */ timestamp: number; } interface Status4xx { /** * Value between 0 and 1 depicting percentage of 4xx requests. * @format float * @minimum 0 * @maximum 1 */ units: number; /** * Seconds since epoch for the unit given. */ timestamp: number; } interface Status5xx { /** * Value between 0 and 1 depicting percentage of 5xx requests. * @format float * @minimum 0 * @maximum 1 */ units: number; /** * Seconds since epoch for the unit given. */ timestamp: number; } interface AvgResponseTime { /** * Response time in seconds. * @format float * @minimum 0 */ units: number; /** * Seconds since epoch for the unit given. */ timestamp: number; } interface CdnHitRate { /** * Number between 0 and 1 depicting CDN hit ratio percentage. * @format float * @minimum 0 * @maximum 1 */ units: number; /** * Seconds since epoch for the unit given. */ timestamp: number; } interface TransformationsCount { /** * Number of transformations */ units: number; /** * Seconds since epoch for the unit given. */ timestamp: number; } interface OriginHitRate { /** * Number between 0 and 1 depicting Origin Cache hit ratio. * @format float * @minimum 0 * @maximum 1 */ units: number; /** * Seconds since epoch for the unit given. */ timestamp: number; } interface AvgTransformationResponseTime { /** * Seconds since epoch for the unit given. */ timestamp: number; /** * Seconds it took to fetch image from origin * @format float * @minimum 0 */ fetch_time: number; /** * Seconds it took to prepare final image and send response. * @format float */ response_time: number; } interface ContentType { /** * Total count of AVIF images delivered */ avif: number; /** * Total count of PNG images delivered */ png: number; /** * Total count of JPEG images delivered */ jpeg: number; /** * Total count of GIF images delivered */ gif: number; /** * Total count of WEBP images delivered */ webp: number; /** * Total count of JPEG-XL images delivered */ jxl: number; /** * Total count of MP4 videos delivered */ mp4: number; /** * Seconds since epoch. */ timestamp: number; } interface BandwidthSaving { /** * Number between 0 and 1 depicting bandwidth savings percentage. * @format float * @minimum 0 * @maximum 1 */ units: number; /** * Timestamp of data point in seconds since epoch. */ timestamp: number; } interface BandwidthConsumptionBySource { /** * Bandwidth usage by the source. */ bytes: number; /** * Domain name of the source. */ domain: string; } interface AICreditUsage { /** * Timestamp of data point in seconds since epoch. */ timestamp: number; /** * Background removal credits used. */ bg_removal?: number; /** * Shadow generation credits used. */ shadow_gen?: number; } } export declare namespace ImageUsageAnalytics { export { type ImageUsageAnalyticRetrieveResponse as ImageUsageAnalyticRetrieveResponse, type ImageUsageAnalyticRetrieveParams as ImageUsageAnalyticRetrieveParams, }; } //# sourceMappingURL=image-usage-analytics.d.ts.map