Resource Quotas
The ResourceQuotaController at /api/v1/tenants/{tenantId}/quotas manages per-tenant resource limits and usage tracking. Quotas are automatically created based on the tenant's tier during provisioning.
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /quotas/defaults | Create default quotas for a tenant |
POST | /quotas | Create or update a quota |
GET | /quotas | Get all quotas |
GET | /quotas/{resourceType} | Get specific quota |
GET | /quotas/summary | Get quota summary with usage stats |
POST | /quotas/usage | Record resource usage |
GET | /quotas/{resourceType}/check | Check quota availability |
GET | /quotas/{resourceType}/usage/history | Get usage history |
GET | /quotas/{resourceType}/usage/trend | Get usage trend |
Creating Default Quotas
During provisioning, default quotas are created based on the tenant's tier:
curl -X POST http://localhost:8082/api/v1/tenants/{tenantId}/quotas/defaults \
-H "Authorization: Bearer $TOKEN"Response (201 Created): Returns a list of ResourceQuota objects with tier-appropriate limits.
Resource Types
The ResourceType enum defines the quotable resources:
| Resource Type | Description | Unit |
|---|---|---|
| CPU | Compute cores | Millicores |
| MEMORY | RAM allocation | MiB |
| STORAGE | Persistent storage | GiB |
| API_CALLS | API request limit | Requests/min |
| CONNECTIONS | Database connections | Count |
| USERS | Active user accounts | Count |
| QUERIES | BI/AI query executions | Queries/day |
| PIPELINES | Data pipeline slots | Count |
| MODELS | ML model deployments | Count |
Creating or Updating a Quota
curl -X POST http://localhost:8082/api/v1/tenants/{tenantId}/quotas \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"resourceType": "API_CALLS",
"softLimit": 4000,
"hardLimit": 5000,
"unit": "requests/min",
"enforcementMode": "HARD"
}'Recording Usage
Services report their resource consumption via the usage endpoint:
curl -X POST http://localhost:8082/api/v1/tenants/{tenantId}/quotas/usage \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"resourceType": "API_CALLS",
"amount": 150,
"source": "ai-service"
}'Successful Response (200 OK):
{
"accepted": true,
"resourceType": "API_CALLS",
"currentUsage": 3250,
"softLimit": 4000,
"hardLimit": 5000,
"utilizationPercent": 65.0,
"warningIssued": false
}Quota Exceeded Response (403 Forbidden):
{
"accepted": false,
"resourceType": "API_CALLS",
"currentUsage": 5000,
"softLimit": 4000,
"hardLimit": 5000,
"utilizationPercent": 100.0,
"message": "Hard quota exceeded for API_CALLS"
}Checking Quota Availability
Before consuming a resource, services can check if the request would exceed the quota:
curl "http://localhost:8082/api/v1/tenants/{tenantId}/quotas/API_CALLS/check?amount=500" \
-H "Authorization: Bearer $TOKEN"Returns a QuotaCheckResult with availability status.
Quota Summary
curl http://localhost:8082/api/v1/tenants/{tenantId}/quotas/summary \
-H "Authorization: Bearer $TOKEN"Returns a QuotaSummary with all quotas, current usage, and utilization percentages.
Usage History
Retrieve historical usage data for a specific resource type:
curl "http://localhost:8082/api/v1/tenants/{tenantId}/quotas/API_CALLS/usage/history?start=2026-02-01T00:00:00Z&end=2026-02-12T00:00:00Z" \
-H "Authorization: Bearer $TOKEN"Defaults to the last 7 days if start and end are not provided.
Usage Trend
Get aggregated usage trend data:
curl "http://localhost:8082/api/v1/tenants/{tenantId}/quotas/STORAGE/usage/trend?interval=day" \
-H "Authorization: Bearer $TOKEN"Parameters:
start: Start time (ISO-8601), defaults to last 30 daysend: End time (ISO-8601), defaults to nowinterval: Aggregation interval (hour,day,week), defaults today
Source Files
| File | Path |
|---|---|
| Controller | control-plane/tenant-service/src/main/java/com/matih/tenant/controller/ResourceQuotaController.java |
| Service | control-plane/tenant-service/src/main/java/com/matih/tenant/service/ResourceQuotaService.java |
| Quota Entity | control-plane/tenant-service/src/main/java/com/matih/tenant/entity/ResourceQuota.java |
| Usage Entity | control-plane/tenant-service/src/main/java/com/matih/tenant/entity/ResourceUsage.java |