11import type { ObjectStorageEndpointTypes } from 'src/object-storage' ;
22import type { Region } from 'src/regions' ;
33
4- export enum QuotaResourceMetrics {
5- BUCKET = 'bucket' ,
6- BYTE = 'byte' ,
7- BYTE_PER_SECOND = 'byte_per_second' ,
8- CLUSTER = 'cluster' ,
9- CPU = 'CPU' ,
10- GPU = 'GPU' ,
11- OBJECT = 'object' ,
12- REQUEST = 'request' ,
13- VPU = 'VPU' ,
14- }
4+ export type LinodeQuotaResourceMetric = 'CPU' | 'GPU' | 'VPU' ;
5+ export type LkeQuotaResourceMetric = 'cluster' ;
6+ export type ObjectStorageEndpointQuotaResourceMetric =
7+ | 'bucket'
8+ | 'byte'
9+ | 'byte_per_second'
10+ | 'object'
11+ | 'request' ;
12+ export type ObjectStorageGlobalQuotaResourceMetric = 'key' ;
1513
16- /**
17- * A Quota is a service used limit that is rated based on service metrics such
18- * as vCPUs used, instances or storage size.
19- */
20- export interface Quota {
14+ interface QuotaCommon < T > {
2115 /**
2216 * Longer explanatory description for the quota.
2317 */
2418 description : string ;
2519
26- /**
27- * The OBJ endpoint type to which this limit applies.
28- *
29- * For OBJ limits only.
30- */
31- endpoint_type ?: ObjectStorageEndpointTypes ;
32-
33- /**
34- * Sets usage column to be n/a when value is false.
35- */
36- has_usage ?: boolean ;
37-
3820 /**
3921 * A unique identifier for the quota.
4022 */
@@ -52,31 +34,80 @@ export interface Quota {
5234 quota_name : string ;
5335
5436 /**
55- * Customer facing id describing the quota .
37+ * The unit of measurement for this service limit .
5638 */
57- quota_type : string ;
39+ resource_metric : T ;
40+ }
5841
42+ interface QuotaCommonWithRegionApplied < T > extends QuotaCommon < T > {
5943 /**
6044 * The region slug to which this limit applies.
6145 *
6246 * OBJ limits are applied by endpoint, not region.
6347 * This below really just is a `string` type but being verbose helps with reading comprehension.
6448 */
65- region_applied ?: 'global' | Region [ 'id' ] ;
49+ region_applied : 'global' | Region [ 'id' ] ;
50+ }
6651
52+ interface QuotaCommonWithUsage < T > extends QuotaCommon < T > {
6753 /**
68- * The unit of measurement for this service limit.
54+ * Determines whether usage information is provided for this quota.
55+ */
56+ has_usage : boolean ;
57+ }
58+
59+ export type LinodeQuota =
60+ QuotaCommonWithRegionApplied < LinodeQuotaResourceMetric > ;
61+
62+ export type LkeQuota = QuotaCommonWithRegionApplied < LkeQuotaResourceMetric > ;
63+
64+ export interface ObjectStorageGlobalQuota
65+ extends QuotaCommon < ObjectStorageGlobalQuotaResourceMetric > {
66+ /**
67+ * Represents the quota type.
68+ */
69+ quota_type : 'keys' ;
70+ }
71+
72+ export interface ObjectStorageEndpointQuota
73+ extends QuotaCommonWithUsage < ObjectStorageEndpointQuotaResourceMetric > {
74+ /**
75+ * The OBJ endpoint type to which this limit applies.
76+ *
77+ */
78+ endpoint_type : ObjectStorageEndpointTypes ;
79+
80+ /**
81+ * Represents the quota type.
6982 */
70- resource_metric : QuotaResourceMetrics ;
83+ quota_type :
84+ | 'obj-buckets'
85+ | 'obj-bytes'
86+ | 'obj-objects'
87+ | 'obj-per-ip-concurrent-requests'
88+ | 'obj-per-ip-egress-throughput'
89+ | 'obj-per-ip-ingress-throughput'
90+ | 'obj-total-concurrent-requests'
91+ | 'obj-total-egress-throughput'
92+ | 'obj-total-ingress-throughput' ;
7193
7294 /**
7395 * The S3 endpoint URL to which this limit applies.
7496 *
75- * For OBJ limits only.
7697 */
77- s3_endpoint ? : string ;
98+ s3_endpoint : string ;
7899}
79100
101+ /**
102+ * A Quota is a service used limit that is rated based on service metrics such
103+ * as vCPUs used, instances or storage size.
104+ */
105+ export type Quota =
106+ | LinodeQuota
107+ | LkeQuota
108+ | ObjectStorageEndpointQuota
109+ | ObjectStorageGlobalQuota ;
110+
80111/**
81112 * A usage limit for a given Quota based on service metrics such
82113 * as vCPUs, instances or storage size.
@@ -97,10 +128,8 @@ export interface QuotaUsage {
97128 usage : null | number ;
98129}
99130
100- export const quotaTypes = {
101- linode : 'Linodes' ,
102- lke : 'Kubernetes' ,
103- 'object-storage' : 'Object Storage' ,
104- } as const ;
105-
106- export type QuotaType = keyof typeof quotaTypes ;
131+ /**
132+ * Represents the type of service for a given quota, e.g. Linodes, Object Storage, etc.
133+ * The type must match the service part of the quota endpoint paths.
134+ */
135+ export type QuotaServiceType = 'linode' | 'lke' | 'object-storage' ;
0 commit comments