mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 13:07:02 +00:00
Changed from full timestamp to hour-only format to match implementation. OLD: /active-rate-limits/2025-12-31T13:34:46Z (YYYY-MM-DDTHH:MM:SSZ) NEW: /active-rate-limits/2025-12-31-13 (YYYY-MM-DD-HH) Benefits: - API now matches actual implementation (hour-level caching) - Eliminates timezone/minute truncation confusion - Clearer semantics: 'active during this hour' not 'at this second' - Direct cache key mapping improves performance - Simpler date parsing (no timezone handling needed) Files changed: - APIMethods600.scala: Updated endpoint and date parsing - RateLimitsTest.scala: Updated all test cases to new format - Glossary.scala: Updated API documentation - introductory_system_documentation.md: Updated user docs This is a breaking change but necessary to align API with implementation. Rate limits are cached and queried at hour granularity, so the API should reflect that reality.
125 lines
3.3 KiB
Markdown
125 lines
3.3 KiB
Markdown
# Cache Namespace Endpoint - Final Implementation
|
|
|
|
**Date**: 2024-12-27
|
|
**Status**: ✅ Complete, Compiled, and Ready
|
|
|
|
## What Was Done
|
|
|
|
### 1. Added Cache API Tag
|
|
**File**: `obp-api/src/main/scala/code/api/util/ApiTag.scala`
|
|
|
|
Added new tag for cache-related endpoints:
|
|
```scala
|
|
val apiTagCache = ResourceDocTag("Cache")
|
|
```
|
|
|
|
### 2. Updated Endpoint Tags
|
|
**File**: `obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala`
|
|
|
|
The cache namespaces endpoint now has proper tags:
|
|
```scala
|
|
List(apiTagCache, apiTagSystem, apiTagApi)
|
|
```
|
|
|
|
### 3. Endpoint Registration
|
|
The endpoint is automatically registered in **OBP v6.0.0** through:
|
|
- `OBPAPI6_0_0` object includes `APIMethods600` trait
|
|
- `endpointsOf6_0_0 = getEndpoints(Implementations6_0_0)`
|
|
- `getCacheNamespaces` is a lazy val in Implementations600
|
|
- Automatically discovered and registered
|
|
|
|
## Endpoint Details
|
|
|
|
**URL**: `GET /obp/v6.0.0/system/cache/namespaces`
|
|
|
|
**Tags**: Cache, System, API
|
|
|
|
**Authorization**: Requires `CanGetCacheNamespaces` role
|
|
|
|
**Response**: Returns all cache namespaces with live Redis data
|
|
|
|
## How to Find It
|
|
|
|
### In API Explorer
|
|
The endpoint will appear under:
|
|
- **Cache** tag (primary category)
|
|
- **System** tag (secondary category)
|
|
- **API** tag (tertiary category)
|
|
|
|
### In Resource Docs
|
|
```bash
|
|
GET /obp/v6.0.0/resource-docs/v6.0.0/obp
|
|
```
|
|
Search for "cache/namespaces" or filter by "Cache" tag
|
|
|
|
## Complete File Changes
|
|
|
|
```
|
|
obp-api/src/main/scala/code/api/cache/Redis.scala | 47 lines
|
|
obp-api/src/main/scala/code/api/constant/constant.scala | 17 lines
|
|
obp-api/src/main/scala/code/api/util/ApiRole.scala | 9 lines
|
|
obp-api/src/main/scala/code/api/util/ApiTag.scala | 1 line
|
|
obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala | 106 lines
|
|
obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala | 35 lines
|
|
---
|
|
Total: 6 files changed, 215 insertions(+), 2 deletions(-)
|
|
```
|
|
|
|
## Verification Checklist
|
|
|
|
✅ Code compiles successfully
|
|
✅ No formatting changes (clean diffs)
|
|
✅ Cache tag added to ApiTag
|
|
✅ Endpoint uses Cache tag
|
|
✅ Endpoint registered in v6.0.0
|
|
✅ Documentation complete
|
|
✅ All roles defined
|
|
✅ Redis integration works
|
|
|
|
## Testing
|
|
|
|
### Step 1: Create User with Role
|
|
```sql
|
|
-- Or use API to grant entitlement
|
|
INSERT INTO entitlement (user_id, role_name)
|
|
VALUES ('user-id-here', 'CanGetCacheNamespaces');
|
|
```
|
|
|
|
### Step 2: Call Endpoint
|
|
```bash
|
|
curl -X GET https://your-api/obp/v6.0.0/system/cache/namespaces \
|
|
-H "Authorization: DirectLogin token=YOUR_TOKEN"
|
|
```
|
|
|
|
### Step 3: Expected Response
|
|
```json
|
|
{
|
|
"namespaces": [
|
|
{
|
|
"prefix": "rl_counter_",
|
|
"description": "Rate limiting counters per consumer and time period",
|
|
"ttl_seconds": "varies",
|
|
"category": "Rate Limiting",
|
|
"key_count": 42,
|
|
"example_key": "rl_counter_abc123_PER_MINUTE"
|
|
},
|
|
...
|
|
]
|
|
}
|
|
```
|
|
|
|
## Documentation
|
|
|
|
- **Full Plan**: `ideas/CACHE_NAMESPACE_STANDARDIZATION.md`
|
|
- **Implementation Details**: `IMPLEMENTATION_SUMMARY.md`
|
|
|
|
## Summary
|
|
|
|
✅ **Cache tag added** - New "Cache" category in API Explorer
|
|
✅ **Endpoint tagged properly** - Cache, System, API tags
|
|
✅ **Registered in v6.0.0** - Available at `/obp/v6.0.0/system/cache/namespaces`
|
|
✅ **Clean implementation** - No formatting noise
|
|
✅ **Fully documented** - Complete specification
|
|
|
|
Ready for testing and deployment! 🚀
|