-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaccountusageanalytics.go
More file actions
1014 lines (918 loc) · 39.4 KB
/
Copy pathaccountusageanalytics.go
File metadata and controls
1014 lines (918 loc) · 39.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package imagekit
import (
"context"
"net/http"
"net/url"
"slices"
"time"
"github.com/imagekit-developer/imagekit-go/v2/internal/apijson"
"github.com/imagekit-developer/imagekit-go/v2/internal/apiquery"
"github.com/imagekit-developer/imagekit-go/v2/internal/requestconfig"
"github.com/imagekit-developer/imagekit-go/v2/option"
"github.com/imagekit-developer/imagekit-go/v2/packages/respjson"
)
// AccountUsageAnalyticsService contains methods and other services that help with
// interacting with the ImageKit API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewAccountUsageAnalyticsService] method instead.
type AccountUsageAnalyticsService struct {
Options []option.RequestOption
}
// NewAccountUsageAnalyticsService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewAccountUsageAnalyticsService(opts ...option.RequestOption) (r AccountUsageAnalyticsService) {
r = AccountUsageAnalyticsService{}
r.Options = opts
return
}
// **Note:** This API is currently in beta.
//
// Get the account analytics data between two dates. The response covers the period
// from the start date to the end date, both dates inclusive. Both dates are
// interpreted as UTC calendar days.
//
// The returned data is scoped to the requesting account only. Unlike
// `/v1/accounts/usage`, an agency account's analytics are not aggregated across
// its child accounts.
//
// The response is cached for 5 minutes per account and date range. Use
// `generatedAt` to check how fresh the returned data is.
func (r *AccountUsageAnalyticsService) Get(ctx context.Context, query AccountUsageAnalyticsGetParams, opts ...option.RequestOption) (res *UsageAnalyticsResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/accounts/usage-analytics"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return res, err
}
type RequestBandwidthEntry struct {
// Total bandwidth used in bytes.
BandwidthBytes float64 `json:"bandwidthBytes" api:"required"`
// Number of requests.
RequestCount float64 `json:"requestCount" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
BandwidthBytes respjson.Field
RequestCount respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r RequestBandwidthEntry) RawJSON() string { return r.JSON.raw }
func (r *RequestBandwidthEntry) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponse struct {
// Total bandwidth, in bytes, utilized during the specified date range.
BandwidthBytes float64 `json:"bandwidthBytes" api:"required"`
// CDN traffic grouped by browser.
Browser UsageAnalyticsResponseBrowser `json:"browser" api:"required"`
// CDN cache hit, miss and error counts for the date range.
Cache UsageAnalyticsResponseCache `json:"cache" api:"required"`
// CDN traffic grouped by country.
Country UsageAnalyticsResponseCountry `json:"country" api:"required"`
// CDN traffic grouped by device and operating system (e.g. `Desktop - Apple Mac`,
// `Smartphone - Apple iPhone`).
Device UsageAnalyticsResponseDevice `json:"device" api:"required"`
// End date of the computed analytics data.
EndDate time.Time `json:"endDate" api:"required" format:"date"`
// Request count grouped by origin error reason. This covers failed origin fetches,
// such as an asset not found at origin or an origin timeout. It is not the HTTP
// status code returned to the client, see `statusCodes` for that.
ErrorReasons []UsageAnalyticsResponseErrorReason `json:"errorReasons" api:"required"`
// Raw per-extension operation counts for the date range. These are raw operation
// counts, not billable extension units. For billable usage, use the
// `/v1/accounts/usage` endpoint.
Extensions []UsageAnalyticsResponseExtension `json:"extensions" api:"required"`
// CDN traffic grouped by response `Content-Type`.
Format UsageAnalyticsResponseFormat `json:"format" api:"required"`
// Date and time when the analytics data was computed. Use this to gauge how fresh
// the returned data is. The date and time is in ISO8601 format.
GeneratedAt time.Time `json:"generatedAt" api:"required" format:"date-time"`
// Total number of requests made during the specified date range.
RequestCount float64 `json:"requestCount" api:"required"`
// Start date of the computed analytics data.
StartDate time.Time `json:"startDate" api:"required" format:"date"`
// Request count grouped by HTTP status code.
StatusCodes []UsageAnalyticsResponseStatusCode `json:"statusCodes" api:"required"`
// Top URLs that returned a 404 response.
Top404Assets []UsageAnalyticsResponseTop404Asset `json:"top404Assets" api:"required"`
// Top image assets by traffic.
TopImages UsageAnalyticsResponseTopImages `json:"topImages" api:"required"`
// Top image transformation strings by traffic.
TopImageTransforms UsageAnalyticsResponseTopImageTransforms `json:"topImageTransforms" api:"required"`
// Top non-image, non-video assets by traffic.
TopOtherAssets UsageAnalyticsResponseTopOtherAssets `json:"topOtherAssets" api:"required"`
// Top HTTP referrers by traffic.
TopReferrers UsageAnalyticsResponseTopReferrers `json:"topReferrers" api:"required"`
// Top user agents by traffic.
TopUserAgents UsageAnalyticsResponseTopUserAgents `json:"topUserAgents" api:"required"`
// Top video assets by traffic.
TopVideos UsageAnalyticsResponseTopVideos `json:"topVideos" api:"required"`
// Top video transformation strings by traffic.
TopVideoTransforms UsageAnalyticsResponseTopVideoTransforms `json:"topVideoTransforms" api:"required"`
// CDN traffic grouped by configured URL endpoint. Traffic that does not match any
// named URL endpoint pattern is grouped under `Default`.
URLEndpoints UsageAnalyticsResponseURLEndpoints `json:"urlEndpoints" api:"required"`
// Raw observed video transcode output duration, in seconds, grouped by resolution
// and codec. These are raw seconds, not billable Video Processing Units (VPU). For
// billable VPU totals, use the `/v1/accounts/usage` endpoint.
VideoProcessing []UsageAnalyticsResponseVideoProcessing `json:"videoProcessing" api:"required"`
ExtraFields map[string]any `json:"" api:"extrafields"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
BandwidthBytes respjson.Field
Browser respjson.Field
Cache respjson.Field
Country respjson.Field
Device respjson.Field
EndDate respjson.Field
ErrorReasons respjson.Field
Extensions respjson.Field
Format respjson.Field
GeneratedAt respjson.Field
RequestCount respjson.Field
StartDate respjson.Field
StatusCodes respjson.Field
Top404Assets respjson.Field
TopImages respjson.Field
TopImageTransforms respjson.Field
TopOtherAssets respjson.Field
TopReferrers respjson.Field
TopUserAgents respjson.Field
TopVideos respjson.Field
TopVideoTransforms respjson.Field
URLEndpoints respjson.Field
VideoProcessing respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponse) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// CDN traffic grouped by browser.
type UsageAnalyticsResponseBrowser struct {
// Top browsers sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseBrowserByBandwidth `json:"byBandwidth" api:"required"`
// Top browsers sorted by request count.
ByRequests []UsageAnalyticsResponseBrowserByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseBrowser) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseBrowser) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseBrowserByBandwidth struct {
// Browser name (e.g. `Chrome`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseBrowserByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseBrowserByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseBrowserByRequest struct {
// Browser name (e.g. `Chrome`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseBrowserByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseBrowserByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// CDN cache hit, miss and error counts for the date range.
type UsageAnalyticsResponseCache struct {
// Number of requests where the CDN encountered a cache error or exceeded capacity
// while serving the response.
ErrorCount float64 `json:"errorCount" api:"required"`
// Number of requests served from cache, including full hits and revalidated hits.
HitCount float64 `json:"hitCount" api:"required"`
// Number of requests that were not found in cache and had to be fetched from
// origin.
MissCount float64 `json:"missCount" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ErrorCount respjson.Field
HitCount respjson.Field
MissCount respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseCache) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseCache) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// CDN traffic grouped by country.
type UsageAnalyticsResponseCountry struct {
// Top requesting countries sorted by total bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseCountryByBandwidth `json:"byBandwidth" api:"required"`
// Top requesting countries sorted by request count.
ByRequests []UsageAnalyticsResponseCountryByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseCountry) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseCountry) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseCountryByBandwidth struct {
// ISO country code.
Code string `json:"code" api:"required"`
// Country name.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseCountryByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseCountryByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseCountryByRequest struct {
// ISO country code.
Code string `json:"code" api:"required"`
// Country name.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseCountryByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseCountryByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// CDN traffic grouped by device and operating system (e.g. `Desktop - Apple Mac`,
// `Smartphone - Apple iPhone`).
type UsageAnalyticsResponseDevice struct {
// Top device/OS combinations sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseDeviceByBandwidth `json:"byBandwidth" api:"required"`
// Top device/OS combinations sorted by request count.
ByRequests []UsageAnalyticsResponseDeviceByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseDevice) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseDevice) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseDeviceByBandwidth struct {
// Device category combined with operating system or vendor (e.g.
// `Desktop - Windows PC`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseDeviceByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseDeviceByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseDeviceByRequest struct {
// Device category combined with operating system or vendor (e.g.
// `Desktop - Windows PC`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseDeviceByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseDeviceByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseErrorReason struct {
// Description of the error reason.
Name string `json:"name" api:"required"`
// Number of requests that failed with this error reason.
RequestCount float64 `json:"requestCount" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
RequestCount respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseErrorReason) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseErrorReason) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseExtension struct {
// Extension identifier.
Name string `json:"name" api:"required"`
// Number of times this extension ran during the date range.
OperationCount float64 `json:"operationCount" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
OperationCount respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseExtension) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseExtension) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// CDN traffic grouped by response `Content-Type`.
type UsageAnalyticsResponseFormat struct {
// Top content types sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseFormatByBandwidth `json:"byBandwidth" api:"required"`
// Top content types sorted by request count.
ByRequests []UsageAnalyticsResponseFormatByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseFormat) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseFormat) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseFormatByBandwidth struct {
// MIME type (e.g. `image/webp`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseFormatByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseFormatByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseFormatByRequest struct {
// MIME type (e.g. `image/webp`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseFormatByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseFormatByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseStatusCode struct {
// HTTP status code.
Name string `json:"name" api:"required"`
// Number of requests that received this status code.
RequestCount float64 `json:"requestCount" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
RequestCount respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseStatusCode) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseStatusCode) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTop404Asset struct {
// URL that returned a 404 response.
Name string `json:"name" api:"required"`
// Number of requests to this URL that returned a 404 response.
RequestCount float64 `json:"requestCount" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
RequestCount respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTop404Asset) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTop404Asset) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Top image assets by traffic.
type UsageAnalyticsResponseTopImages struct {
// Top image assets sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseTopImagesByBandwidth `json:"byBandwidth" api:"required"`
// Top image assets sorted by request count.
ByRequests []UsageAnalyticsResponseTopImagesByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopImages) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopImages) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopImagesByBandwidth struct {
// URL of the image asset.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopImagesByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopImagesByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopImagesByRequest struct {
// URL of the image asset.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopImagesByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopImagesByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Top image transformation strings by traffic.
type UsageAnalyticsResponseTopImageTransforms struct {
// Top image transformation strings sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseTopImageTransformsByBandwidth `json:"byBandwidth" api:"required"`
// Top image transformation strings sorted by request count.
ByRequests []UsageAnalyticsResponseTopImageTransformsByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopImageTransforms) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopImageTransforms) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopImageTransformsByBandwidth struct {
// Image transformation string (e.g. `tr:w-400,h-400`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopImageTransformsByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopImageTransformsByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopImageTransformsByRequest struct {
// Image transformation string (e.g. `tr:w-400,h-400`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopImageTransformsByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopImageTransformsByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Top non-image, non-video assets by traffic.
type UsageAnalyticsResponseTopOtherAssets struct {
// Top non-image, non-video assets sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseTopOtherAssetsByBandwidth `json:"byBandwidth" api:"required"`
// Top non-image, non-video assets sorted by request count.
ByRequests []UsageAnalyticsResponseTopOtherAssetsByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopOtherAssets) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopOtherAssets) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopOtherAssetsByBandwidth struct {
// URL of the non-image, non-video asset.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopOtherAssetsByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopOtherAssetsByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopOtherAssetsByRequest struct {
// URL of the non-image, non-video asset.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopOtherAssetsByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopOtherAssetsByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Top HTTP referrers by traffic.
type UsageAnalyticsResponseTopReferrers struct {
// Top HTTP referrers sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseTopReferrersByBandwidth `json:"byBandwidth" api:"required"`
// Top HTTP referrers sorted by request count.
ByRequests []UsageAnalyticsResponseTopReferrersByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopReferrers) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopReferrers) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopReferrersByBandwidth struct {
// Referrer URL.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopReferrersByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopReferrersByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopReferrersByRequest struct {
// Referrer URL.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopReferrersByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopReferrersByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Top user agents by traffic.
type UsageAnalyticsResponseTopUserAgents struct {
// Top user agents sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseTopUserAgentsByBandwidth `json:"byBandwidth" api:"required"`
// Top user agents sorted by request count.
ByRequests []UsageAnalyticsResponseTopUserAgentsByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopUserAgents) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopUserAgents) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopUserAgentsByBandwidth struct {
// User agent string.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopUserAgentsByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopUserAgentsByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopUserAgentsByRequest struct {
// User agent string.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopUserAgentsByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopUserAgentsByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Top video assets by traffic.
type UsageAnalyticsResponseTopVideos struct {
// Top video assets sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseTopVideosByBandwidth `json:"byBandwidth" api:"required"`
// Top video assets sorted by request count.
ByRequests []UsageAnalyticsResponseTopVideosByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopVideos) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopVideos) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopVideosByBandwidth struct {
// URL of the video asset.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopVideosByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopVideosByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopVideosByRequest struct {
// Full URL of the video asset (e.g. `https://ik.imagekit.io/demo/clip.mp4`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopVideosByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopVideosByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Top video transformation strings by traffic.
type UsageAnalyticsResponseTopVideoTransforms struct {
// Top video transformation strings sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseTopVideoTransformsByBandwidth `json:"byBandwidth" api:"required"`
// Top video transformation strings sorted by request count.
ByRequests []UsageAnalyticsResponseTopVideoTransformsByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopVideoTransforms) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopVideoTransforms) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopVideoTransformsByBandwidth struct {
// Video transformation string (e.g. `tr:h-720,f-mp4`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopVideoTransformsByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopVideoTransformsByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseTopVideoTransformsByRequest struct {
// Video transformation string (e.g. `tr:h-720,f-mp4`).
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseTopVideoTransformsByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseTopVideoTransformsByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// CDN traffic grouped by configured URL endpoint. Traffic that does not match any
// named URL endpoint pattern is grouped under `Default`.
type UsageAnalyticsResponseURLEndpoints struct {
// Top URL endpoints sorted by bandwidth utilized.
ByBandwidth []UsageAnalyticsResponseURLEndpointsByBandwidth `json:"byBandwidth" api:"required"`
// Top URL endpoints sorted by request count.
ByRequests []UsageAnalyticsResponseURLEndpointsByRequest `json:"byRequests" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ByBandwidth respjson.Field
ByRequests respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseURLEndpoints) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseURLEndpoints) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseURLEndpointsByBandwidth struct {
// URL endpoint name, or `Default` for traffic that does not match a named
// endpoint.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseURLEndpointsByBandwidth) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseURLEndpointsByBandwidth) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseURLEndpointsByRequest struct {
// URL endpoint name, or `Default` for traffic that does not match a named
// endpoint.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
RequestBandwidthEntry
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseURLEndpointsByRequest) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseURLEndpointsByRequest) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type UsageAnalyticsResponseVideoProcessing struct {
// Video codec used for the output (e.g. `h264`, `av1`).
Codec string `json:"codec" api:"required"`
// Total output duration, in seconds, for this resolution and codec combination.
DurationSeconds float64 `json:"durationSeconds" api:"required"`
// Output resolution tier (e.g. `SD`, `HD`, `4K`).
Resolution string `json:"resolution" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Codec respjson.Field
DurationSeconds respjson.Field
Resolution respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r UsageAnalyticsResponseVideoProcessing) RawJSON() string { return r.JSON.raw }
func (r *UsageAnalyticsResponseVideoProcessing) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type AccountUsageAnalyticsGetParams struct {
// Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
// It should be after the `startDate`. The difference between `startDate` and
// `endDate` should be less than 90 days.
EndDate time.Time `query:"endDate" api:"required" format:"date" json:"-"`
// Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.