ioc-scope-api 1.0.0__tar.gz → 1.2.0__tar.gz
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.2.0/.env.example +14 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/Dockerfile +15 -3
- ioc_scope_api-1.0.0/README.md → ioc_scope_api-1.2.0/PKG-INFO +55 -0
- ioc_scope_api-1.0.0/PKG-INFO → ioc_scope_api-1.2.0/README.md +23 -27
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/Taskfile.yml +10 -0
- ioc_scope_api-1.2.0/clients/.gitignore +30 -0
- ioc_scope_api-1.2.0/clients/README.md +145 -0
- ioc_scope_api-1.2.0/clients/Taskfile.yml +135 -0
- ioc_scope_api-1.2.0/clients/python/openapi-python-client.yaml +8 -0
- ioc_scope_api-1.2.0/clients/python/ruff.toml +9 -0
- ioc_scope_api-1.2.0/clients/python/scope_client/cli/__init__.py +140 -0
- ioc_scope_api-1.2.0/clients/python/scope_client/cli/__main__.py +8 -0
- ioc_scope_api-1.2.0/clients/python/scope_client/cli/commands.py +249 -0
- ioc_scope_api-1.2.0/clients/python/tests/test_cli.py +212 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/pyproject.toml +11 -1
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/__init__.py +37 -25
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/api.py +11 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/applications.py +103 -7
- ioc_scope_api-1.2.0/scope/api/api_v1/endpoints/cognition_store.py +256 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/metrics.py +23 -0
- ioc_scope_api-1.2.0/scope/api/api_v1/endpoints/realtime_events.py +63 -0
- ioc_scope_api-1.2.0/scope/api/cognition_fabric.py +81 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/_metrics.py +107 -58
- ioc_scope_api-1.2.0/scope/client/_realtime_events.py +117 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/_ui.py +65 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/applications.py +243 -17
- ioc_scope_api-1.2.0/scope/client/cognition_store.py +217 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/local.py +2 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/mock/client.py +0 -1
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/sessions.py +3 -1
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/dependencies.py +27 -2
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/interfaces/models.py +26 -0
- ioc_scope_api-1.2.0/scope/models/cognition_store.py +123 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/models/otel_traces.py +0 -1
- ioc_scope_api-1.2.0/scope/models/realtime_events.py +73 -0
- ioc_scope_api-1.2.0/scope/query_builders/cognition.py +221 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/metrics.py +17 -0
- ioc_scope_api-1.2.0/scope/query_builders/realtime_events.py +120 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/ui.py +158 -22
- ioc_scope_api-1.2.0/scripts/export_openapi.py +53 -0
- ioc_scope_api-1.2.0/specs/scope_openapi.yaml +7455 -0
- ioc_scope_api-1.2.0/tests/conftest.py +101 -0
- ioc_scope_api-1.2.0/tests/test_cognition_fabric_flag.py +62 -0
- ioc_scope_api-1.2.0/tests/test_cognition_store.py +260 -0
- ioc_scope_api-1.2.0/tests/test_cognition_store_subscriptions.py +461 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_cognitive_observability.py +13 -5
- ioc_scope_api-1.2.0/tests/test_cost_timeline_kg.py +285 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_latent_space_extra.py +3 -1
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_metrics_query_builders.py +11 -0
- ioc_scope_api-1.2.0/tests/test_realtime_events.py +466 -0
- ioc_scope_api-1.2.0/tests/test_realtime_events_clickhouse.py +353 -0
- ioc_scope_api-1.0.0/.env.example +0 -11
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/.gitignore +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/Makefile +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/data/clickhouse/otel_traces.sql +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/data/clickhouse/trace_labels.sql +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/data/csv/derived_metrics.csv +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/data/csv/derived_metrics_PassiveEvalAgents.csv +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/data/csv/otel_traces.csv +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/data/csv/otel_traces_10.csv +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/data/csv/otel_traces_working.csv +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/data/postgres/otel_traces.sql +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/data/sql/otel_traces.sql +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/deploy/docker-compose.yml +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/agentic_protocols_metrics.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/cache.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/concepts.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/features.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/helpers.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/kg.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/labels.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/live_topology.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/reasoning.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/semanticgroups.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/sessions.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/spans.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/symbolic.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/ui.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v1/endpoints/waste_estimation.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v2/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v2/api.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v2/endpoints/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/api/api_v2/endpoints/metrics.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/app.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/cache.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/_concepts.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/_kg.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/_labels.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/_live_topology.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/_semanticgroups.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/_sessions.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/_symbolic.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/agentic_protocols.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/application_charts.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/base.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/cognition_protocols.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/constants.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/dal.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/failures.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/mock/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/spans.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/client/utils.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/connectors/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/connectors/base.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/connectors/clickhouse.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/connectors/neo4j.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/connectors/sqlalchemy.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/core/config.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/core/exceptions.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/health.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/interfaces/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/interfaces/data_provider.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/interfaces/integration_example.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/interfaces/kg_provider.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/interfaces/metrics_provider.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/models/kg.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/models/live_topology.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/providers/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/providers/_graph.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/providers/cognition_protocols.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/providers/kg.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/providers/kg_query_runner.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/providers/neo4j_mce.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/providers/scope_metrics.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/cognition_protocol_graph.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/concepts.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/dal.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/failure_graph.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/features.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/kg.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/labels.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/live_topology.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/metric_graph.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/semanticgroups.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/sessions.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/symbolic.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/trajectory.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/types.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/query_builders/waste_estimation.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/repositories/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/repositories/clickhouse_otel_repository.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/repositories/otel_repository.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/repositories/sqlite_repository.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/scripts/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/scripts/seed.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scope/workarounds.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scripts/csv_to_sql.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scripts/test_metrics_sequence.sh +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/scripts/test_metrics_single.sh +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/__init__.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_496_applications.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_application_charts_v2.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_caching_and_optimizations.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_endpoint_ui.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_endpoint_ui_ch.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_endpoint_ui_data_mocker.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_exceptions.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_functions.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_kg_query_builders.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_kg_retrieval.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_metrics_before_kg.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_metrics_endpoint_filtering.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_parallel_localhost_queries.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_semanticgroups.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_symbolic_api_live_db_context_extraction.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/other/test_with_local_dbs.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_agentic_protocols_metrics.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_application_charts.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_application_sessions.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_applications.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_caching.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_clickhouse_pool.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_cognition_protocol_report_provider.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_cognition_protocols.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_dal.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_dal_metric_queries.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_failure_reports.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_ingest_insights.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_kg.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_live_topology.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_local_client_lifecycle.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_mcev2.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_metric_evaluation_cost.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_metric_reader_queries.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_metrics.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_metrics_provider_persistence.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_metrics_provider_persistence_mocks.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_neo4j_transient_errors.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_reasoning.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_session_span_links.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_sessions.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_structural_topology.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_symbolic_api.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_symbolic_api_mocks.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_trajectory_dal.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/tests/test_waste_estimation.py +0 -0
- {ioc_scope_api-1.0.0 → ioc_scope_api-1.2.0}/workers/pyproject.toml +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
CLICKHOUSE_USERNAME=
|
|
2
|
+
CLICKHOUSE_PASSWORD=
|
|
3
|
+
CLICKHOUSE_HOST=
|
|
4
|
+
CLICKHOUSE_PORT=
|
|
5
|
+
CLICKHOUSE_DATABASE=
|
|
6
|
+
|
|
7
|
+
NEO4J_HOST=
|
|
8
|
+
NEO4J_PORT=
|
|
9
|
+
NEO4J_USERNAME=
|
|
10
|
+
NEO4J_PASSWORD=
|
|
11
|
+
NEO4J_DATABASE=
|
|
12
|
+
# Optional Cognition Fabric endpoints. Requires the cognition-fabric extra and Postgres.
|
|
13
|
+
SCOPE_ENABLE_COGNITION_FABRIC_ENDPOINTS=false
|
|
14
|
+
# POSTGRES_URL=
|
|
@@ -23,16 +23,21 @@ COPY uv.lock /src/api/uv.lock
|
|
|
23
23
|
COPY api/pyproject.toml /src/api/pyproject.toml
|
|
24
24
|
COPY --from=ontology . /ontology
|
|
25
25
|
|
|
26
|
+
ARG SCOPE_API_EXTRAS=""
|
|
27
|
+
|
|
26
28
|
# Install dependencies without installing source code yet.
|
|
27
29
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
28
|
-
cd /src && uv sync --frozen --no-dev --no-install-project --no-install-workspace --no-sources --extra latent-space --extra clickhouse-sqlalchemy --project /src/api
|
|
30
|
+
cd /src && uv sync --frozen --no-dev --no-install-project --no-install-workspace --no-sources --extra latent-space --extra clickhouse-sqlalchemy $SCOPE_API_EXTRAS --project /src/api
|
|
29
31
|
|
|
30
32
|
# Copy the API source code.
|
|
31
33
|
COPY api /src/api
|
|
34
|
+
COPY mce/mce-core /src/mce/mce-core
|
|
35
|
+
COPY mce/mce-provider-native /src/mce/mce-provider-native
|
|
36
|
+
COPY mce/mce-provider-sdk /src/mce/mce-provider-sdk
|
|
32
37
|
|
|
33
38
|
# Install the ioc-scope-api package
|
|
34
39
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
35
|
-
cd /src && uv sync --frozen --no-dev --no-editable --extra latent-space --extra clickhouse-sqlalchemy --project /src/api
|
|
40
|
+
cd /src && uv sync --frozen --no-dev --no-editable --extra latent-space --extra clickhouse-sqlalchemy $SCOPE_API_EXTRAS --project /src/api
|
|
36
41
|
|
|
37
42
|
FROM python:3.13-slim-trixie AS runner
|
|
38
43
|
|
|
@@ -45,4 +50,11 @@ USER user
|
|
|
45
50
|
|
|
46
51
|
EXPOSE 8000
|
|
47
52
|
|
|
48
|
-
CMD ["/app/bin/dev"]
|
|
53
|
+
CMD ["/app/bin/dev"]
|
|
54
|
+
|
|
55
|
+
FROM runner AS cognition-fabric
|
|
56
|
+
ENV SCOPE_ENABLE_COGNITION_FABRIC_ENDPOINTS=true \
|
|
57
|
+
SCOPE_API_RELOAD=false \
|
|
58
|
+
CACHE_ENABLED=false
|
|
59
|
+
|
|
60
|
+
FROM runner AS default
|
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ioc-scope-api
|
|
3
|
+
Version: 1.2.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: cognition-fabric
|
|
24
|
+
Requires-Dist: ioc-scope-mce-core>=2.0.0; extra == 'cognition-fabric'
|
|
25
|
+
Requires-Dist: ioc-scope-mce-provider-native>=2.0.0; extra == 'cognition-fabric'
|
|
26
|
+
Requires-Dist: ioc-scope-mce-provider-sdk>=2.0.0; extra == 'cognition-fabric'
|
|
27
|
+
Requires-Dist: psycopg2-binary>=2.9.10; extra == 'cognition-fabric'
|
|
28
|
+
Provides-Extra: latent-space
|
|
29
|
+
Requires-Dist: numba>=0.60.0; extra == 'latent-space'
|
|
30
|
+
Requires-Dist: umap-learn>=0.5.7; extra == 'latent-space'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
1
33
|
# SCOPE API
|
|
2
34
|
|
|
3
35
|
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.
|
|
@@ -32,6 +64,29 @@ The API will be available at **http://127.0.0.1:8000**.
|
|
|
32
64
|
|
|
33
65
|
OpenAPI specification docs are available at **http://127.0.0.1:8000/docs**.
|
|
34
66
|
|
|
67
|
+
## Cognition Fabric endpoints
|
|
68
|
+
|
|
69
|
+
`SCOPE_ENABLE_COGNITION_FABRIC_ENDPOINTS` is read at startup and defaults to `false`.
|
|
70
|
+
When disabled, the following routes are not registered or included in OpenAPI,
|
|
71
|
+
and startup does not initialize the Cognition Store database.
|
|
72
|
+
|
|
73
|
+
When enabled, `/api/v1/realtime` reads normalized events from ClickHouse by
|
|
74
|
+
session ID, span ID, or event ID. `/api/v1/cognition-store` provides item,
|
|
75
|
+
subscription, and finding operations backed by Postgres. Set `POSTGRES_URL`
|
|
76
|
+
(or `POSTGRES_HOST`, `POSTGRES_PORT`, `POSTGRES_USER`, `POSTGRES_PASSWORD`,
|
|
77
|
+
and `POSTGRES_DB`) to a database where the app can initialize its tables.
|
|
78
|
+
|
|
79
|
+
To run locally from `backend/api`:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
SCOPE_ENABLE_COGNITION_FABRIC_ENDPOINTS=true SCOPE_API_PORT=8081 \
|
|
83
|
+
uv run --locked --package ioc-scope-api --extra cognition-fabric dev
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The [Cognition Fabric Compose stack](../../integrations/cognition-fabric)
|
|
87
|
+
enables these endpoints on port `8081`. See the [Python client guide](clients/README.md)
|
|
88
|
+
for generated client and CLI usage.
|
|
89
|
+
|
|
35
90
|
## Running tests
|
|
36
91
|
|
|
37
92
|
```bash
|
|
@@ -1,30 +1,3 @@
|
|
|
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
1
|
# SCOPE API
|
|
29
2
|
|
|
30
3
|
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.
|
|
@@ -59,6 +32,29 @@ The API will be available at **http://127.0.0.1:8000**.
|
|
|
59
32
|
|
|
60
33
|
OpenAPI specification docs are available at **http://127.0.0.1:8000/docs**.
|
|
61
34
|
|
|
35
|
+
## Cognition Fabric endpoints
|
|
36
|
+
|
|
37
|
+
`SCOPE_ENABLE_COGNITION_FABRIC_ENDPOINTS` is read at startup and defaults to `false`.
|
|
38
|
+
When disabled, the following routes are not registered or included in OpenAPI,
|
|
39
|
+
and startup does not initialize the Cognition Store database.
|
|
40
|
+
|
|
41
|
+
When enabled, `/api/v1/realtime` reads normalized events from ClickHouse by
|
|
42
|
+
session ID, span ID, or event ID. `/api/v1/cognition-store` provides item,
|
|
43
|
+
subscription, and finding operations backed by Postgres. Set `POSTGRES_URL`
|
|
44
|
+
(or `POSTGRES_HOST`, `POSTGRES_PORT`, `POSTGRES_USER`, `POSTGRES_PASSWORD`,
|
|
45
|
+
and `POSTGRES_DB`) to a database where the app can initialize its tables.
|
|
46
|
+
|
|
47
|
+
To run locally from `backend/api`:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
SCOPE_ENABLE_COGNITION_FABRIC_ENDPOINTS=true SCOPE_API_PORT=8081 \
|
|
51
|
+
uv run --locked --package ioc-scope-api --extra cognition-fabric dev
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The [Cognition Fabric Compose stack](../../integrations/cognition-fabric)
|
|
55
|
+
enables these endpoints on port `8081`. See the [Python client guide](clients/README.md)
|
|
56
|
+
for generated client and CLI usage.
|
|
57
|
+
|
|
62
58
|
## Running tests
|
|
63
59
|
|
|
64
60
|
```bash
|
|
@@ -8,7 +8,17 @@ vars:
|
|
|
8
8
|
METRIC_ID: '{{.METRIC_ID | default "Duration"}}'
|
|
9
9
|
COMPUTE_METRIC_ID: '{{.COMPUTE_METRIC_ID | default "Cost"}}'
|
|
10
10
|
|
|
11
|
+
includes:
|
|
12
|
+
clients:
|
|
13
|
+
taskfile: ./clients
|
|
14
|
+
dir: ./clients
|
|
15
|
+
|
|
11
16
|
tasks:
|
|
17
|
+
openapi:
|
|
18
|
+
desc: Export the OpenAPI spec with the Cognition Fabric routes enabled
|
|
19
|
+
cmds:
|
|
20
|
+
- uv run --locked --package ioc-scope-api --group client-gen python scripts/export_openapi.py -o specs/scope_openapi.yaml
|
|
21
|
+
|
|
12
22
|
test-env:
|
|
13
23
|
desc: Recreate the dedicated test virtualenv with project and dev dependencies
|
|
14
24
|
cmds:
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright (c) 2026 Cisco Systems, Inc. and its affiliates
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
# Generated by `task clients:generate` / CI (openapi-python-client) from specs/scope_openapi.yaml.
|
|
5
|
+
# Only the hand-written parts of python/ (scope_client/cli/, tests/, openapi-python-client.yaml) are committed.
|
|
6
|
+
# This file lives here, not in python/, because the generator overwrites python/.gitignore.
|
|
7
|
+
python/.gitignore
|
|
8
|
+
python/README.md
|
|
9
|
+
python/pyproject.toml
|
|
10
|
+
python/setup.py
|
|
11
|
+
python/scope_client/__init__.py
|
|
12
|
+
python/scope_client/api/
|
|
13
|
+
python/scope_client/models/
|
|
14
|
+
python/scope_client/client.py
|
|
15
|
+
python/scope_client/errors.py
|
|
16
|
+
python/scope_client/py.typed
|
|
17
|
+
python/scope_client/types.py
|
|
18
|
+
|
|
19
|
+
# Build and local environment artifacts
|
|
20
|
+
python/dist/
|
|
21
|
+
python/build/
|
|
22
|
+
python/*.egg-info/
|
|
23
|
+
python/uv.lock
|
|
24
|
+
python/.venv/
|
|
25
|
+
python/.ruff_cache/
|
|
26
|
+
python/.pytest_cache/
|
|
27
|
+
__pycache__/
|
|
28
|
+
|
|
29
|
+
# Task cache
|
|
30
|
+
.task
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) 2026 Cisco Systems, Inc. and its affiliates
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
# Cognition Fabric API client
|
|
7
|
+
|
|
8
|
+
## Python (`python/`)
|
|
9
|
+
|
|
10
|
+
The client package is **generated** from `../specs/scope_openapi.yaml` with
|
|
11
|
+
[openapi-python-client](https://github.com/openapi-generators/openapi-python-client) and is not
|
|
12
|
+
committed. Only the hand-written parts are in git: `python/openapi-python-client.yaml` (generator
|
|
13
|
+
config), `python/scope_client/cli/` (the CLI, shipped inside the package) and `python/tests/`.
|
|
14
|
+
|
|
15
|
+
The generator version is pinned in the `client-gen` dependency group of `api/pyproject.toml`
|
|
16
|
+
(locked in `backend/uv.lock`) and installed with uv; bump it there.
|
|
17
|
+
|
|
18
|
+
Run these from `backend/api`:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
task clients:generate # (re)generate; skipped when the spec/config are unchanged
|
|
22
|
+
task clients:test-unit # CLI unit tests
|
|
23
|
+
task clients:ci # smoke tests against a running API (default http://localhost:8081)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
CLI: `python -m scope_client.cli [--base-url URL] [--token T] <command>`; see `--help`.
|
|
27
|
+
|
|
28
|
+
### Install
|
|
29
|
+
|
|
30
|
+
The package name is `ioc-scope-client`; the Python import is `scope_client`. The generated
|
|
31
|
+
client requires Python 3.11 or later. Generating it in this repository uses the
|
|
32
|
+
workspace's Python 3.13 or later.
|
|
33
|
+
|
|
34
|
+
After a version has been published, install it from public PyPI:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
python -m pip install ioc-scope-client
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
To build and install locally instead, run these commands from
|
|
41
|
+
`backend/api`:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
uv run --locked --package ioc-scope-api --only-group client-gen \
|
|
45
|
+
openapi-python-client generate \
|
|
46
|
+
--path specs/scope_openapi.yaml \
|
|
47
|
+
--config clients/python/openapi-python-client.yaml \
|
|
48
|
+
--meta setup --output-path clients/python --overwrite
|
|
49
|
+
uv build --wheel clients/python
|
|
50
|
+
uv venv --python 3.11 clients/python/.venv
|
|
51
|
+
uv pip install --python clients/python/.venv/bin/python clients/python/dist/*.whl
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Generation is required before building: the generated package and its metadata
|
|
55
|
+
are not committed. The generated `python/README.md` is overwritten by generation;
|
|
56
|
+
keep maintained usage documentation here.
|
|
57
|
+
|
|
58
|
+
### Call the API
|
|
59
|
+
|
|
60
|
+
The client calls a running Cognition Fabric API over HTTP; it does not start the server
|
|
61
|
+
or connect directly to its databases. Set the base URL to the server or gateway
|
|
62
|
+
root, without appending `/api/v1`. The examples use `http://localhost:8000`, the
|
|
63
|
+
API container port; with the root Docker Compose file the API is published on
|
|
64
|
+
`http://localhost:8081`.
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from http import HTTPStatus
|
|
68
|
+
|
|
69
|
+
import httpx
|
|
70
|
+
|
|
71
|
+
from scope_client import Client
|
|
72
|
+
from scope_client.api.v1 import (
|
|
73
|
+
get_application_names_api_v1_ui_applications_names_get as application_names,
|
|
74
|
+
)
|
|
75
|
+
from scope_client.models import ApplicationNamesResponse
|
|
76
|
+
|
|
77
|
+
with Client(
|
|
78
|
+
base_url="http://localhost:8000",
|
|
79
|
+
timeout=httpx.Timeout(30.0),
|
|
80
|
+
raise_on_unexpected_status=True,
|
|
81
|
+
) as client:
|
|
82
|
+
response = application_names.sync_detailed(client=client, limit=10)
|
|
83
|
+
if response.status_code != HTTPStatus.OK:
|
|
84
|
+
raise RuntimeError(f"API returned {response.status_code}: {response.content!r}")
|
|
85
|
+
if not isinstance(response.parsed, ApplicationNamesResponse):
|
|
86
|
+
raise RuntimeError("API returned an unexpected response")
|
|
87
|
+
print(response.parsed.to_dict())
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Use `AuthenticatedClient(base_url=..., token=...)` instead of `Client` when the
|
|
91
|
+
gateway requires bearer authentication. Each generated endpoint also provides
|
|
92
|
+
`sync`, `asyncio`, and `asyncio_detailed` functions.
|
|
93
|
+
|
|
94
|
+
### CLI
|
|
95
|
+
|
|
96
|
+
With the package installed in the active Python environment:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
export SCOPE_BASE_URL=http://localhost:8000 # use :8081 with Docker Compose
|
|
100
|
+
# If your gateway requires authentication, set SCOPE_TOKEN in your environment.
|
|
101
|
+
python -m scope_client.cli health
|
|
102
|
+
python -m scope_client.cli applications --limit 10
|
|
103
|
+
python -m scope_client.cli sessions --limit 10
|
|
104
|
+
python -m scope_client.cli --help
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Cognition-store commands (the `/api/v1/cognition-store` routes, generated from `scope_openapi.yaml` like the rest of the client):
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
python -m scope_client.cli cognition-info
|
|
111
|
+
python -m scope_client.cli store-put --ce-id <uuid> --namespace ns --key k --type t --value '{"a": 1}'
|
|
112
|
+
python -m scope_client.cli store-list --namespace ns --key k
|
|
113
|
+
python -m scope_client.cli subscribe --namespace ns --type t --callback-url https://example.com/hook
|
|
114
|
+
python -m scope_client.cli subscriptions --namespace ns
|
|
115
|
+
python -m scope_client.cli unsubscribe <subscription-uuid>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The CLI defaults to `http://localhost:8006`; the Taskfile smoke tests default to
|
|
119
|
+
`http://localhost:8081` for Docker Compose. Set `SCOPE_BASE_URL` explicitly for your
|
|
120
|
+
deployment. Keep TLS certificate verification enabled; use `--ca-bundle` when
|
|
121
|
+
your gateway requires a custom CA.
|
|
122
|
+
|
|
123
|
+
### CI and releases
|
|
124
|
+
|
|
125
|
+
SCOPE's [Publish Package workflow](../../../../../.github/workflows/publish-packages.yml)
|
|
126
|
+
generates, tests, and builds the client. Before the first upload, configure a PyPI
|
|
127
|
+
Trusted Publisher for `ioc-scope-client`: repository `ioc-project/scope`, workflow
|
|
128
|
+
`publish-packages.yml`, environment `pypi-ioc-scope-client`. For a project that does not
|
|
129
|
+
exist yet, register it as a pending publisher in PyPI.
|
|
130
|
+
|
|
131
|
+
Run the workflow manually with `package: ioc-scope-client` and `publish: false`
|
|
132
|
+
to verify the build without uploading. Select `publish: true` to release it.
|
|
133
|
+
The workflow also publishes on `package-v*` tags. The client version comes
|
|
134
|
+
from the spec's `info.version`; bump it even for CLI-only releases.
|
|
135
|
+
|
|
136
|
+
For a new release, including a CLI-only release:
|
|
137
|
+
|
|
138
|
+
1. Update the FastAPI version in `../scope/api/__init__.py`.
|
|
139
|
+
2. Run `task openapi` from `backend/api` and commit the updated spec.
|
|
140
|
+
3. Ensure the client generation, build, and test checks pass before merging.
|
|
141
|
+
4. After merging, run the publish workflow with `publish: true` or use the
|
|
142
|
+
package release tag. Verify the new version can be installed from PyPI.
|
|
143
|
+
|
|
144
|
+
Treat published versions as immutable. A successful job that skips an existing
|
|
145
|
+
artifact does not release updated code under that version.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Copyright (c) 2026 Cisco Systems, Inc. and its affiliates
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
version: "3"
|
|
5
|
+
|
|
6
|
+
# Defaults match the Cognition Fabric API in the integration's docker-compose.yml
|
|
7
|
+
# (host port 8081, no auth). Override with env vars or `task SCOPE_BASE_URL=...`.
|
|
8
|
+
# A bearer token is read from SCOPE_TOKEN by the CLI. Global CLI options (--expect-*, --retries)
|
|
9
|
+
# must come before the subcommand.
|
|
10
|
+
vars:
|
|
11
|
+
SCOPE_BASE_URL: '{{.SCOPE_BASE_URL | default "http://localhost:8081"}}'
|
|
12
|
+
WAIT_RETRIES: '{{.WAIT_RETRIES | default "30"}}'
|
|
13
|
+
WAIT_DELAY: '{{.WAIT_DELAY | default "2"}}'
|
|
14
|
+
COMPOSE_FILE: ../../../integrations/cognition-fabric/docker-compose.yml
|
|
15
|
+
SPEC: ../../specs/scope_openapi.yaml
|
|
16
|
+
CLI: uv run --with httpx --with attrs python -m scope_client.cli --base-url {{.SCOPE_BASE_URL}}
|
|
17
|
+
|
|
18
|
+
tasks:
|
|
19
|
+
default:
|
|
20
|
+
silent: true
|
|
21
|
+
cmds:
|
|
22
|
+
- task -l
|
|
23
|
+
|
|
24
|
+
generate:
|
|
25
|
+
desc: Generate the Python client from the OpenAPI spec (regenerates only when the spec or config changes)
|
|
26
|
+
dir: python
|
|
27
|
+
run: once
|
|
28
|
+
sources:
|
|
29
|
+
- "{{.SPEC}}"
|
|
30
|
+
- openapi-python-client.yaml
|
|
31
|
+
- ../../pyproject.toml
|
|
32
|
+
- ../../../uv.lock
|
|
33
|
+
generates:
|
|
34
|
+
- scope_client/client.py
|
|
35
|
+
cmds:
|
|
36
|
+
- uv run --locked --project ../.. --package ioc-scope-api --only-group client-gen openapi-python-client generate --path {{.SPEC}} --config openapi-python-client.yaml --meta setup --output-path . --overwrite
|
|
37
|
+
|
|
38
|
+
up:
|
|
39
|
+
desc: Start the Cognition Fabric API and its dependencies from the integration's Compose file
|
|
40
|
+
cmds:
|
|
41
|
+
- docker compose -f {{.COMPOSE_FILE}} up -d ioc-analytics-api
|
|
42
|
+
|
|
43
|
+
down:
|
|
44
|
+
desc: Stop the services started by the root docker-compose.yml
|
|
45
|
+
cmds:
|
|
46
|
+
- docker compose -f {{.COMPOSE_FILE}} down
|
|
47
|
+
|
|
48
|
+
wait:
|
|
49
|
+
desc: Wait for the API to answer /healthz (WAIT_RETRIES x WAIT_DELAY seconds)
|
|
50
|
+
deps: [generate]
|
|
51
|
+
dir: python
|
|
52
|
+
cmds:
|
|
53
|
+
- "{{.CLI}} --retries {{.WAIT_RETRIES}} --retry-delay {{.WAIT_DELAY}} health"
|
|
54
|
+
|
|
55
|
+
test-health:
|
|
56
|
+
desc: Check /healthz and /api/v1/healthz
|
|
57
|
+
deps: [generate]
|
|
58
|
+
dir: python
|
|
59
|
+
cmds:
|
|
60
|
+
- "{{.CLI}} health"
|
|
61
|
+
- "{{.CLI}} health --v1"
|
|
62
|
+
|
|
63
|
+
test-features-info:
|
|
64
|
+
desc: Check /api/v1/features/info
|
|
65
|
+
deps: [generate]
|
|
66
|
+
dir: python
|
|
67
|
+
cmds:
|
|
68
|
+
- "{{.CLI}} features-info"
|
|
69
|
+
|
|
70
|
+
test-metrics-catalog:
|
|
71
|
+
desc: Check that the metrics catalog responds with a schema-valid body
|
|
72
|
+
deps: [generate]
|
|
73
|
+
dir: python
|
|
74
|
+
cmds:
|
|
75
|
+
- "{{.CLI}} --expect-json-key total --expect-json-key metrics metrics-catalog"
|
|
76
|
+
|
|
77
|
+
test-sessions:
|
|
78
|
+
desc: Check the session and application listings (empty results are fine)
|
|
79
|
+
deps: [generate]
|
|
80
|
+
dir: python
|
|
81
|
+
cmds:
|
|
82
|
+
- "{{.CLI}} --expect-json-key sessions sessions --limit 1"
|
|
83
|
+
- "{{.CLI}} --expect-json-key applications applications --limit 1"
|
|
84
|
+
|
|
85
|
+
test-session-data:
|
|
86
|
+
desc: Check spans and metric compute for SESSION_ID (skipped when SESSION_ID is unset)
|
|
87
|
+
deps: [generate]
|
|
88
|
+
dir: python
|
|
89
|
+
status:
|
|
90
|
+
- test -z "{{.SESSION_ID}}"
|
|
91
|
+
cmds:
|
|
92
|
+
- "{{.CLI}} --expect-json-key spans session-spans {{.SESSION_ID}} --limit 1"
|
|
93
|
+
- "{{.CLI}} metrics-compute --session-id {{.SESSION_ID}} --metric {{.METRIC_ID | default \"Cost\"}}"
|
|
94
|
+
|
|
95
|
+
test-cognition-store:
|
|
96
|
+
desc: Check the cognition store - info, item upsert and lookup, subscription create/list/cancel
|
|
97
|
+
deps: [generate]
|
|
98
|
+
dir: python
|
|
99
|
+
vars:
|
|
100
|
+
CE_ID: 00000000-0000-0000-0000-000000000001
|
|
101
|
+
NS: scope-client-smoke
|
|
102
|
+
cmds:
|
|
103
|
+
- "{{.CLI}} --expect-json-key item_count cognition-info"
|
|
104
|
+
- "{{.CLI}} --expect-json-key key store-put --ce-id {{.CE_ID}} --namespace {{.NS}} --key smoke --type smoke --value '{\"ok\": true}'"
|
|
105
|
+
- "{{.CLI}} store-list --namespace {{.NS}} --key smoke"
|
|
106
|
+
- "{{.CLI}} subscriptions --namespace {{.NS}}"
|
|
107
|
+
- |
|
|
108
|
+
ID=$({{.CLI}} --expect-json-key id subscribe --namespace {{.NS}} --type smoke --callback-url http://localhost:9/hook | python -c 'import json,sys; print(json.load(sys.stdin)["id"])')
|
|
109
|
+
{{.CLI}} unsubscribe "$ID"
|
|
110
|
+
|
|
111
|
+
lint:
|
|
112
|
+
desc: Check formatting and lint of the hand-written client code (CLI and tests) with ruff
|
|
113
|
+
dir: python
|
|
114
|
+
cmds:
|
|
115
|
+
- uv run --locked --project ../.. --package ioc-scope-api --only-group client-gen ruff format --check scope_client/cli tests
|
|
116
|
+
- uv run --locked --project ../.. --package ioc-scope-api --only-group client-gen ruff check scope_client/cli tests
|
|
117
|
+
|
|
118
|
+
test-unit:
|
|
119
|
+
desc: Run the CLI unit tests (no server needed)
|
|
120
|
+
deps: [generate]
|
|
121
|
+
dir: python
|
|
122
|
+
cmds:
|
|
123
|
+
- uv run --no-project --with pytest --with httpx --with attrs python -m pytest -q tests
|
|
124
|
+
|
|
125
|
+
ci:
|
|
126
|
+
desc: Wait for the API, then run all smoke tests against it
|
|
127
|
+
cmds:
|
|
128
|
+
- task: lint
|
|
129
|
+
- task: wait
|
|
130
|
+
- task: test-health
|
|
131
|
+
- task: test-features-info
|
|
132
|
+
- task: test-metrics-catalog
|
|
133
|
+
- task: test-sessions
|
|
134
|
+
- task: test-cognition-store
|
|
135
|
+
- task: test-session-data
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Copyright (c) 2026 Cisco Systems, Inc. and its affiliates
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
# Takes precedence over the generated pyproject.toml (git-ignored), so ruff behaves the same
|
|
5
|
+
# in CI, where the client has not been generated, as it does locally and in the generator's post_hooks.
|
|
6
|
+
line-length = 120
|
|
7
|
+
|
|
8
|
+
[lint]
|
|
9
|
+
select = ["F", "I", "UP"]
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Copyright (c) 2026 Cisco Systems, Inc. and its affiliates
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
"""Command line interface for making simple requests to the SCOPE API.
|
|
5
|
+
|
|
6
|
+
Usage: ``python -m scope_client.cli [options] <command> [command options]``.
|
|
7
|
+
|
|
8
|
+
Exit codes: 0 success, 1 unexpected status or failed assertion, 2 usage error, 3 connection error or timeout.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import argparse
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import sys
|
|
15
|
+
import time
|
|
16
|
+
from collections.abc import Sequence
|
|
17
|
+
from typing import Any
|
|
18
|
+
|
|
19
|
+
import httpx
|
|
20
|
+
|
|
21
|
+
from ..client import AuthenticatedClient, Client
|
|
22
|
+
from .commands import COMMANDS
|
|
23
|
+
|
|
24
|
+
DEFAULT_BASE_URL = "http://localhost:8006"
|
|
25
|
+
|
|
26
|
+
EXIT_OK = 0
|
|
27
|
+
EXIT_FAILED = 1
|
|
28
|
+
EXIT_USAGE = 2
|
|
29
|
+
EXIT_CONNECTION = 3
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _build_parser() -> argparse.ArgumentParser:
|
|
33
|
+
parser = argparse.ArgumentParser(
|
|
34
|
+
prog="scope_client.cli", description="Make simple requests to the Cognition Fabric API."
|
|
35
|
+
)
|
|
36
|
+
parser.add_argument(
|
|
37
|
+
"--base-url", default=os.environ.get("SCOPE_BASE_URL", DEFAULT_BASE_URL), help="env: SCOPE_BASE_URL"
|
|
38
|
+
)
|
|
39
|
+
parser.add_argument("--token", default=os.environ.get("SCOPE_TOKEN"), help="Bearer token; env: SCOPE_TOKEN")
|
|
40
|
+
parser.add_argument("--timeout", type=float, default=30.0, help="Request timeout in seconds")
|
|
41
|
+
parser.add_argument("--insecure", action="store_true", help="Disable TLS certificate verification")
|
|
42
|
+
parser.add_argument("--ca-bundle", help="Path to a CA bundle for TLS verification")
|
|
43
|
+
parser.add_argument("--output", choices=["json", "raw"], default="json", help="Body format (default: pretty json)")
|
|
44
|
+
parser.add_argument(
|
|
45
|
+
"--expect-status", type=int, help="Expected HTTP status (default: any 2xx); mismatch exits with 1"
|
|
46
|
+
)
|
|
47
|
+
parser.add_argument(
|
|
48
|
+
"--expect-json-key", action="append", default=[], help="Top-level key required in the JSON body (repeatable)"
|
|
49
|
+
)
|
|
50
|
+
parser.add_argument("--retries", type=int, default=0, help="Retries on connection error or failed expectation")
|
|
51
|
+
parser.add_argument("--retry-delay", type=float, default=2.0, help="Seconds between retries")
|
|
52
|
+
parser.add_argument("-v", "--verbose", action="store_true", help="Print status line to stderr")
|
|
53
|
+
|
|
54
|
+
sub = parser.add_subparsers(dest="command", required=True, metavar="command")
|
|
55
|
+
for name, command in COMMANDS.items():
|
|
56
|
+
command.add_arguments(sub.add_parser(name, help=command.help, description=command.help))
|
|
57
|
+
return parser
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _make_client(args: argparse.Namespace) -> AuthenticatedClient | Client:
|
|
61
|
+
verify: bool | str = args.ca_bundle or (not args.insecure)
|
|
62
|
+
kwargs: dict[str, Any] = {
|
|
63
|
+
"base_url": args.base_url,
|
|
64
|
+
"timeout": httpx.Timeout(args.timeout),
|
|
65
|
+
"verify_ssl": verify,
|
|
66
|
+
"raise_on_unexpected_status": False,
|
|
67
|
+
}
|
|
68
|
+
if args.token:
|
|
69
|
+
return AuthenticatedClient(token=args.token, **kwargs)
|
|
70
|
+
return Client(**kwargs)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _check(args: argparse.Namespace, status: int, content: bytes) -> str | None:
|
|
74
|
+
"""Return a failure reason, or None if the response meets expectations."""
|
|
75
|
+
if args.expect_status is not None:
|
|
76
|
+
if status != args.expect_status:
|
|
77
|
+
return f"expected status {args.expect_status}, got {status}"
|
|
78
|
+
elif not 200 <= status < 300:
|
|
79
|
+
return f"unexpected status {status}"
|
|
80
|
+
if args.expect_json_key:
|
|
81
|
+
try:
|
|
82
|
+
body = json.loads(content)
|
|
83
|
+
except ValueError:
|
|
84
|
+
return "body is not valid JSON"
|
|
85
|
+
if not isinstance(body, dict):
|
|
86
|
+
return "body is not a JSON object"
|
|
87
|
+
missing = [key for key in args.expect_json_key if key not in body]
|
|
88
|
+
if missing:
|
|
89
|
+
return f"missing JSON key(s): {', '.join(missing)}"
|
|
90
|
+
return None
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _format_body(args: argparse.Namespace, content: bytes) -> str:
|
|
94
|
+
text = content.decode("utf-8", errors="replace")
|
|
95
|
+
if args.output == "json":
|
|
96
|
+
try:
|
|
97
|
+
return json.dumps(json.loads(text), indent=2)
|
|
98
|
+
except ValueError:
|
|
99
|
+
pass
|
|
100
|
+
return text
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
104
|
+
args = _build_parser().parse_args(argv)
|
|
105
|
+
command = COMMANDS[args.command]
|
|
106
|
+
|
|
107
|
+
attempts = max(args.retries, 0) + 1
|
|
108
|
+
failure = "no attempt made"
|
|
109
|
+
exit_code = EXIT_FAILED
|
|
110
|
+
with _make_client(args) as client:
|
|
111
|
+
for attempt in range(1, attempts + 1):
|
|
112
|
+
if attempt > 1:
|
|
113
|
+
time.sleep(args.retry_delay)
|
|
114
|
+
try:
|
|
115
|
+
response = command.run(client, args)
|
|
116
|
+
except httpx.HTTPError as exc:
|
|
117
|
+
failure, exit_code = f"{type(exc).__name__}: {exc}", EXIT_CONNECTION
|
|
118
|
+
print(f"attempt {attempt}/{attempts}: {failure}", file=sys.stderr)
|
|
119
|
+
continue
|
|
120
|
+
except (KeyError, TypeError, ValueError) as exc:
|
|
121
|
+
# The generated parsers raise when a 2xx body doesn't match the spec'd schema.
|
|
122
|
+
failure, exit_code = (
|
|
123
|
+
f"response does not match the OpenAPI schema ({type(exc).__name__}: {exc})",
|
|
124
|
+
EXIT_FAILED,
|
|
125
|
+
)
|
|
126
|
+
print(f"attempt {attempt}/{attempts}: {failure}", file=sys.stderr)
|
|
127
|
+
continue
|
|
128
|
+
status = int(response.status_code)
|
|
129
|
+
if args.verbose:
|
|
130
|
+
print(f"HTTP {status}", file=sys.stderr)
|
|
131
|
+
reason = _check(args, status, response.content)
|
|
132
|
+
if response.content:
|
|
133
|
+
print(_format_body(args, response.content))
|
|
134
|
+
if reason is None:
|
|
135
|
+
return EXIT_OK
|
|
136
|
+
failure, exit_code = reason, EXIT_FAILED
|
|
137
|
+
print(f"attempt {attempt}/{attempts}: {failure}", file=sys.stderr)
|
|
138
|
+
|
|
139
|
+
print(f"error: {failure}", file=sys.stderr)
|
|
140
|
+
return exit_code
|