|
| 1 | +# Endpoint Capabilities API |
| 2 | + |
| 3 | +This document describes the new endpoint capabilities API that provides a unified view of all REST endpoints and Verb methods available in the Sentrius system. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The capabilities API allows AI agents, Python agents, and other systems to dynamically discover what operations are available across the entire Sentrius platform. It scans both: |
| 8 | + |
| 9 | +- **REST API endpoints** from Spring controllers with `@LimitAccess` annotations |
| 10 | +- **Verb methods** from AI agent classes with `@Verb` annotations |
| 11 | + |
| 12 | +## API Endpoints |
| 13 | + |
| 14 | +All endpoints are secured with `@LimitAccess` and require appropriate authentication. |
| 15 | + |
| 16 | +### Get All Endpoints |
| 17 | + |
| 18 | +``` |
| 19 | +GET /api/v1/capabilities/endpoints |
| 20 | +``` |
| 21 | + |
| 22 | +Returns all available endpoints (both REST and Verb) with optional filtering: |
| 23 | + |
| 24 | +**Query Parameters:** |
| 25 | +- `type` (optional): Filter by type (`REST` or `VERB`) |
| 26 | +- `requiresAuth` (optional): Filter by authentication requirement (`true` or `false`) |
| 27 | + |
| 28 | +**Example Response:** |
| 29 | +```json |
| 30 | +[ |
| 31 | + { |
| 32 | + "name": "listusers", |
| 33 | + "description": "Returns list of users", |
| 34 | + "type": "REST", |
| 35 | + "httpMethod": "GET", |
| 36 | + "path": "/api/v1/users/list", |
| 37 | + "className": "io.sentrius.sso.controllers.api.UserApiController", |
| 38 | + "methodName": "listusers", |
| 39 | + "requiresAuthentication": true, |
| 40 | + "accessLimitations": { |
| 41 | + "hasLimitAccess": true, |
| 42 | + "userAccess": ["CAN_VIEW_USERS"] |
| 43 | + }, |
| 44 | + "parameters": [...] |
| 45 | + }, |
| 46 | + { |
| 47 | + "name": "assess_ztat_requests", |
| 48 | + "description": "Analyzes ztats requests according to the by prompting the LLM", |
| 49 | + "type": "VERB", |
| 50 | + "className": "io.sentrius.agent.analysis.agents.verbs.AgentVerbs", |
| 51 | + "methodName": "analyzeAtatRequests", |
| 52 | + "requiresTokenManagement": true, |
| 53 | + "metadata": { |
| 54 | + "isAiCallable": true, |
| 55 | + "outputInterpreter": "...", |
| 56 | + "inputInterpreter": "..." |
| 57 | + } |
| 58 | + } |
| 59 | +] |
| 60 | +``` |
| 61 | + |
| 62 | +### Get REST Endpoints Only |
| 63 | + |
| 64 | +``` |
| 65 | +GET /api/v1/capabilities/rest |
| 66 | +``` |
| 67 | + |
| 68 | +Returns only REST API endpoints from Spring controllers. |
| 69 | + |
| 70 | +### Get Verb Methods Only |
| 71 | + |
| 72 | +``` |
| 73 | +GET /api/v1/capabilities/verbs |
| 74 | +``` |
| 75 | + |
| 76 | +Returns only Verb methods available to AI agents. |
| 77 | + |
| 78 | +### Refresh Cache |
| 79 | + |
| 80 | +``` |
| 81 | +GET /api/v1/capabilities/refresh |
| 82 | +``` |
| 83 | + |
| 84 | +Forces a refresh of the endpoint cache. Useful during development or after deploying new capabilities. |
| 85 | + |
| 86 | +**Requires:** `CAN_MANAGE_APPLICATION` access level. |
| 87 | + |
| 88 | +## Data Model |
| 89 | + |
| 90 | +### EndpointDescriptor |
| 91 | + |
| 92 | +| Field | Type | Description | |
| 93 | +|-------|------|-------------| |
| 94 | +| `name` | String | Endpoint/verb name | |
| 95 | +| `description` | String | Human-readable description | |
| 96 | +| `type` | String | Either "REST" or "VERB" | |
| 97 | +| `httpMethod` | String | HTTP method (GET, POST, etc.) - REST only | |
| 98 | +| `path` | String | URL path - REST only | |
| 99 | +| `className` | String | Java class containing the method | |
| 100 | +| `methodName` | String | Java method name | |
| 101 | +| `parameters` | List | Parameter descriptors | |
| 102 | +| `accessLimitations` | Object | Access control information | |
| 103 | +| `requiresAuthentication` | Boolean | Whether authentication is required | |
| 104 | +| `requiresTokenManagement` | Boolean | Whether token management is needed | |
| 105 | +| `returnType` | Class | Method return type | |
| 106 | +| `metadata` | Map | Additional metadata (mainly for Verbs) | |
| 107 | + |
| 108 | +### AccessLimitations |
| 109 | + |
| 110 | +Extracted from `@LimitAccess` annotations: |
| 111 | + |
| 112 | +| Field | Type | Description | |
| 113 | +|-------|------|-------------| |
| 114 | +| `hasLimitAccess` | Boolean | Whether @LimitAccess annotation is present | |
| 115 | +| `userAccess` | Array | Required user access levels | |
| 116 | +| `applicationAccess` | Array | Required application access levels | |
| 117 | +| `sshAccess` | Array | Required SSH access levels | |
| 118 | +| `allowedIdentityTypes` | Array | Allowed identity types | |
| 119 | +| `endpointThreat` | String | Endpoint threat level | |
| 120 | + |
| 121 | +## Usage Examples |
| 122 | + |
| 123 | +### For AI Agents |
| 124 | + |
| 125 | +AI agents can discover available verbs: |
| 126 | + |
| 127 | +```bash |
| 128 | +curl -H "Authorization: Bearer <token>" \ |
| 129 | + "/api/v1/capabilities/verbs" |
| 130 | +``` |
| 131 | + |
| 132 | +### For Python Agents |
| 133 | + |
| 134 | +Python agents can discover all capabilities: |
| 135 | + |
| 136 | +```python |
| 137 | +import requests |
| 138 | + |
| 139 | +response = requests.get( |
| 140 | + "https://sentrius.example.com/api/v1/capabilities/endpoints", |
| 141 | + headers={"Authorization": f"Bearer {token}"} |
| 142 | +) |
| 143 | + |
| 144 | +capabilities = response.json() |
| 145 | +for cap in capabilities: |
| 146 | + print(f"{cap['type']}: {cap['name']} - {cap['description']}") |
| 147 | +``` |
| 148 | + |
| 149 | +### For Dynamic Documentation |
| 150 | + |
| 151 | +Generate API documentation dynamically: |
| 152 | + |
| 153 | +```bash |
| 154 | +curl -H "Authorization: Bearer <token>" \ |
| 155 | + "/api/v1/capabilities/rest?requiresAuth=true" |
| 156 | +``` |
| 157 | + |
| 158 | +## Integration |
| 159 | + |
| 160 | +### VerbRegistry Integration |
| 161 | + |
| 162 | +The `VerbRegistry` class now provides additional methods: |
| 163 | + |
| 164 | +```java |
| 165 | +@Autowired |
| 166 | +private VerbRegistry verbRegistry; |
| 167 | + |
| 168 | +// Get all verb descriptors |
| 169 | +List<EndpointDescriptor> allVerbs = verbRegistry.getVerbDescriptors(); |
| 170 | + |
| 171 | +// Get only AI-callable verbs |
| 172 | +List<EndpointDescriptor> aiVerbs = verbRegistry.getAiCallableVerbDescriptors(); |
| 173 | +``` |
| 174 | + |
| 175 | +### Custom Scanning |
| 176 | + |
| 177 | +The `EndpointScanningService` can be used directly: |
| 178 | + |
| 179 | +```java |
| 180 | +@Autowired |
| 181 | +private EndpointScanningService scanningService; |
| 182 | + |
| 183 | +// Get all endpoints |
| 184 | +List<EndpointDescriptor> endpoints = scanningService.getAllEndpoints(); |
| 185 | + |
| 186 | +// Force refresh |
| 187 | +scanningService.refreshEndpoints(); |
| 188 | +``` |
| 189 | + |
| 190 | +## Performance |
| 191 | + |
| 192 | +- Results are cached for performance |
| 193 | +- Cache is automatically populated on first request |
| 194 | +- Cache can be manually refreshed via the `/refresh` endpoint |
| 195 | +- Scanning happens at startup and on-demand |
| 196 | + |
| 197 | +## Security |
| 198 | + |
| 199 | +- All endpoints require authentication |
| 200 | +- Access limitations from `@LimitAccess` are preserved and exposed |
| 201 | +- Endpoint access follows the same security model as the underlying APIs |
| 202 | +- The refresh endpoint requires `CAN_MANAGE_APPLICATION` permission |
| 203 | + |
| 204 | +## Development Notes |
| 205 | + |
| 206 | +- The scanning covers packages starting with `io.sentrius` |
| 207 | +- New controllers and verbs are automatically discovered |
| 208 | +- Changes require cache refresh or application restart to be visible |
| 209 | +- Comprehensive logging is available for debugging scanning issues |
0 commit comments