OBP-API/FINAL_SUMMARY.md
simonredfern efc1868fd4 BREAKING CHANGE: Switch active-rate-limits endpoint to hour-based format
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.
2025-12-30 17:35:38 +01:00

3.3 KiB

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:

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:

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

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

-- Or use API to grant entitlement
INSERT INTO entitlement (user_id, role_name) 
VALUES ('user-id-here', 'CanGetCacheNamespaces');

Step 2: Call Endpoint

curl -X GET https://your-api/obp/v6.0.0/system/cache/namespaces \
  -H "Authorization: DirectLogin token=YOUR_TOKEN"

Step 3: Expected Response

{
  "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! 🚀