11import type { ObjectStorageEndpointTypes } from 'src/object-storage' ;
22import type { Region } from 'src/regions' ;
33
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' ;
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+ }
1315
14- interface QuotaCommon < T > {
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 {
1521 /**
1622 * Longer explanatory description for the quota.
1723 */
1824 description : string ;
1925
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+
2038 /**
2139 * A unique identifier for the quota.
2240 */
@@ -34,80 +52,31 @@ interface QuotaCommon<T> {
3452 quota_name : string ;
3553
3654 /**
37- * The unit of measurement for this service limit .
55+ * Customer facing id describing the quota .
3856 */
39- resource_metric : T ;
40- }
57+ quota_type : string ;
4158
42- interface QuotaCommonWithRegionApplied < T > extends QuotaCommon < T > {
4359 /**
4460 * The region slug to which this limit applies.
4561 *
4662 * OBJ limits are applied by endpoint, not region.
4763 * This below really just is a `string` type but being verbose helps with reading comprehension.
4864 */
49- region_applied : 'global' | Region [ 'id' ] ;
50- }
51-
52- interface QuotaCommonWithUsage < T > extends QuotaCommon < T > {
53- /**
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 ;
65+ region_applied ?: 'global' | Region [ 'id' ] ;
7966
8067 /**
81- * Represents the quota type .
68+ * The unit of measurement for this service limit .
8269 */
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' ;
70+ resource_metric : QuotaResourceMetrics ;
9371
9472 /**
9573 * The S3 endpoint URL to which this limit applies.
9674 *
75+ * For OBJ limits only.
9776 */
98- s3_endpoint : string ;
77+ s3_endpoint ? : string ;
9978}
10079
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-
11180/**
11281 * A usage limit for a given Quota based on service metrics such
11382 * as vCPUs, instances or storage size.
@@ -128,8 +97,10 @@ export interface QuotaUsage {
12897 usage : null | number ;
12998}
13099
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' ;
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 ;
0 commit comments