|
| 1 | +# CapellaRESTAPIs - Agent Documentation |
| 2 | + |
| 3 | +## Project Purpose and Scope |
| 4 | +Python client library for Couchbase Capella REST APIs, used as a submodule by testrunner and TAF repositories for QA/test automation. Provides programmatic access to Capella Cloud APIs across multiple service types (dedicated, serverless, columnar, common) with dual API version support (v3 and v4). |
| 5 | + |
| 6 | +**Primary Users**: Internal QE/test automation teams |
| 7 | +**Usage Pattern**: Library imported and called directly from parent repositories during test execution |
| 8 | + |
| 9 | +## Core Commands |
| 10 | + |
| 11 | +### Installation and Setup |
| 12 | +```bash |
| 13 | +# Development installation (required for submodule usage) |
| 14 | +pip install -e . |
| 15 | + |
| 16 | +# Verify installation |
| 17 | +python -c "from capella.lib.APIRequests import APIRequests; print('OK')" |
| 18 | +``` |
| 19 | + |
| 20 | +### Library Verification |
| 21 | +```bash |
| 22 | +# Test core infrastructure |
| 23 | +python -c "from capella.lib.APIAuth import APIAuth; from capella.lib.APIRequests import APIRequests; print('Core OK')" |
| 24 | + |
| 25 | +# Test service imports |
| 26 | +python -c "from capella.dedicated.CapellaAPI_v4 import ClusterOperationsAPIs; from capella.serverless.CapellaAPI import CapellaAPI; from capella.columnar.ColumnarAPI_v4 import ColumnarAPIs; from capella.common.CapellaAPI_v4 import OrganizationOperationsAPIs; print('Services OK')" |
| 27 | +``` |
| 28 | + |
| 29 | +### Operational Patterns |
| 30 | +```python |
| 31 | +# v4 API usage pattern (Bearer token) |
| 32 | +from capella.dedicated.CapellaAPI_v4 import ClusterOperationsAPIs |
| 33 | +api = ClusterOperationsAPIs( |
| 34 | + url="https://cloudapi.qe-17.sandbox.nonprod-project-avengers.com", |
| 35 | + secret=secret_key, # v3 HMAC auth |
| 36 | + access=access_key, # v3 HMAC auth |
| 37 | + bearer_token=token # v4 Bearer auth |
| 38 | +) |
| 39 | +response = api.list_clusters(organizationId, projectId) |
| 40 | +``` |
| 41 | + |
| 42 | +## Repo Layout |
| 43 | + |
| 44 | +### Core Infrastructure |
| 45 | +- `capella/lib/` - Base components (APIAuth, APIRequests, APIExceptions) |
| 46 | +- `capella/common/` - Organization-level and shared operations |
| 47 | +- `capella/dedicated/` - Dedicated cluster operations |
| 48 | +- `capella/serverless/` - Serverless cluster operations |
| 49 | +- `capella/columnar/` - Columnar database operations |
| 50 | +- `docs/agent-context/` - Agent documentation context |
| 51 | +- `setup.py` - Package configuration |
| 52 | + |
| 53 | +### File Conventions |
| 54 | +- `CapellaAPI.py` - v3 API implementations (HMAC auth) |
| 55 | +- `CapellaAPI_v4.py` - v4 API implementations (Bearer auth) |
| 56 | +- `ColumnarAPI_v4.py` - Columnar-specific v4 operations |
| 57 | + |
| 58 | +## Development Patterns and Constraints |
| 59 | + |
| 60 | +### Authentication Strategy |
| 61 | +- **v3 APIs**: HMAC signature using secret key, access key, timestamp |
| 62 | +- **v4 APIs**: Bearer token authentication |
| 63 | +- **Detection**: API determines auth method based on URL containing "v4" |
| 64 | + |
| 65 | +### Request Patterns |
| 66 | +- Use service-specific API classes (ClusterOperationsAPIs, OrganizationOperationsAPIs) |
| 67 | +- All methods follow pattern: `operation_{name}(required_params, optional_params=None, headers=None, **kwargs)` |
| 68 | +- HTTP methods: `api_get()`, `api_post()`, `api_put()`, `api_patch()`, `api_del()` |
| 69 | + |
| 70 | +### Code Style Constraints |
| 71 | +- No automated linting or formatting currently configured |
| 72 | +- Thread-safety: Lock-based JWT refresh in internal API calls |
| 73 | +- Session reuse: `network_session` maintains HTTP connections |
| 74 | +- **SSL verification disabled** across all requests (security concern) |
| 75 | + |
| 76 | +### API Version Compatibility |
| 77 | +- Maintain both v3 (legacy) and v4 (current) versions when adding features |
| 78 | +- v4 preferred for new implementations |
| 79 | +- Check existing service files to determine version requirements |
| 80 | + |
| 81 | +## Validation and Evidence Required Before Completion |
| 82 | + |
| 83 | +### Mandatory Verification Steps |
| 84 | +1. **Import Validation**: All service classes import correctly in parent repository context |
| 85 | +2. **Authentication Test**: Successful API call using credentials provided by parent repository |
| 86 | +3. **Endpoint Verification**: Constructed API endpoints match Capella API documentation |
| 87 | +4. **Error Handling**: Custom exceptions properly raised and propagate correctly |
| 88 | +5. **Response Parsing**: JSON responses parse correctly without errors |
| 89 | + |
| 90 | +### Testing Evidence Requirements |
| 91 | +- Manual API call verification for each service type (dedicated, serverless, columnar, common) |
| 92 | +- Both v3 and v4 endpoint testing when applicable |
| 93 | +- Error path verification (invalid credentials, missing resources) |
| 94 | +- Integration testing through parent repositories (testrunner, TAF) |
| 95 | + |
| 96 | +### Validation Commands |
| 97 | +```bash |
| 98 | +# Manual verification pattern |
| 99 | +python -c " |
| 100 | +from capella.dedicated.CapellaAPI_v4 import ClusterOperationsAPIs |
| 101 | +api = ClusterOperationsAPIs(base_url, secret, access, bearer_token) |
| 102 | +# Perform test API call |
| 103 | +response = api.list_clusters(org_id, project_id) |
| 104 | +print('Success' if response.status_code == 200 else 'Failed') |
| 105 | +" |
| 106 | +``` |
| 107 | + |
| 108 | +## Security and Sensitive-Path Guidance |
| 109 | + |
| 110 | +### Credential Management |
| 111 | +- **Never hardcode** API keys, secret keys, or bearer tokens in code |
| 112 | +- Credentials are **passed from parent repositories** at runtime |
| 113 | +- Store credentials in parent repository environment variables |
| 114 | +- No credential storage in CapellaRESTAPIs |
| 115 | + |
| 116 | +### URL and Endpoint Security |
| 117 | +- Base URLs vary by environment (sandbox, staging, production) |
| 118 | +- Example: `https://cloudapi.qe-17.sandbox.nonprod-project-avengers.com` |
| 119 | +- Verify endpoint URLs match intended Capella environment |
| 120 | + |
| 121 | +### SSL Verification Warning |
| 122 | +- **Critical Security Issue**: SSL verification (`verify=False`) is disabled throughout codebase |
| 123 | +- This creates vulnerability to man-in-middle attacks |
| 124 | +- **Immediate Action Required**: Implement proper SSL certificate handling |
| 125 | +- For development: May be acceptable temporarily |
| 126 | +- For production: SSL verification must be enabled |
| 127 | + |
| 128 | +### Logging Security |
| 129 | +- DEBUG logging may include request/response content |
| 130 | +- Review logs before sharing to ensure no sensitive data exposure |
| 131 | +- Credentials should never appear in log output |
| 132 | + |
| 133 | +### Git Security |
| 134 | +- Never commit environment files with actual credentials |
| 135 | +- `.gitignore` should prevent credential file commits |
| 136 | +- Review diffs carefully for accidental credential inclusion |
| 137 | + |
| 138 | +### External References |
| 139 | +- Capella API documentation for endpoint verification |
| 140 | +- Security team guidance for SSL certificate management |
| 141 | +- Credential rotation policies from Capella platform |
| 142 | + |
| 143 | +## Supporting Documentation |
| 144 | + |
| 145 | +### Agent Context Documents |
| 146 | +- [Repo Inventory](docs/agent-context/repo-inventory.md) - Complete repository analysis |
| 147 | +- [Build and Test Matrix](docs/agent-context/build-test-matrix.md) - Command patterns and validation workflows |
| 148 | +- [Domain Glossary](docs/agent-context/domain-glossary.md) - Capella terminology and concepts |
| 149 | + |
| 150 | +### Architecture Documentation |
| 151 | +- [Architecture for Agents](docs/architecture.agents.md) - System design and component relationships |
| 152 | + |
| 153 | +### Operational Guidance |
| 154 | +- When adding new API operations: Follow existing method signature patterns |
| 155 | +- When creating new service types: Inherit from APIRequests and implement service-specific methods |
| 156 | +- When debugging API failures: Check exception hierarchy and API response content |
| 157 | +- When updating authentication: Verify both v3 and v4 paths as needed |
| 158 | + |
| 159 | +### Integration Context |
| 160 | +- Primary integration: testrunner repository (QA test automation) |
| 161 | +- Secondary integration: TAF repository (Test Automation Framework) |
| 162 | +- Credentials flow: Parent repos → CapellaRESTAPIs → Capella Cloud APIs |
| 163 | +- No direct user interaction: Library called programmatically only |
0 commit comments