1+ import { PROXY_URL } from '@/modules/axios/axios.client' ;
12import { ListQueryParams } from '@/resources/schemas' ;
23import {
34 ComMiloapisQuotaV1Alpha1AllowanceBucket ,
@@ -7,16 +8,25 @@ import {
78 deleteQuotaMiloapisComV1Alpha1NamespacedAllowanceBucket ,
89 deleteQuotaMiloapisComV1Alpha1NamespacedResourceClaim ,
910 deleteQuotaMiloapisComV1Alpha1NamespacedResourceGrant ,
10- listQuotaMiloapisComV1Alpha1AllowanceBucketForAllNamespaces ,
11- listQuotaMiloapisComV1Alpha1ResourceClaimForAllNamespaces ,
12- listQuotaMiloapisComV1Alpha1ResourceGrantForAllNamespaces ,
11+ listQuotaMiloapisComV1Alpha1NamespacedAllowanceBucket ,
12+ listQuotaMiloapisComV1Alpha1NamespacedResourceClaim ,
13+ listQuotaMiloapisComV1Alpha1NamespacedResourceGrant ,
1314 listQuotaMiloapisComV1Alpha1ResourceRegistration ,
1415 readQuotaMiloapisComV1Alpha1NamespacedAllowanceBucket ,
1516 readQuotaMiloapisComV1Alpha1NamespacedResourceClaim ,
1617 readQuotaMiloapisComV1Alpha1NamespacedResourceGrant ,
1718 readQuotaMiloapisComV1Alpha1ResourceRegistration ,
1819} from '@openapi/quota.miloapis.com/v1alpha1' ;
1920
21+ const MILO_SYSTEM_NAMESPACE = 'milo-system' ;
22+
23+ // Helper to build control-plane baseURL
24+ const getProjectControlPlaneBaseURL = ( projectName : string ) =>
25+ `${ PROXY_URL } /apis/resourcemanager.miloapis.com/v1alpha1/projects/${ projectName } /control-plane` ;
26+
27+ const getOrgControlPlaneBaseURL = ( orgName : string ) =>
28+ `${ PROXY_URL } /apis/resourcemanager.miloapis.com/v1alpha1/organizations/${ orgName } /control-plane` ;
29+
2030// ------------------------
2131// ResourceRegistrations
2232// ------------------------
@@ -45,9 +55,12 @@ export const quotaRegistrationDetailQuery = async (name: string) => {
4555// ResourceGrants
4656// ------------------------
4757export const quotaGrantListQuery = async (
48- params ?: ListQueryParams & { fieldSelector ?: string ; labelSelector ?: string }
58+ namespace : string ,
59+ params ?: ListQueryParams & { fieldSelector ?: string ; labelSelector ?: string ; baseURL ?: string }
4960) => {
50- const response = await listQuotaMiloapisComV1Alpha1ResourceGrantForAllNamespaces ( {
61+ const response = await listQuotaMiloapisComV1Alpha1NamespacedResourceGrant ( {
62+ ...( params ?. baseURL && { baseURL : params . baseURL } ) ,
63+ path : { namespace } ,
5164 query : {
5265 limit : params ?. limit ,
5366 continue : params ?. cursor ,
@@ -80,8 +93,9 @@ export const orgQuotaGrantListQuery = (
8093 if ( params ?. resourceType )
8194 fieldSelectorParts . push ( `spec.allowances.resourceType=${ params . resourceType } ` ) ;
8295
83- return quotaGrantListQuery ( {
96+ return quotaGrantListQuery ( orgName , {
8497 ...params ,
98+ baseURL : getOrgControlPlaneBaseURL ( orgName ) ,
8599 fieldSelector : fieldSelectorParts . join ( ',' ) ,
86100 } ) ;
87101} ;
@@ -97,8 +111,9 @@ export const projectQuotaGrantListQuery = (
97111 if ( params ?. resourceType )
98112 fieldSelectorParts . push ( `spec.allowances.resourceType=${ params . resourceType } ` ) ;
99113
100- return quotaGrantListQuery ( {
114+ return quotaGrantListQuery ( MILO_SYSTEM_NAMESPACE , {
101115 ...params ,
116+ baseURL : getProjectControlPlaneBaseURL ( projectName ) ,
102117 fieldSelector : fieldSelectorParts . join ( ',' ) ,
103118 } ) ;
104119} ;
@@ -132,9 +147,12 @@ export const quotaGrantDeleteMutation = async (name: string, namespace: string =
132147// AllowanceBuckets
133148// ------------------------
134149export const quotaBucketListQuery = async (
135- params ?: ListQueryParams & { fieldSelector ?: string ; labelSelector ?: string }
150+ namespace : string ,
151+ params ?: ListQueryParams & { fieldSelector ?: string ; labelSelector ?: string ; baseURL ?: string }
136152) => {
137- const response = await listQuotaMiloapisComV1Alpha1AllowanceBucketForAllNamespaces ( {
153+ const response = await listQuotaMiloapisComV1Alpha1NamespacedAllowanceBucket ( {
154+ ...( params ?. baseURL && { baseURL : params . baseURL } ) ,
155+ path : { namespace } ,
138156 query : {
139157 limit : params ?. limit ,
140158 continue : params ?. cursor ,
@@ -166,8 +184,9 @@ export const orgQuotaBucketListQuery = (
166184 ] ;
167185 if ( params ?. resourceType ) fieldSelectorParts . push ( `spec.resourceType=${ params . resourceType } ` ) ;
168186
169- return quotaBucketListQuery ( {
187+ return quotaBucketListQuery ( orgName , {
170188 ...params ,
189+ baseURL : getOrgControlPlaneBaseURL ( orgName ) ,
171190 fieldSelector : fieldSelectorParts . join ( ',' ) ,
172191 } ) ;
173192} ;
@@ -182,8 +201,9 @@ export const projectQuotaBucketListQuery = (
182201 ] ;
183202 if ( params ?. resourceType ) fieldSelectorParts . push ( `spec.resourceType=${ params . resourceType } ` ) ;
184203
185- return quotaBucketListQuery ( {
204+ return quotaBucketListQuery ( MILO_SYSTEM_NAMESPACE , {
186205 ...params ,
206+ baseURL : getProjectControlPlaneBaseURL ( projectName ) ,
187207 fieldSelector : fieldSelectorParts . join ( ',' ) ,
188208 } ) ;
189209} ;
@@ -202,9 +222,12 @@ export const quotaBucketDeleteMutation = async (
202222// ResourceClaims
203223// ------------------------
204224export const quotaClaimListQuery = async (
205- params ?: ListQueryParams & { fieldSelector ?: string ; labelSelector ?: string }
225+ namespace : string ,
226+ params ?: ListQueryParams & { fieldSelector ?: string ; labelSelector ?: string ; baseURL ?: string }
206227) => {
207- const response = await listQuotaMiloapisComV1Alpha1ResourceClaimForAllNamespaces ( {
228+ const response = await listQuotaMiloapisComV1Alpha1NamespacedResourceClaim ( {
229+ ...( params ?. baseURL && { baseURL : params . baseURL } ) ,
230+ path : { namespace } ,
208231 query : {
209232 limit : params ?. limit ,
210233 continue : params ?. cursor ,
@@ -233,8 +256,9 @@ export const orgQuotaClaimListQuery = (
233256 // Filter by request resourceType if provided (server-side may ignore; client can post-filter)
234257 if ( params ?. resourceType ) parts . push ( `spec.requests.resourceType=${ params . resourceType } ` ) ;
235258
236- return quotaClaimListQuery ( {
259+ return quotaClaimListQuery ( orgName , {
237260 ...params ,
261+ baseURL : getOrgControlPlaneBaseURL ( orgName ) ,
238262 fieldSelector : parts . join ( ',' ) ,
239263 } ) ;
240264} ;
@@ -246,8 +270,9 @@ export const projectQuotaClaimListQuery = (
246270 const parts = [ `spec.consumerRef.kind=Project` , `spec.consumerRef.name=${ projectName } ` ] ;
247271 if ( params ?. resourceType ) parts . push ( `spec.requests.resourceType=${ params . resourceType } ` ) ;
248272
249- return quotaClaimListQuery ( {
273+ return quotaClaimListQuery ( MILO_SYSTEM_NAMESPACE , {
250274 ...params ,
275+ baseURL : getProjectControlPlaneBaseURL ( projectName ) ,
251276 fieldSelector : parts . join ( ',' ) ,
252277 } ) ;
253278} ;
0 commit comments