ioc-scope-api 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ioc_scope_api-1.0.0.dist-info/METADATA +306 -0
- ioc_scope_api-1.0.0.dist-info/RECORD +106 -0
- ioc_scope_api-1.0.0.dist-info/WHEEL +4 -0
- ioc_scope_api-1.0.0.dist-info/entry_points.txt +2 -0
- scope/__init__.py +27 -0
- scope/api/__init__.py +119 -0
- scope/api/api_v1/__init__.py +2 -0
- scope/api/api_v1/api.py +71 -0
- scope/api/api_v1/endpoints/__init__.py +2 -0
- scope/api/api_v1/endpoints/agentic_protocols_metrics.py +39 -0
- scope/api/api_v1/endpoints/applications.py +440 -0
- scope/api/api_v1/endpoints/cache.py +50 -0
- scope/api/api_v1/endpoints/concepts.py +123 -0
- scope/api/api_v1/endpoints/features.py +19 -0
- scope/api/api_v1/endpoints/helpers.py +65 -0
- scope/api/api_v1/endpoints/kg.py +195 -0
- scope/api/api_v1/endpoints/labels.py +71 -0
- scope/api/api_v1/endpoints/live_topology.py +89 -0
- scope/api/api_v1/endpoints/metrics.py +1014 -0
- scope/api/api_v1/endpoints/reasoning.py +62 -0
- scope/api/api_v1/endpoints/semanticgroups.py +144 -0
- scope/api/api_v1/endpoints/sessions.py +339 -0
- scope/api/api_v1/endpoints/spans.py +41 -0
- scope/api/api_v1/endpoints/symbolic.py +186 -0
- scope/api/api_v1/endpoints/ui.py +145 -0
- scope/api/api_v1/endpoints/waste_estimation.py +182 -0
- scope/api/api_v2/__init__.py +3 -0
- scope/api/api_v2/api.py +23 -0
- scope/api/api_v2/endpoints/__init__.py +3 -0
- scope/api/api_v2/endpoints/metrics.py +193 -0
- scope/app.py +30 -0
- scope/cache.py +64 -0
- scope/client/__init__.py +27 -0
- scope/client/_concepts.py +137 -0
- scope/client/_kg.py +64 -0
- scope/client/_labels.py +86 -0
- scope/client/_live_topology.py +912 -0
- scope/client/_metrics.py +561 -0
- scope/client/_semanticgroups.py +166 -0
- scope/client/_sessions.py +168 -0
- scope/client/_symbolic.py +1354 -0
- scope/client/_ui.py +599 -0
- scope/client/agentic_protocols.py +289 -0
- scope/client/application_charts.py +1786 -0
- scope/client/applications.py +2246 -0
- scope/client/base.py +49 -0
- scope/client/cognition_protocols.py +302 -0
- scope/client/constants.py +81 -0
- scope/client/dal.py +2382 -0
- scope/client/failures.py +70 -0
- scope/client/local.py +161 -0
- scope/client/mock/__init__.py +7 -0
- scope/client/mock/client.py +1034 -0
- scope/client/sessions.py +1688 -0
- scope/client/spans.py +95 -0
- scope/client/utils.py +392 -0
- scope/connectors/__init__.py +13 -0
- scope/connectors/base.py +52 -0
- scope/connectors/clickhouse.py +105 -0
- scope/connectors/neo4j.py +220 -0
- scope/connectors/sqlalchemy.py +131 -0
- scope/core/config.py +530 -0
- scope/core/exceptions.py +64 -0
- scope/dependencies.py +164 -0
- scope/health.py +10 -0
- scope/interfaces/__init__.py +33 -0
- scope/interfaces/data_provider.py +61 -0
- scope/interfaces/integration_example.py +310 -0
- scope/interfaces/kg_provider.py +91 -0
- scope/interfaces/metrics_provider.py +92 -0
- scope/interfaces/models.py +185 -0
- scope/models/kg.py +48 -0
- scope/models/live_topology.py +78 -0
- scope/models/otel_traces.py +1595 -0
- scope/providers/__init__.py +277 -0
- scope/providers/_graph.py +59 -0
- scope/providers/cognition_protocols.py +178 -0
- scope/providers/kg.py +702 -0
- scope/providers/kg_query_runner.py +109 -0
- scope/providers/neo4j_mce.py +18 -0
- scope/providers/scope_metrics.py +7 -0
- scope/query_builders/__init__.py +14 -0
- scope/query_builders/cognition_protocol_graph.py +191 -0
- scope/query_builders/concepts.py +112 -0
- scope/query_builders/dal.py +931 -0
- scope/query_builders/failure_graph.py +102 -0
- scope/query_builders/features.py +5 -0
- scope/query_builders/kg.py +416 -0
- scope/query_builders/labels.py +53 -0
- scope/query_builders/live_topology.py +503 -0
- scope/query_builders/metric_graph.py +196 -0
- scope/query_builders/metrics.py +354 -0
- scope/query_builders/semanticgroups.py +46 -0
- scope/query_builders/sessions.py +208 -0
- scope/query_builders/symbolic.py +615 -0
- scope/query_builders/trajectory.py +76 -0
- scope/query_builders/types.py +20 -0
- scope/query_builders/ui.py +3278 -0
- scope/query_builders/waste_estimation.py +221 -0
- scope/repositories/__init__.py +28 -0
- scope/repositories/clickhouse_otel_repository.py +135 -0
- scope/repositories/otel_repository.py +97 -0
- scope/repositories/sqlite_repository.py +215 -0
- scope/scripts/__init__.py +2 -0
- scope/scripts/seed.py +35 -0
- scope/workarounds.py +38 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ioc-scope-api
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: SCOPE backend API service
|
|
5
|
+
Author-email: Outshift Open <oss-github@cisco.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.13
|
|
8
|
+
Requires-Dist: clickhouse-connect>=0.11.0
|
|
9
|
+
Requires-Dist: fastapi>=0.129.0
|
|
10
|
+
Requires-Dist: ioc-scope-ontology[models,verify]>=1.1.0
|
|
11
|
+
Requires-Dist: neo4j>=6.1.0
|
|
12
|
+
Requires-Dist: numpy>=2.3.5
|
|
13
|
+
Requires-Dist: packaging>=26.0
|
|
14
|
+
Requires-Dist: pydantic-settings>=2.13.1
|
|
15
|
+
Requires-Dist: python-dotenv>=1.2.1
|
|
16
|
+
Requires-Dist: redis>=5.0.0
|
|
17
|
+
Requires-Dist: requests>=2.32.5
|
|
18
|
+
Requires-Dist: ruff<=0.15.22
|
|
19
|
+
Requires-Dist: sqlalchemy>=2.0.46
|
|
20
|
+
Requires-Dist: uvicorn>=0.41.0
|
|
21
|
+
Provides-Extra: clickhouse-sqlalchemy
|
|
22
|
+
Requires-Dist: clickhouse-sqlalchemy>=0.3.2; extra == 'clickhouse-sqlalchemy'
|
|
23
|
+
Provides-Extra: latent-space
|
|
24
|
+
Requires-Dist: numba>=0.60.0; extra == 'latent-space'
|
|
25
|
+
Requires-Dist: umap-learn>=0.5.7; extra == 'latent-space'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# SCOPE API
|
|
29
|
+
|
|
30
|
+
Unified DB access layer across SCOPE. It consolidates the fragmented data access patterns currently spread across scope-backend, DAL, and workflow components into one single library and provides an optional REST API, for use by the downstream components.
|
|
31
|
+
|
|
32
|
+
## Tech stack
|
|
33
|
+
|
|
34
|
+
- **Python 3.13+**
|
|
35
|
+
- **SQLAlchemy** — ORM / database toolkit (SQLite & ClickHouse backends)
|
|
36
|
+
- **clickhouse-connect** — native ClickHouse driver
|
|
37
|
+
- **FastAPI** + **Uvicorn** — async HTTP server
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 1. Create a virtual environment & install dependencies
|
|
43
|
+
uv venv
|
|
44
|
+
source .venv/bin/activate
|
|
45
|
+
uv sync
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
# 2. Run the server
|
|
49
|
+
```bash
|
|
50
|
+
export CLICKHOUSE_HOST=localhost
|
|
51
|
+
export CLICKHOUSE_PORT=8123
|
|
52
|
+
export CLICKHOUSE_USERNAME=scopeclickhouseuser
|
|
53
|
+
export CLICKHOUSE_PASSWORD=scopeclickhousepassword
|
|
54
|
+
export CLICKHOUSE_DATABASE=scope
|
|
55
|
+
uv run dev
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The API will be available at **http://127.0.0.1:8000**.
|
|
59
|
+
|
|
60
|
+
OpenAPI specification docs are available at **http://127.0.0.1:8000/docs**.
|
|
61
|
+
|
|
62
|
+
## Running tests
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Recreate a dedicated test environment from the project metadata
|
|
66
|
+
uv venv .venv_tests
|
|
67
|
+
source .venv_tests/bin/activate
|
|
68
|
+
uv sync --active --dev
|
|
69
|
+
|
|
70
|
+
# Run the test suites
|
|
71
|
+
python -m pytest tests/ -v
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The `uv sync --active --dev` step installs both the main project dependencies
|
|
75
|
+
and the test-only dependencies declared in `pyproject.toml`, including vendored
|
|
76
|
+
wheel dependencies such as `mce-core`, `mce-provider-native`, and
|
|
77
|
+
`mce-provider-sdk`.
|
|
78
|
+
|
|
79
|
+
No additional `uv pip install` commands are required for metric compute in local
|
|
80
|
+
dev or CI when syncing with `--group dev`.
|
|
81
|
+
|
|
82
|
+
### Vendored wheel maintenance (important for Docker builds)
|
|
83
|
+
|
|
84
|
+
The API image build uses Docker `context: api`, so `uv.lock` cannot contain
|
|
85
|
+
sources outside that directory (for example `../mce/...`). Keep
|
|
86
|
+
`[tool.uv.sources]` and `api/uv.lock` pointing to `api/vendor/*.whl` paths.
|
|
87
|
+
|
|
88
|
+
When updating `mce-core` or MCE providers:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# From repo root
|
|
92
|
+
uv build mce/mce-core
|
|
93
|
+
uv build mce/mce-provider-native
|
|
94
|
+
uv build mce/mce-provider-sdk
|
|
95
|
+
|
|
96
|
+
cp mce/dist/mce_core-2.0.0rc1-py3-none-any.whl api/vendor/
|
|
97
|
+
cp mce/dist/mce_provider_native-0.1.0-py3-none-any.whl api/vendor/
|
|
98
|
+
cp mce/dist/mce_provider_sdk-0.1.0-py3-none-any.whl api/vendor/
|
|
99
|
+
|
|
100
|
+
uv lock --project ./api
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Docker
|
|
104
|
+
|
|
105
|
+
### Build the image
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
docker build -t scope-api -f Dockerfile .
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
or use `docker compose` to build as part of the full stack:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
docker compose -f deploy/docker-compose.yml --build scope-api
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Run the container standalone
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
docker run --rm -p 8000:8000 \
|
|
121
|
+
-e CLICKHOUSE_HOST=host.docker.internal \
|
|
122
|
+
-e CLICKHOUSE_PORT=8123 \
|
|
123
|
+
-e CLICKHOUSE_USERNAME=scopeclickhouseuser \
|
|
124
|
+
-e CLICKHOUSE_PASSWORD=scopeclickhousepassword \
|
|
125
|
+
-e CLICKHOUSE_DATABASE=default \
|
|
126
|
+
scope-api
|
|
127
|
+
```
|
|
128
|
+
The init script ([data/clickhouse/otel_traces.sql](data/clickhouse/otel_traces.sql)) runs automatically on first startup, creating the `scope` database.
|
|
129
|
+
|
|
130
|
+
| Service | URL |
|
|
131
|
+
|---------|-----|
|
|
132
|
+
| SCOPE API | `http://localhost:8000` |
|
|
133
|
+
| ClickHouse HTTP | `http://localhost:8123` |
|
|
134
|
+
| ClickHouse TCP | `localhost:9000` |
|
|
135
|
+
|
|
136
|
+
## Test HTTP REST API
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
make test-rest-api
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Using as a Python library
|
|
143
|
+
|
|
144
|
+
Besides running as a REST server, `scope-api` can be imported directly into any Python project as a library.
|
|
145
|
+
|
|
146
|
+
### Quick example
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from scope import LocalClient
|
|
150
|
+
|
|
151
|
+
with LocalClient() as client:
|
|
152
|
+
apps = client.get_application_names()
|
|
153
|
+
sessions = client.get_sessions(app_name="my-app", limit=10)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Specifying database credentials
|
|
157
|
+
|
|
158
|
+
`LocalClient` accepts an optional `db` argument — a **Connector** instance that
|
|
159
|
+
you configure with explicit credentials. When `db` is omitted, the backend is
|
|
160
|
+
chosen automatically through the `SCOPE_LOCAL` environment variable (see
|
|
161
|
+
[Environment-variable mode](#environment-variable-mode) below).
|
|
162
|
+
|
|
163
|
+
#### Option A — ClickHouse (via `clickhouse-connect`)
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
from scope import LocalClient
|
|
167
|
+
from scope.connectors.clickhouse import ClickHouseConnector
|
|
168
|
+
|
|
169
|
+
db = ClickHouseConnector(
|
|
170
|
+
host="clickhouse.example.com",
|
|
171
|
+
port=8123,
|
|
172
|
+
username="scope_user",
|
|
173
|
+
password="s3cret",
|
|
174
|
+
database="scope",
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
with LocalClient(db=db) as client:
|
|
178
|
+
apps = client.get_applications()
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
#### Option B — PostgreSQL (via SQLAlchemy)
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
from scope import LocalClient
|
|
185
|
+
from scope.connectors.sqlalchemy import SQLAlchemyConnector
|
|
186
|
+
|
|
187
|
+
# PostgreSQL
|
|
188
|
+
db = SQLAlchemyConnector(url="postgresql://user:pass@host:5432/scope")
|
|
189
|
+
|
|
190
|
+
with LocalClient(db=db) as client:
|
|
191
|
+
sessions = client.list_sessions(limit=20)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### Option C — Neo4j (for KG, metrics, and concepts operations)
|
|
195
|
+
|
|
196
|
+
KG, metrics, and concepts methods require a Neo4j-backed connector:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
from scope import LocalClient
|
|
200
|
+
from scope.connectors.neo4j import Neo4JConnector
|
|
201
|
+
|
|
202
|
+
db = Neo4JConnector(
|
|
203
|
+
host="neo4j.example.com",
|
|
204
|
+
port=7687,
|
|
205
|
+
username="neo4j",
|
|
206
|
+
password="s3cret",
|
|
207
|
+
database="neo4j",
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
with LocalClient(db=db) as client:
|
|
211
|
+
state = client.get_state_by_session_id("session-abc")
|
|
212
|
+
metrics = client.get_session_metrics("session-abc", hops=2)
|
|
213
|
+
concepts = client.get_app_concepts("my-app")
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### Environment-variable mode
|
|
217
|
+
|
|
218
|
+
When you create `LocalClient()` **without** a `db` argument, the backend is
|
|
219
|
+
selected by the `SCOPE_LOCAL` environment variable:
|
|
220
|
+
|
|
221
|
+
| `SCOPE_LOCAL` | Backend | Credentials read from |
|
|
222
|
+
|----------------------------|------------|-----------------------------------|
|
|
223
|
+
| `true` / `1` / `yes` *(default)* | SQLite | Uses `scope.db` in the working directory |
|
|
224
|
+
| Any other value | ClickHouse | `CLICKHOUSE_HOST`, `CLICKHOUSE_PORT`, `CLICKHOUSE_USERNAME`, `CLICKHOUSE_PASSWORD`, `CLICKHOUSE_DATABASE` |
|
|
225
|
+
|
|
226
|
+
Neo4j settings (used by the REST server's dependency injection) are read from:
|
|
227
|
+
|
|
228
|
+
| Variable | Default |
|
|
229
|
+
|--------------------|-------------|
|
|
230
|
+
| `NEO4J_HOST` | `localhost` |
|
|
231
|
+
| `NEO4J_PORT` | `7687` |
|
|
232
|
+
| `NEO4J_USERNAME` | `neo4j` |
|
|
233
|
+
| `NEO4J_PASSWORD` | *(empty)* |
|
|
234
|
+
| `NEO4J_DATABASE` | `neo4j` |
|
|
235
|
+
|
|
236
|
+
Example:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
export SCOPE_LOCAL=false
|
|
240
|
+
export CLICKHOUSE_HOST=clickhouse.example.com
|
|
241
|
+
export CLICKHOUSE_PORT=8123
|
|
242
|
+
export CLICKHOUSE_USERNAME=scope_user
|
|
243
|
+
export CLICKHOUSE_PASSWORD=s3cret
|
|
244
|
+
export CLICKHOUSE_DATABASE=scope
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
```python
|
|
248
|
+
from scope import LocalClient
|
|
249
|
+
|
|
250
|
+
# Automatically connects to the ClickHouse instance above
|
|
251
|
+
client = LocalClient()
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Available client methods
|
|
255
|
+
|
|
256
|
+
| Domain | Method | Description |
|
|
257
|
+
|--------|--------|-------------|
|
|
258
|
+
| **Applications** | `get_application_names(...)` | List known application IDs |
|
|
259
|
+
| | `get_applications(...)` | Applications with agents, LLMs, cost, perf |
|
|
260
|
+
| | `get_application_details(...)` | Application-level monitoring data |
|
|
261
|
+
| | `get_application_agents(...)` | Per-agent monitoring for an app |
|
|
262
|
+
| **Sessions** | `get_sessions(...)` | Session/trace summaries |
|
|
263
|
+
| | `list_sessions(...)` | Flat session listing |
|
|
264
|
+
| | `get_session_agents(...)` | Agents within a session |
|
|
265
|
+
| | `get_session_agent_details(...)` | Detailed agent info in a session |
|
|
266
|
+
| | `_get_session_timeline(...)` | Waterfall span tree |
|
|
267
|
+
| | `get_session_spans(...)` | Span attributes for session(s) |
|
|
268
|
+
| **Spans** | `get_spans(...)` | Single span details |
|
|
269
|
+
| **KG** | `get_state_by_session_id(...)` | Session state from knowledge graph |
|
|
270
|
+
| | `get_embedding_by_session_id(...)` | Embedding vector for a session |
|
|
271
|
+
| | `get_neighbors(...)` | Similar sessions by embedding distance |
|
|
272
|
+
| **Metrics** | `get_session_metrics(...)` | KG metrics for a session |
|
|
273
|
+
| | `get_span_metrics(...)` | KG metrics for a span |
|
|
274
|
+
| **Concepts** | `get_app_concepts(...)` | Neurosymbolic concepts for an app |
|
|
275
|
+
| | `get_span_concepts(...)` | Concepts scoped to a specific span |
|
|
276
|
+
|
|
277
|
+
### Type hints & return types
|
|
278
|
+
|
|
279
|
+
All methods return **Pydantic models** (e.g. `TracesResponse`,
|
|
280
|
+
`ApplicationsResponse`, `SpanDetailsResponse`) defined in
|
|
281
|
+
`scope.models.otel_traces`. Results are fully typed and serializable:
|
|
282
|
+
|
|
283
|
+
```python
|
|
284
|
+
from scope import LocalClient
|
|
285
|
+
|
|
286
|
+
with LocalClient() as client:
|
|
287
|
+
resp = client.get_applications()
|
|
288
|
+
for app in resp.applications:
|
|
289
|
+
print(app.applicationName, app.cost)
|
|
290
|
+
|
|
291
|
+
# Serialize to dict / JSON
|
|
292
|
+
print(resp.model_dump_json(indent=2))
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
For dependency injection or testing, type-hint against the abstract base class:
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
from scope import SCOPEAPIClient, LocalClient
|
|
299
|
+
|
|
300
|
+
def analyze(client: SCOPEAPIClient):
|
|
301
|
+
...
|
|
302
|
+
|
|
303
|
+
analyze(LocalClient())
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
scope/__init__.py,sha256=GKyA6rDbdGBGCy0jK55k-Wi8MWxjKmjbku0leVXmVVQ,754
|
|
2
|
+
scope/app.py,sha256=Ybg8x5BA-do3bZWt-f90LgWX--lUOCUMeFXttVbvB9A,732
|
|
3
|
+
scope/cache.py,sha256=Ug_BQfuDbLLUjMP85ynEpJNExJBg0tKqKtLfxqzwEGU,1804
|
|
4
|
+
scope/dependencies.py,sha256=cD60e2ldxHKloHsIQz629b6d3IEwFLF3ZRxQVan2Ap8,5941
|
|
5
|
+
scope/health.py,sha256=5w4nfAsc8vem2qiYVVcoH4AnNsbljxaJOvrgnChBHcU,269
|
|
6
|
+
scope/workarounds.py,sha256=6_GWRS9sMcbNurGmMMJh8CV8rh4uEbaDRU0rnj-9EaE,1649
|
|
7
|
+
scope/api/__init__.py,sha256=XP3_dQI_aWmgBS8HN9nnH_dFQcR-x7gqjp3MbR82d5U,3857
|
|
8
|
+
scope/api/api_v1/__init__.py,sha256=t5U0rc_5ch8vkvHhA2QXazu2VA9bRPtzKseXaWR-BQc,100
|
|
9
|
+
scope/api/api_v1/api.py,sha256=FrX7wuBv-kDOCOSRN2dXm6DQdU8OppsQomUN4_cQ8fA,2225
|
|
10
|
+
scope/api/api_v1/endpoints/__init__.py,sha256=t5U0rc_5ch8vkvHhA2QXazu2VA9bRPtzKseXaWR-BQc,100
|
|
11
|
+
scope/api/api_v1/endpoints/agentic_protocols_metrics.py,sha256=2oZ5mMpHRtN4FFSGPWP9lUkI8S9SAJUtcJAzfXzn7W8,1330
|
|
12
|
+
scope/api/api_v1/endpoints/applications.py,sha256=hhABr1Z1y5ZwHDWOri19NuvB3YaFPOCBQvySEziHWEs,14365
|
|
13
|
+
scope/api/api_v1/endpoints/cache.py,sha256=q6PD00PBHpP-O7RhSYSeTruk3q-U66LbZiNVUT36Ycs,1392
|
|
14
|
+
scope/api/api_v1/endpoints/concepts.py,sha256=FMHdXzbzvo1SvKVklwcaNLKxFE4ZICANSe77oc5k_Y8,3950
|
|
15
|
+
scope/api/api_v1/endpoints/features.py,sha256=ZjpsPtHKrDcuUmVzLX13pod3IrImRqV-ucnKrdNyOXk,507
|
|
16
|
+
scope/api/api_v1/endpoints/helpers.py,sha256=SuhGoXpLI0O2UdB096dn5OItzi4_5zXF-TYXyksMXtE,2248
|
|
17
|
+
scope/api/api_v1/endpoints/kg.py,sha256=ApiH7Zg901tLxRnC6f5-nwckJegfmhUyq6DcJQ3p3JA,7427
|
|
18
|
+
scope/api/api_v1/endpoints/labels.py,sha256=FhMKY01Jh34xoUCtrs9_ojzkHmM20IqVdu5pDaWt1y4,2135
|
|
19
|
+
scope/api/api_v1/endpoints/live_topology.py,sha256=UhwNGfjoud7rT24Av-g0qtI4Us4rIR47Ox8OjU52jf4,2659
|
|
20
|
+
scope/api/api_v1/endpoints/metrics.py,sha256=NmAma55z6OA3zdfaD6THI3zndUt-zjZ-OiYYTYszpsw,36132
|
|
21
|
+
scope/api/api_v1/endpoints/reasoning.py,sha256=MgN3ODZxazWzXwBWRIrNfmYJTyD9g-0_X35olcoYlW4,2165
|
|
22
|
+
scope/api/api_v1/endpoints/semanticgroups.py,sha256=NzcZd2_E0dINoi-lGhC4SHUwwUo2nmIx7YPWiSd5PLw,4771
|
|
23
|
+
scope/api/api_v1/endpoints/sessions.py,sha256=EPSkLdVUF3aXmj7aK2o4kR_0rgkDGYIBUGUFCfr2QAE,11391
|
|
24
|
+
scope/api/api_v1/endpoints/spans.py,sha256=82IF2AeSPMRR1xknzNUQdreMJEjJrMyJnXxiyYXWbKs,1326
|
|
25
|
+
scope/api/api_v1/endpoints/symbolic.py,sha256=ek1sE2d8X5m-JHoOw5BR4UfCipNY2-WxDsKFfbfVOlY,6063
|
|
26
|
+
scope/api/api_v1/endpoints/ui.py,sha256=d2hmLKiPGTH0D0zuJ-brXbiSuWhYEhELS0OEHDmqIN4,4739
|
|
27
|
+
scope/api/api_v1/endpoints/waste_estimation.py,sha256=-qQQFD_O-g5_7X93EDMhjvEiR5jOmvc2n0yWXIO0SCU,6474
|
|
28
|
+
scope/api/api_v2/__init__.py,sha256=oMbZMEAvSUVhqnhS7b8QB4pKLj-QVmynChnjwP8w3qs,122
|
|
29
|
+
scope/api/api_v2/api.py,sha256=ZxOGZUn_vYh3mCCrpAqDfvXQJhP9_ZL5ORPNHGFGDQE,751
|
|
30
|
+
scope/api/api_v2/endpoints/__init__.py,sha256=pMsZIZgvC5ICybhi6dFj96VKOf2zaYhXtlT17-5k7Z4,132
|
|
31
|
+
scope/api/api_v2/endpoints/metrics.py,sha256=3GvO9yu-zeiOKW37PlRSYXZgCqB4OezWRNo3P043Zxk,6992
|
|
32
|
+
scope/client/__init__.py,sha256=Bo8IjfX4rmCrwjgJSvqpAv3Z8VRPPBFZlq6aCCYaIMc,821
|
|
33
|
+
scope/client/_concepts.py,sha256=9G7xrO684uEa2rZYUhZEXimuGlEF0mCMspbyqGHrJjo,4559
|
|
34
|
+
scope/client/_kg.py,sha256=nWBWYkV8IpGCEIXPv4Z-aW6YG3JJIbIHMUKZVRIsW1g,2228
|
|
35
|
+
scope/client/_labels.py,sha256=vFitBezaRdDs0IGZa8gqcMUsVHb-Z_R4VNMzwaqxyu0,3053
|
|
36
|
+
scope/client/_live_topology.py,sha256=Gx0yKdhOABEG8RGyh0QX1339Y0Lnm7BG62nTtYw5qtU,36325
|
|
37
|
+
scope/client/_metrics.py,sha256=JN_REy2_GcbcFG3-CVVBb5u04ib6wRJZMpGD1HsLqz8,20019
|
|
38
|
+
scope/client/_semanticgroups.py,sha256=Ey2gJCmrWjgcq2EsbEmq_bBkmBeSh6xFkMhyRCHFdsY,5557
|
|
39
|
+
scope/client/_sessions.py,sha256=7SvpxXO_Hc_OQeTfg61DUBAoZUH3lsarWIECDh_kcwk,5831
|
|
40
|
+
scope/client/_symbolic.py,sha256=M5GOOpkX0Jm6H_Jo55TMtwk0AzaxTgNHCXgEwqc8w_Q,55144
|
|
41
|
+
scope/client/_ui.py,sha256=bAxLfJndyhDlBJL8e_dYwi1yQZZpeYDhr1cUxRc3Rg8,18337
|
|
42
|
+
scope/client/agentic_protocols.py,sha256=1AP4vy_N_GfmQbygCZO1cBGpMClhPqHtOV3GIQ0xyj8,8561
|
|
43
|
+
scope/client/application_charts.py,sha256=MoRLLjOMcGxjUOTL0DmDtNwjRYpefNHByxdcpj8SSZU,65641
|
|
44
|
+
scope/client/applications.py,sha256=KU2OVZE40j4OX1B52QYD55WkIbx_yazEaqVmB9_eww0,82353
|
|
45
|
+
scope/client/base.py,sha256=IG7muYhWbbP2bj82UJM9X3lmxJlpbc8mLQSi1FSVJtM,2261
|
|
46
|
+
scope/client/cognition_protocols.py,sha256=B7mZ9iq-1T8DgU0L-H4ftA9W4PYSYPZ4SBa-Qte21CQ,11469
|
|
47
|
+
scope/client/constants.py,sha256=klblSbLsWBGcVtzhYpm_kiptwz49PxQ-XIAF-PzCejs,2781
|
|
48
|
+
scope/client/dal.py,sha256=MgQXolqGwr5gahYvrqQw2jfLft1WOWf1FSxjuDo5FxE,85284
|
|
49
|
+
scope/client/failures.py,sha256=PGFxcPUiPG5l9jm7dffBXBN2SMogvS6h4Rm-yIQ2kJA,2524
|
|
50
|
+
scope/client/local.py,sha256=Q7-wswQcgVUWDipDt1312Vwb6lvMC6J8M8P8L4Nqt3E,6224
|
|
51
|
+
scope/client/sessions.py,sha256=Q0VMCou51Lk9q7hN7BqSDNY3q5ebAU8v4vUUUpGVHNE,57220
|
|
52
|
+
scope/client/spans.py,sha256=M9ly6Jc4BvCDo0jHj3lx3Ai6y3Xoz0Buuesu2XjXoyY,2811
|
|
53
|
+
scope/client/utils.py,sha256=eJ6fPO39CGUnfbwBkvOwyCN4-LpUbW37_fdSUoGV_3Q,13238
|
|
54
|
+
scope/client/mock/__init__.py,sha256=zdI74FfS1L1l8x4RKSoAhpQgKNYKHGabqbbxRl3FQjs,238
|
|
55
|
+
scope/client/mock/client.py,sha256=nS60KmXq_TXVWokRfoqntfucnXORdqUoJFzUKnmDdYk,45155
|
|
56
|
+
scope/connectors/__init__.py,sha256=4jI8P878mXMlEX1ItQNYkGc48k4ox2odvY7_4-4VHho,412
|
|
57
|
+
scope/connectors/base.py,sha256=ZyyaiZsrniS2VQ0FAS2q1GAWHGCIPAI7Kczb5bncaRs,1911
|
|
58
|
+
scope/connectors/clickhouse.py,sha256=sd0psyYv3fkYnqaiRTgHYsNrmplAKhZZzCNh55FB6c8,3832
|
|
59
|
+
scope/connectors/neo4j.py,sha256=RhfW8q6H9tJiZTpFCjeEC85Nr7RsTyx85UqacPUbBNo,8215
|
|
60
|
+
scope/connectors/sqlalchemy.py,sha256=qHU5fcg8wD9B5MH5_3M-y6GbRNGPtQ3JEAj00eLkzfM,4903
|
|
61
|
+
scope/core/config.py,sha256=bfmGNPOKtPUomCPnR9gSBrs7zOn49AyQYy-bIPkbY-g,18336
|
|
62
|
+
scope/core/exceptions.py,sha256=WsleodS5Wru8b9tRdyFSQfeVtvwcScZxPAxacUMQd70,1663
|
|
63
|
+
scope/interfaces/__init__.py,sha256=AmGw8LjYiFMAgFpinQYwsRRHc1VVth4pAnr-6Q5N-kQ,813
|
|
64
|
+
scope/interfaces/data_provider.py,sha256=11l8w9yBzxZ4Z02j7kiIOL4pPZJji86s8GcWWbczr8M,2274
|
|
65
|
+
scope/interfaces/integration_example.py,sha256=OrDh3qVNQnIOgh_YfmuI--4SpnHgYJaktDjD7j5b28k,13658
|
|
66
|
+
scope/interfaces/kg_provider.py,sha256=Kkc5EpwwVdcOEsyIzNmrkpYwHRVs7exoIqRdIDAntP8,2716
|
|
67
|
+
scope/interfaces/metrics_provider.py,sha256=KgX9hy3M6YcnP_oq0FxKWYk2iAMrRDElvr2pslnHmtE,2987
|
|
68
|
+
scope/interfaces/models.py,sha256=CkYo65jG6Y3fnUUpuxKmMkNiZtJwj_1SXIUbTvYHs04,5889
|
|
69
|
+
scope/models/kg.py,sha256=5OqJcXolbTqufAvxQ3WA2vTPrZKj6MGzKiD5dBdvqDo,1544
|
|
70
|
+
scope/models/live_topology.py,sha256=FvW_VcP20FOMkdpgzU1KuyPVN3w8lCHE5NkJKRHGBqk,2122
|
|
71
|
+
scope/models/otel_traces.py,sha256=TJur5pMESkvjkC6ks8X54W-HO9-pwhiK0z-xDVMFMmE,54019
|
|
72
|
+
scope/providers/__init__.py,sha256=KQ9Q-hCoRMZ1xobFl5eel2xItw2ugu2OgYnItvSdMkk,9828
|
|
73
|
+
scope/providers/_graph.py,sha256=WFeQVqCAQ_mi14sZZmF4CAZGH4PoRiZC8Xh8ti_6400,1952
|
|
74
|
+
scope/providers/cognition_protocols.py,sha256=pBWqTJyRmUwZzD18ROwkVkGTfOmBIqSN0gw9SVzmbak,6726
|
|
75
|
+
scope/providers/kg.py,sha256=z7Be8KCSq1Oo2_-nM7Wa6SKAqCk4D1QKr913d1Kf2SY,26557
|
|
76
|
+
scope/providers/kg_query_runner.py,sha256=yreE6fPnECfGlt_RNRJoI_HTY4NzY3Rt2KvQIzLCwlc,3544
|
|
77
|
+
scope/providers/neo4j_mce.py,sha256=nDw3REp5Q0i3muoF4KmFSYCT-1kULg1M7et0FOVg2uc,666
|
|
78
|
+
scope/providers/scope_metrics.py,sha256=rvErYvZC5q0d-CtevCSRlY9Swj1nVrEaThFNQKA8fFs,283
|
|
79
|
+
scope/query_builders/__init__.py,sha256=3C8KofvdJIlDeRpiswsAGZA7ppEYoASX2XFQWezM9AA,369
|
|
80
|
+
scope/query_builders/cognition_protocol_graph.py,sha256=uAbA_i1GiSkcMyH0jz7gOfvM0bZhdDx43QNtbb8IES0,7109
|
|
81
|
+
scope/query_builders/concepts.py,sha256=bpLrZKN_27LFRFeVPtwZpj233T6ds6yqqYK1fBGJxNw,3353
|
|
82
|
+
scope/query_builders/dal.py,sha256=Pn1W-pydd-eI6a00VeqitDsHPwTc_a_uIrfRDPdB1fc,32870
|
|
83
|
+
scope/query_builders/failure_graph.py,sha256=UR9Bx01EhDJf_2NBMmM4WewMMsoKH4nwILnaH4viqPI,3608
|
|
84
|
+
scope/query_builders/features.py,sha256=6ImAuJg0ZgG0eCijzffrTGkJ5Ppv7f-RiDQq8S8i3CM,194
|
|
85
|
+
scope/query_builders/kg.py,sha256=IuOmZDGF7C2x59hRw3QOufXFSUoV9VFqCDZWCxpoed8,14971
|
|
86
|
+
scope/query_builders/labels.py,sha256=T4J3AIbxNhNV3MZEJDOEjWkqw19oONTsrUat3bVE6tc,1585
|
|
87
|
+
scope/query_builders/live_topology.py,sha256=Tas1Ntixa3G6STmCiEliGDDCmJ3kQ20W4Y6yrz4sSas,15298
|
|
88
|
+
scope/query_builders/metric_graph.py,sha256=gxqzmPwQ428s4slCkcUp7v0DyNLeMrmnKx-CNtdF4tc,7554
|
|
89
|
+
scope/query_builders/metrics.py,sha256=MKCHuS9wySBgUS-Mv4clkl4Whn2foTotsprdMCNa2Jk,12798
|
|
90
|
+
scope/query_builders/semanticgroups.py,sha256=jTcvSSVaBwZSjomsJSWBx_Z0ZpEhdK0zA_BTBBNUbqc,1894
|
|
91
|
+
scope/query_builders/sessions.py,sha256=bSbPX5bLeE9rJJKObT_vs3UQegmhiRsEHTamF2fXsug,6381
|
|
92
|
+
scope/query_builders/symbolic.py,sha256=b_eWUz56fbsLWztcVBjBH9C38LZSJUioZhur7zx_oAs,21843
|
|
93
|
+
scope/query_builders/trajectory.py,sha256=TQqetLKLpXB5BVwEZTAc-Ct1oR7iPBB58tF82slTRUM,2967
|
|
94
|
+
scope/query_builders/types.py,sha256=k5xUFvRrnGgMBFbSon-uZ8aVVe3q2HYxC99Zyg2Vx8w,490
|
|
95
|
+
scope/query_builders/ui.py,sha256=TFWWGl9fLZiI1vvyZZhwHBa57Qa9KSRFH98aDH-5SxY,113181
|
|
96
|
+
scope/query_builders/waste_estimation.py,sha256=DtRVRPA6Xqsgi6o5Jgp7Vfy9wCYdqQkcyxKmOU6LEBM,7176
|
|
97
|
+
scope/repositories/__init__.py,sha256=2TYSEsBovJFvPPCqugYS2tV2PxuTJf0VpHiSl20sKMQ,956
|
|
98
|
+
scope/repositories/clickhouse_otel_repository.py,sha256=G2Ina5wHc6oCQLu7VRyMbhYoaUV605BL_K8pUgqJW50,4812
|
|
99
|
+
scope/repositories/otel_repository.py,sha256=xIenx1UivzhE7iFPsgbVZslqU5jOgBsv8kIKc5vemVo,2862
|
|
100
|
+
scope/repositories/sqlite_repository.py,sha256=mv69Og_-FgfVqqkkOAOX24YYSnE0kVOv9WKzxoXxo1g,7596
|
|
101
|
+
scope/scripts/__init__.py,sha256=t5U0rc_5ch8vkvHhA2QXazu2VA9bRPtzKseXaWR-BQc,100
|
|
102
|
+
scope/scripts/seed.py,sha256=XmedCm0vEREyfmWGpoeW5gmfL7PGvz1eXkVvUITGruY,1067
|
|
103
|
+
ioc_scope_api-1.0.0.dist-info/METADATA,sha256=U-l8DM4thYN6uRNLdCRQlDWVWaHcNUo9iYbjct64QLw,9299
|
|
104
|
+
ioc_scope_api-1.0.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
105
|
+
ioc_scope_api-1.0.0.dist-info/entry_points.txt,sha256=8b8Bu8-qcb8iFw7auNIhyTetTfb4gJ7qN8SvbL1F80w,39
|
|
106
|
+
ioc_scope_api-1.0.0.dist-info/RECORD,,
|
scope/__init__.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Copyright (c) 2026 Cisco Systems, Inc. and its affiliates
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
"""SCOPE public library interface.
|
|
4
|
+
|
|
5
|
+
Exports are loaded lazily so submodule imports do not eagerly pull optional
|
|
6
|
+
runtime dependencies.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
__all__ = ["SCOPEAPIClient", "Filters", "LocalClient"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def __getattr__(name: str) -> Any:
|
|
15
|
+
if name == "SCOPEAPIClient":
|
|
16
|
+
from scope.client.base import SCOPEAPIClient
|
|
17
|
+
|
|
18
|
+
return SCOPEAPIClient
|
|
19
|
+
if name == "LocalClient":
|
|
20
|
+
from scope.client.local import LocalClient
|
|
21
|
+
|
|
22
|
+
return LocalClient
|
|
23
|
+
if name == "Filters":
|
|
24
|
+
from scope.models.otel_traces import Filters
|
|
25
|
+
|
|
26
|
+
return Filters
|
|
27
|
+
raise AttributeError(f"module 'scope' has no attribute {name!r}")
|
scope/api/__init__.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Copyright (c) 2026 Cisco Systems, Inc. and its affiliates
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
"""FastAPI REST wrapper — a thin HTTP layer around the local library."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
from contextlib import asynccontextmanager
|
|
9
|
+
|
|
10
|
+
from fastapi import FastAPI, Request
|
|
11
|
+
from fastapi.responses import JSONResponse
|
|
12
|
+
from starlette.middleware.cors import CORSMiddleware
|
|
13
|
+
|
|
14
|
+
from scope.api.api_v1.api import router as v1_router
|
|
15
|
+
from scope.api.api_v2.api import router as v2_router
|
|
16
|
+
from scope.core.exceptions import SCOPEError
|
|
17
|
+
from scope.health import healthz
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@asynccontextmanager
|
|
23
|
+
async def lifespan(app: FastAPI):
|
|
24
|
+
"""Run one-time setup before the app starts serving requests."""
|
|
25
|
+
_ensure_tables()
|
|
26
|
+
_check_redis()
|
|
27
|
+
yield
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _check_redis() -> None:
|
|
31
|
+
"""Ping Redis and log the result so operators can confirm it is reachable."""
|
|
32
|
+
try:
|
|
33
|
+
from scope.core.config import settings
|
|
34
|
+
from scope.dependencies import get_redis
|
|
35
|
+
|
|
36
|
+
client = get_redis()
|
|
37
|
+
client.ping()
|
|
38
|
+
logger.info("Redis is reachable — %s", settings.CACHE_REDIS_URL)
|
|
39
|
+
logger.info("Redis CACHING ENABLED !")
|
|
40
|
+
except Exception as exc:
|
|
41
|
+
logger.warning("Redis is NOT reachable: %s", exc)
|
|
42
|
+
logger.info("Redis CACHING will be DISABLED !")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _ensure_tables() -> None:
|
|
46
|
+
"""Create tables that may not exist yet (idempotent)."""
|
|
47
|
+
try:
|
|
48
|
+
from scope.dependencies import get_db
|
|
49
|
+
from scope.query_builders.labels import CREATE_TABLE_SQL
|
|
50
|
+
|
|
51
|
+
db = next(get_db())
|
|
52
|
+
|
|
53
|
+
db.execute_command(CREATE_TABLE_SQL)
|
|
54
|
+
logger.info("trace_labels table ensured")
|
|
55
|
+
except Exception as exc:
|
|
56
|
+
logger.error("could not ensure trace_labels table: %s", exc)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
app = FastAPI(
|
|
60
|
+
title="SCOPE API",
|
|
61
|
+
description="REST API to retrieve data from databases",
|
|
62
|
+
version="0.1.0",
|
|
63
|
+
lifespan=lifespan,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# ── Centralized exception handlers ───────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@app.exception_handler(SCOPEError)
|
|
71
|
+
async def scope_error_handler(request: Request, exc: SCOPEError) -> JSONResponse:
|
|
72
|
+
"""Map SCOPE domain exceptions to structured JSON error responses."""
|
|
73
|
+
if exc.status_code < 500:
|
|
74
|
+
# Expected client errors (e.g. 404, 422) — log concisely without a traceback.
|
|
75
|
+
logger.info("%s [%d]: %s", type(exc).__name__, exc.status_code, exc.message)
|
|
76
|
+
else:
|
|
77
|
+
logger.error(
|
|
78
|
+
"%s [%d]: %s",
|
|
79
|
+
type(exc).__name__,
|
|
80
|
+
exc.status_code,
|
|
81
|
+
exc.message,
|
|
82
|
+
exc_info=exc,
|
|
83
|
+
)
|
|
84
|
+
return JSONResponse(
|
|
85
|
+
status_code=exc.status_code,
|
|
86
|
+
content={"detail": exc.message},
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@app.exception_handler(Exception)
|
|
91
|
+
async def unhandled_error_handler(request: Request, exc: Exception) -> JSONResponse:
|
|
92
|
+
"""Catch-all for unexpected errors — log and return 500."""
|
|
93
|
+
logger.error("Unhandled %s: %s", type(exc).__name__, exc, exc_info=exc)
|
|
94
|
+
return JSONResponse(
|
|
95
|
+
status_code=500,
|
|
96
|
+
content={"detail": "Internal server error"},
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# Set all CORS enabled origins
|
|
101
|
+
app.add_middleware(
|
|
102
|
+
CORSMiddleware,
|
|
103
|
+
allow_origins=["*"],
|
|
104
|
+
allow_methods=["*"],
|
|
105
|
+
allow_headers=["*"],
|
|
106
|
+
expose_headers=["*"],
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
# ── Health check ─────────────────────────────────────────────────────────────
|
|
111
|
+
@app.get("/healthz", tags=["health"])
|
|
112
|
+
def health_check():
|
|
113
|
+
"""Liveness / keep-alive probe."""
|
|
114
|
+
return healthz()
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# ── Versioned API (all new endpoints live here) ──────────────────────────────
|
|
118
|
+
app.include_router(v1_router)
|
|
119
|
+
app.include_router(v2_router)
|
scope/api/api_v1/api.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Copyright (c) 2026 Cisco Systems, Inc. and its affiliates
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
"""API v1 router — composes all v1 sub-routers under ``/api/v1``."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from fastapi import APIRouter
|
|
8
|
+
|
|
9
|
+
from scope.api.api_v1.endpoints import (
|
|
10
|
+
agentic_protocols_metrics,
|
|
11
|
+
applications,
|
|
12
|
+
cache,
|
|
13
|
+
concepts,
|
|
14
|
+
features,
|
|
15
|
+
kg,
|
|
16
|
+
labels,
|
|
17
|
+
reasoning,
|
|
18
|
+
metrics,
|
|
19
|
+
semanticgroups,
|
|
20
|
+
sessions,
|
|
21
|
+
spans,
|
|
22
|
+
symbolic,
|
|
23
|
+
ui,
|
|
24
|
+
waste_estimation,
|
|
25
|
+
live_topology,
|
|
26
|
+
)
|
|
27
|
+
from scope.health import healthz as _healthz
|
|
28
|
+
|
|
29
|
+
router = APIRouter(prefix="/api/v1", tags=["v1"])
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@router.get("/healthz")
|
|
33
|
+
def healthz() -> dict:
|
|
34
|
+
"""Version-scoped health check."""
|
|
35
|
+
return _healthz()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# ── Include domain sub-routers ────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
router.include_router(cache.router, prefix="/cache", tags=["cache"])
|
|
41
|
+
router.include_router(reasoning.router, prefix="")
|
|
42
|
+
router.include_router(
|
|
43
|
+
agentic_protocols_metrics.router,
|
|
44
|
+
prefix="",
|
|
45
|
+
tags=["agentic-protocols-metrics"],
|
|
46
|
+
)
|
|
47
|
+
router.include_router(ui.router, prefix="/ui", tags=["ui"])
|
|
48
|
+
router.include_router(kg.router, prefix="/kg", tags=["kg"])
|
|
49
|
+
router.include_router(metrics.router, prefix="/metrics", tags=["metrics"])
|
|
50
|
+
router.include_router(features.router, prefix="/features", tags=["features"])
|
|
51
|
+
router.include_router(
|
|
52
|
+
semanticgroups.router, prefix="/semanticgroups", tags=["semanticgroups"]
|
|
53
|
+
)
|
|
54
|
+
router.include_router(sessions.router, prefix="/sessions", tags=["sessions"])
|
|
55
|
+
router.include_router(spans.router, prefix="/spans", tags=["spans"])
|
|
56
|
+
router.include_router(
|
|
57
|
+
applications.router, prefix="/applications", tags=["applications"]
|
|
58
|
+
)
|
|
59
|
+
router.include_router(concepts.router, prefix="/concepts", tags=["concepts"])
|
|
60
|
+
router.include_router(labels.router, prefix="/labels", tags=["labels"])
|
|
61
|
+
router.include_router(symbolic.router, prefix="/symbolic", tags=["symbolic"])
|
|
62
|
+
router.include_router(
|
|
63
|
+
waste_estimation.router,
|
|
64
|
+
prefix="/waste-estimation",
|
|
65
|
+
tags=["waste-estimation"],
|
|
66
|
+
)
|
|
67
|
+
router.include_router(
|
|
68
|
+
live_topology.router,
|
|
69
|
+
prefix="/live_topology",
|
|
70
|
+
tags=["live_topology"],
|
|
71
|
+
)
|