|
| 1 | +# PuppetDB and Puppet Server API Endpoints Analysis |
| 2 | + |
| 3 | +This document provides a comprehensive list of all PuppetDB and Puppet Server API endpoints used in the Pabawi codebase, including where they are used and their purpose. |
| 4 | + |
| 5 | +## PuppetDB API Endpoints |
| 6 | + |
| 7 | +### Core Query Endpoints |
| 8 | + |
| 9 | +#### `/pdb/query/v4/nodes` |
| 10 | +- **Used in**: `PuppetDBService.getInventory()` |
| 11 | +- **Purpose**: Retrieve list of all nodes known to PuppetDB |
| 12 | +- **Method**: GET with PQL query parameter |
| 13 | +- **Query Example**: `["=", "certname", "node1.example.com"]` |
| 14 | +- **Location**: `backend/src/integrations/puppetdb/PuppetDBService.ts:271` |
| 15 | + |
| 16 | +#### `/pdb/query/v4/facts` |
| 17 | +- **Used in**: `PuppetDBService.getNodeFacts()` |
| 18 | +- **Purpose**: Retrieve facts for a specific node |
| 19 | +- **Method**: GET with PQL query parameter |
| 20 | +- **Query Example**: `["=", "certname", "node1.example.com"]` |
| 21 | +- **Location**: `backend/src/integrations/puppetdb/PuppetDBService.ts:334` |
| 22 | + |
| 23 | +#### `/pdb/query/v4/reports` |
| 24 | +- **Used in**: `PuppetDBService.getNodeReports()`, `PuppetDBService.getReport()` |
| 25 | +- **Purpose**: Retrieve Puppet run reports for nodes |
| 26 | +- **Method**: GET with PQL query and order_by parameters |
| 27 | +- **Query Example**: `["=", "certname", "node1.example.com"]` |
| 28 | +- **Parameters**: `limit`, `order_by: '[{"field": "producer_timestamp", "order": "desc"}]'` |
| 29 | +- **Location**: `backend/src/integrations/puppetdb/PuppetDBService.ts:456` |
| 30 | + |
| 31 | +#### `/pdb/query/v4/reports/{hash}/metrics` |
| 32 | +- **Used in**: `PuppetDBService.getNodeReports()` (via href references) |
| 33 | +- **Purpose**: Retrieve detailed metrics for a specific report |
| 34 | +- **Method**: GET |
| 35 | +- **Note**: Called when reports contain metrics href references instead of embedded data |
| 36 | +- **Location**: `backend/src/integrations/puppetdb/PuppetDBService.ts:502` |
| 37 | + |
| 38 | +#### `/pdb/query/v4/catalogs` |
| 39 | +- **Used in**: `PuppetDBService.getNodeCatalog()` |
| 40 | +- **Purpose**: Retrieve compiled catalog for a node |
| 41 | +- **Method**: GET with PQL query parameter |
| 42 | +- **Query Example**: `["=", "certname", "node1.example.com"]` |
| 43 | +- **Location**: `backend/src/integrations/puppetdb/PuppetDBService.ts:612` |
| 44 | + |
| 45 | +#### `/pdb/query/v4/resources` |
| 46 | +- **Used in**: `PuppetDBService.getCatalogResources()`, Integration routes |
| 47 | +- **Purpose**: Retrieve managed resources for a node |
| 48 | +- **Method**: GET with PQL query parameter |
| 49 | +- **Query Example**: `["=", "certname", "node1.example.com"]` |
| 50 | +- **Location**: `backend/src/integrations/puppetdb/PuppetDBService.ts:695` |
| 51 | + |
| 52 | +#### `/pdb/query/v4/events` |
| 53 | +- **Used in**: `PuppetDBService.getNodeEvents()` |
| 54 | +- **Purpose**: Retrieve events (resource changes) for a node |
| 55 | +- **Method**: GET with PQL query and filtering parameters |
| 56 | +- **Query Example**: `["and", ["=", "certname", "node1.example.com"], ["=", "status", "success"]]` |
| 57 | +- **Parameters**: `limit`, `order_by: '[{"field": "timestamp", "order": "desc"}]'` |
| 58 | +- **Location**: `backend/src/integrations/puppetdb/PuppetDBService.ts:750` |
| 59 | + |
| 60 | +### Status and Admin Endpoints |
| 61 | + |
| 62 | +#### `/status/v1/services/puppetdb-status` |
| 63 | +- **Used in**: `PuppetDBService.performHealthCheck()` |
| 64 | +- **Purpose**: Health check to verify PuppetDB connectivity |
| 65 | +- **Method**: GET |
| 66 | +- **Location**: `backend/src/integrations/puppetdb/PuppetDBService.ts:189` |
| 67 | + |
| 68 | +#### `/pdb/admin/v1/archive` |
| 69 | +- **Used in**: Integration routes, Frontend PuppetDBAdmin component |
| 70 | +- **Purpose**: Retrieve PuppetDB archive information |
| 71 | +- **Method**: GET |
| 72 | +- **Frontend**: `frontend/src/components/PuppetDBAdmin.svelte:32` |
| 73 | +- **Backend**: `backend/src/routes/integrations.ts:1311` |
| 74 | + |
| 75 | +#### `/pdb/admin/v1/summary-stats` |
| 76 | +- **Used in**: Integration routes, Frontend PuppetDBAdmin component |
| 77 | +- **Purpose**: Retrieve PuppetDB summary statistics (resource-intensive) |
| 78 | +- **Method**: GET |
| 79 | +- **Warning**: Can be resource-intensive on PuppetDB |
| 80 | +- **Frontend**: `frontend/src/components/PuppetDBAdmin.svelte:67` |
| 81 | +- **Backend**: `backend/src/routes/integrations.ts:1383` |
| 82 | + |
| 83 | +## Puppet Server API Endpoints |
| 84 | + |
| 85 | +### Certificate Authority (CA) Endpoints |
| 86 | + |
| 87 | +#### `/puppet-ca/v1/certificate_statuses` |
| 88 | +- **Used in**: `PuppetserverClient.getCertificates()`, `PuppetserverService.getInventory()` |
| 89 | +- **Purpose**: Retrieve all certificates with optional status filter |
| 90 | +- **Method**: GET |
| 91 | +- **Parameters**: `state` (optional: 'signed', 'requested', 'revoked') |
| 92 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:175` |
| 93 | + |
| 94 | +#### `/puppet-ca/v1/certificate_status/{certname}` |
| 95 | +- **Used in**: `PuppetserverClient.getCertificate()`, `PuppetserverClient.signCertificate()`, `PuppetserverClient.revokeCertificate()` |
| 96 | +- **Purpose**: Get, sign, or revoke a specific certificate |
| 97 | +- **Methods**: GET (retrieve), PUT (sign/revoke) |
| 98 | +- **Body for PUT**: `{"desired_state": "signed"}` or `{"desired_state": "revoked"}` |
| 99 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:200, 217, 233` |
| 100 | + |
| 101 | +### Node Information Endpoints |
| 102 | + |
| 103 | +#### `/puppet/v3/status/{certname}` |
| 104 | +- **Used in**: `PuppetserverClient.getStatus()`, `PuppetserverService.getNodeStatus()` |
| 105 | +- **Purpose**: Retrieve node status information (last check-in, environment, etc.) |
| 106 | +- **Method**: GET |
| 107 | +- **Note**: Returns null if node hasn't checked in yet |
| 108 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:260` |
| 109 | + |
| 110 | +#### `/puppet/v3/facts/{certname}` |
| 111 | +- **Used in**: `PuppetserverClient.getFacts()`, `PuppetserverService.getNodeFacts()` |
| 112 | +- **Purpose**: Retrieve facts for a specific node |
| 113 | +- **Method**: GET |
| 114 | +- **Note**: Returns null if node hasn't submitted facts yet |
| 115 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:380` |
| 116 | + |
| 117 | +#### `/puppet/v3/catalog/{certname}` |
| 118 | +- **Used in**: `PuppetserverClient.compileCatalog()`, `PuppetserverService.compileCatalog()` |
| 119 | +- **Purpose**: Compile a catalog for a node in a specific environment |
| 120 | +- **Method**: POST |
| 121 | +- **Parameters**: `environment` (query parameter) |
| 122 | +- **Body**: Optional facts data for compilation |
| 123 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:330` |
| 124 | + |
| 125 | +### Environment Management Endpoints |
| 126 | + |
| 127 | +#### `/puppet/v3/environments` |
| 128 | +- **Used in**: `PuppetserverClient.getEnvironments()`, `PuppetserverService.listEnvironments()` |
| 129 | +- **Purpose**: Retrieve list of available environments |
| 130 | +- **Method**: GET |
| 131 | +- **Note**: May return array or object format depending on Puppet Server version |
| 132 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:430` |
| 133 | + |
| 134 | +#### `/puppet/v3/environment/{name}` |
| 135 | +- **Used in**: `PuppetserverClient.getEnvironment()`, `PuppetserverService.getEnvironment()` |
| 136 | +- **Purpose**: Retrieve details for a specific environment |
| 137 | +- **Method**: GET |
| 138 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:480` |
| 139 | + |
| 140 | +#### `/puppet-admin-api/v1/environment-cache` |
| 141 | +- **Used in**: `PuppetserverClient.deployEnvironment()`, `PuppetserverService.deployEnvironment()` |
| 142 | +- **Purpose**: Deploy/refresh an environment |
| 143 | +- **Method**: POST |
| 144 | +- **Body**: `{"environment": "environment_name"}` |
| 145 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:487` |
| 146 | + |
| 147 | +### Status and Monitoring Endpoints |
| 148 | + |
| 149 | +#### `/status/v1/services` |
| 150 | +- **Used in**: `PuppetserverClient.getServicesStatus()`, `PuppetserverService.getServicesStatus()` |
| 151 | +- **Purpose**: Retrieve detailed status of all Puppet Server services |
| 152 | +- **Method**: GET |
| 153 | +- **Frontend**: `frontend/src/components/PuppetserverStatus.svelte:39` |
| 154 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:1350` |
| 155 | + |
| 156 | +#### `/status/v1/simple` |
| 157 | +- **Used in**: `PuppetserverClient.getSimpleStatus()`, `PuppetserverService.getSimpleStatus()` |
| 158 | +- **Purpose**: Lightweight health check (returns "running" or error) |
| 159 | +- **Method**: GET |
| 160 | +- **Frontend**: `frontend/src/components/PuppetserverStatus.svelte:70` |
| 161 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:1380` |
| 162 | + |
| 163 | +#### `/puppet-admin-api/v1` |
| 164 | +- **Used in**: `PuppetserverClient.getAdminApiInfo()`, `PuppetserverService.getAdminApiInfo()` |
| 165 | +- **Purpose**: Retrieve admin API information and available operations |
| 166 | +- **Method**: GET |
| 167 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:1410` |
| 168 | + |
| 169 | +#### `/metrics/v2` |
| 170 | +- **Used in**: `PuppetserverClient.getMetrics()`, `PuppetserverService.getMetrics()` |
| 171 | +- **Purpose**: Retrieve JMX metrics via Jolokia |
| 172 | +- **Method**: GET |
| 173 | +- **Parameters**: `mbean` (optional, for specific metrics) |
| 174 | +- **Warning**: Resource-intensive endpoint, use sparingly |
| 175 | +- **Location**: `backend/src/integrations/puppetserver/PuppetserverClient.ts:1440` |
| 176 | + |
| 177 | +## Application API Endpoints (Frontend to Backend) |
| 178 | + |
| 179 | +### PuppetDB Integration Routes |
| 180 | + |
| 181 | +#### `GET /api/integrations/puppetdb/resources/{certname}` |
| 182 | +- **Purpose**: Get managed resources for a node |
| 183 | +- **Backend**: `backend/src/routes/integrations.ts:1049` |
| 184 | + |
| 185 | +#### `GET /api/integrations/puppetdb/admin/archive` |
| 186 | +- **Purpose**: Get PuppetDB archive information |
| 187 | +- **Backend**: `backend/src/routes/integrations.ts:1311` |
| 188 | +- **Frontend**: `frontend/src/components/PuppetDBAdmin.svelte:32` |
| 189 | + |
| 190 | +#### `GET /api/integrations/puppetdb/admin/summary-stats` |
| 191 | +- **Purpose**: Get PuppetDB summary statistics |
| 192 | +- **Backend**: `backend/src/routes/integrations.ts:1383` |
| 193 | +- **Frontend**: `frontend/src/components/PuppetDBAdmin.svelte:67` |
| 194 | + |
| 195 | +### Puppet Server Integration Routes |
| 196 | + |
| 197 | +#### `GET /api/integrations/puppetserver/certificates` |
| 198 | +- **Purpose**: List all certificates |
| 199 | +- **Backend**: `backend/src/routes/integrations.ts` (implied) |
| 200 | +- **Frontend**: `frontend/src/components/CertificateManagement.svelte:88` |
| 201 | + |
| 202 | +#### `POST /api/integrations/puppetserver/certificates/{certname}/sign` |
| 203 | +- **Purpose**: Sign a certificate |
| 204 | +- **Frontend**: `frontend/src/components/CertificateManagement.svelte:147` |
| 205 | + |
| 206 | +#### `DELETE /api/integrations/puppetserver/certificates/{certname}` |
| 207 | +- **Purpose**: Revoke a certificate |
| 208 | +- **Frontend**: `frontend/src/components/CertificateManagement.svelte:179` |
| 209 | + |
| 210 | +#### `POST /api/integrations/puppetserver/certificates/bulk-sign` |
| 211 | +- **Purpose**: Sign multiple certificates |
| 212 | +- **Frontend**: `frontend/src/components/CertificateManagement.svelte:207` |
| 213 | + |
| 214 | +#### `POST /api/integrations/puppetserver/certificates/bulk-revoke` |
| 215 | +- **Purpose**: Revoke multiple certificates |
| 216 | +- **Frontend**: `frontend/src/components/CertificateManagement.svelte:238` |
| 217 | + |
| 218 | +#### `GET /api/integrations/puppetserver/status/services` |
| 219 | +- **Purpose**: Get Puppet Server services status |
| 220 | +- **Backend**: `backend/src/routes/integrations.ts:2929` |
| 221 | +- **Frontend**: `frontend/src/components/PuppetserverStatus.svelte:39` |
| 222 | + |
| 223 | +#### `GET /api/integrations/puppetserver/status/simple` |
| 224 | +- **Purpose**: Get simple Puppet Server status |
| 225 | +- **Backend**: `backend/src/routes/integrations.ts:3000` |
| 226 | +- **Frontend**: `frontend/src/components/PuppetserverStatus.svelte:70` |
| 227 | + |
| 228 | +## Authentication Methods |
| 229 | + |
| 230 | +### PuppetDB |
| 231 | +- **Token-based**: `X-Authentication` header |
| 232 | +- **SSL/TLS**: Client certificates (cert, key, ca) |
| 233 | +- **Configuration**: `backend/.env` - `PUPPETDB_*` variables |
| 234 | + |
| 235 | +### Puppet Server |
| 236 | +- **Token-based**: `X-Authentication` header |
| 237 | +- **Certificate-based**: Client certificates for mutual TLS |
| 238 | +- **SSL/TLS**: Custom CA certificates |
| 239 | +- **Configuration**: `backend/.env` - `PUPPETSERVER_*` variables |
| 240 | + |
| 241 | +## Error Handling Patterns |
| 242 | + |
| 243 | +### Common HTTP Status Codes |
| 244 | +- **200**: Success |
| 245 | +- **401/403**: Authentication/authorization errors |
| 246 | +- **404**: Resource not found (handled gracefully) |
| 247 | +- **429**: Rate limiting (retryable) |
| 248 | +- **5xx**: Server errors (retryable) |
| 249 | + |
| 250 | +### Retry Logic |
| 251 | +- **PuppetDB**: Circuit breaker with exponential backoff |
| 252 | +- **Puppet Server**: Circuit breaker with exponential backoff |
| 253 | +- **Retryable errors**: Connection, timeout, 5xx, 429 |
| 254 | +- **Non-retryable**: Authentication errors, 4xx client errors |
| 255 | + |
| 256 | +### Caching Strategy |
| 257 | +- **Default TTL**: 5 minutes (300,000ms) |
| 258 | +- **Status endpoints**: 30 seconds (frequently changing) |
| 259 | +- **Metrics**: 5+ minutes (resource-intensive) |
| 260 | +- **Empty results**: 1 minute (shorter TTL) |
| 261 | + |
| 262 | +## Performance Considerations |
| 263 | + |
| 264 | +### Resource-Intensive Endpoints |
| 265 | +1. **`/pdb/admin/v1/summary-stats`** - Can impact PuppetDB performance |
| 266 | +2. **`/metrics/v2`** - Can impact Puppet Server performance |
| 267 | +3. **`/pdb/query/v4/events`** - Limited to 100 events by default to prevent hanging |
| 268 | + |
| 269 | +### Optimization Strategies |
| 270 | +- Caching with appropriate TTLs |
| 271 | +- Circuit breakers to prevent cascading failures |
| 272 | +- Pagination for large datasets |
| 273 | +- Graceful degradation when endpoints are unavailable |
| 274 | +- Detailed logging for debugging and monitoring |
0 commit comments