LogstashUI 0.5.5.dev0__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.
- AI/__init__.py +0 -0
- AI/integration_factory.py +1392 -0
- AI/migrations/0001_initial.py +58 -0
- AI/migrations/0002_draftdefinition_normalizers.py +23 -0
- AI/migrations/0003_delete_aisettings_delete_draftdefinition.py +19 -0
- AI/migrations/__init__.py +0 -0
- AI/models.py +5 -0
- AI/static/js/integration_factory.js +1102 -0
- AI/system_prompts/dashboard_generator.md +367 -0
- AI/system_prompts/grok_patterns.txt +95 -0
- AI/system_prompts/ingest_pipeline_generator.md +331 -0
- AI/system_prompts/ingest_pipeline_processors.json +2851 -0
- AI/system_prompts/ingest_verifier.md +84 -0
- AI/system_prompts/integrations_list.json +2690 -0
- AI/system_prompts/log_classifier.md +134 -0
- AI/system_prompts/template_creator.md +123 -0
- AI/templates/integration_factory.html +200 -0
- AI/urls.py +16 -0
- AI/views.py +20 -0
- API/__init__.py +0 -0
- API/admin.py +7 -0
- API/api.http +784 -0
- API/apps.py +9 -0
- API/auth.py +101 -0
- API/connections_views.py +312 -0
- API/guides.py +88 -0
- API/mcp/__init__.py +5 -0
- API/mcp/dispatch.py +179 -0
- API/mcp/tools.py +890 -0
- API/mcp/views.py +215 -0
- API/migrations/__init__.py +0 -0
- API/models.py +7 -0
- API/pipelines_views.py +1224 -0
- API/policies_views.py +1015 -0
- API/security_views.py +488 -0
- API/simulation_detail.py +219 -0
- API/snmp_views.py +1539 -0
- API/urls.py +81 -0
- Common/__init__.py +0 -0
- Common/ai/agent_builder.py +690 -0
- Common/context_processors.py +49 -0
- Common/decorators.py +68 -0
- Common/elastic_utils.py +1154 -0
- Common/encryption.py +271 -0
- Common/error_handlers.py +65 -0
- Common/formatters.py +106 -0
- Common/logstash_config_parse.py +1469 -0
- Common/logstash_utils.py +34 -0
- Common/middleware.py +216 -0
- Common/product_ca.py +1124 -0
- Common/validators.py +66 -0
- Documentation/__init__.py +0 -0
- Documentation/admin.py +7 -0
- Documentation/apps.py +9 -0
- Documentation/content/CHANGELOG.md +890 -0
- Documentation/content/docs/getting_started.md +92 -0
- Documentation/content/docs/index.md +124 -0
- Documentation/content/docs/logstashagent/configuration/index.md +60 -0
- Documentation/content/docs/logstashagent/configuration/logstashagent.yml.md +141 -0
- Documentation/content/docs/logstashagent/general/build.md +217 -0
- Documentation/content/docs/logstashagent/general/index.md +38 -0
- Documentation/content/docs/logstashagent/general/roles.md +267 -0
- Documentation/content/docs/logstashagent/index.md +264 -0
- Documentation/content/docs/logstashui/SNMP/Quickstart.md +94 -0
- Documentation/content/docs/logstashui/SNMP/architecture.md +64 -0
- Documentation/content/docs/logstashui/SNMP/configuration.md +147 -0
- Documentation/content/docs/logstashui/SNMP/data_overview.md +59 -0
- Documentation/content/docs/logstashui/SNMP/deploying_changes.md +71 -0
- Documentation/content/docs/logstashui/SNMP/device_support.md +39 -0
- Documentation/content/docs/logstashui/SNMP/discovery.md +48 -0
- Documentation/content/docs/logstashui/SNMP/index.md +58 -0
- Documentation/content/docs/logstashui/SNMP/pipeline_generation.md +63 -0
- Documentation/content/docs/logstashui/SNMP/schema.md +595 -0
- Documentation/content/docs/logstashui/SNMP/testing.md +47 -0
- Documentation/content/docs/logstashui/SNMP/traps.md +45 -0
- Documentation/content/docs/logstashui/SNMP/tsds_implementation.md +82 -0
- Documentation/content/docs/logstashui/agent_guides/concepts.md +25 -0
- Documentation/content/docs/logstashui/agent_guides/deploy.md +30 -0
- Documentation/content/docs/logstashui/agent_guides/pipeline-review.md +24 -0
- Documentation/content/docs/logstashui/agent_guides/simulation.md +55 -0
- Documentation/content/docs/logstashui/agent_guides/snmp.md +57 -0
- Documentation/content/docs/logstashui/agent_guides/troubleshooting.md +21 -0
- Documentation/content/docs/logstashui/architecture.md +11 -0
- Documentation/content/docs/logstashui/compatibility.md +58 -0
- Documentation/content/docs/logstashui/configuration/environment.md +193 -0
- Documentation/content/docs/logstashui/configuration/host_mode.md +94 -0
- Documentation/content/docs/logstashui/configuration/index.md +72 -0
- Documentation/content/docs/logstashui/configuration/logstash_proxy.md +138 -0
- Documentation/content/docs/logstashui/configuration/logstashui.yml.md +16 -0
- Documentation/content/docs/logstashui/configuration/simulation.md +84 -0
- Documentation/content/docs/logstashui/database/examples/README.md +15 -0
- Documentation/content/docs/logstashui/database/examples/create-mariadb.sql +13 -0
- Documentation/content/docs/logstashui/database/examples/create-mysql.sql +12 -0
- Documentation/content/docs/logstashui/database/examples/create-postgresql.sql +13 -0
- Documentation/content/docs/logstashui/database/examples/schema-mysql.sql +502 -0
- Documentation/content/docs/logstashui/database/examples/schema-postgresql.sql +1709 -0
- Documentation/content/docs/logstashui/database/index.md +79 -0
- Documentation/content/docs/logstashui/database/migration.md +75 -0
- Documentation/content/docs/logstashui/general/build.md +154 -0
- Documentation/content/docs/logstashui/general/deploy.md +122 -0
- Documentation/content/docs/logstashui/general/deployment-recs.md +32 -0
- Documentation/content/docs/logstashui/general/index.md +62 -0
- Documentation/content/docs/logstashui/general/offline.md +68 -0
- Documentation/content/docs/logstashui/general/updating.md +50 -0
- Documentation/content/docs/logstashui/index.md +90 -0
- Documentation/content/docs/logstashui/kubernetes/cnpg.md +98 -0
- Documentation/content/docs/logstashui/kubernetes/envoy-gateway.md +112 -0
- Documentation/content/docs/logstashui/kubernetes/examples/README.md +46 -0
- Documentation/content/docs/logstashui/kubernetes/examples/embedded-agent.yaml +122 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/configmap.yaml +41 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/secret.yaml +19 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml +25 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml +42 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/secret.yaml +19 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml +35 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/secret.yaml +18 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/index.md +121 -0
- Documentation/content/docs/logstashui/mcp.md +224 -0
- Documentation/content/docs/logstashui/mcp_scenarios.md +234 -0
- Documentation/content/docs/logstashui/rest_api.md +2783 -0
- Documentation/content/docs/logstashui/utilities/dissect_debugger.md +89 -0
- Documentation/content/docs/logstashui/utilities/grok_debugger.md +114 -0
- Documentation/content/docs/logstashui/utilities/index.md +40 -0
- Documentation/content/images/LogstashIcon.png +0 -0
- Documentation/content/images/architecture.png +0 -0
- Documentation/content/images/connection_manager.png +0 -0
- Documentation/content/images/control_plane.png +0 -0
- Documentation/content/images/graph.gif +0 -0
- Documentation/content/images/login.png +0 -0
- Documentation/content/images/monitoring.png +0 -0
- Documentation/content/images/new_connection.gif +0 -0
- Documentation/content/images/simulate.gif +0 -0
- Documentation/content/images/simulate.png +0 -0
- Documentation/content/images/snmp.gif +0 -0
- Documentation/content/images/snmp.png +0 -0
- Documentation/content/images/snmp_architecture.png +0 -0
- Documentation/migrations/__init__.py +0 -0
- Documentation/models.py +9 -0
- Documentation/static/css/markdown.css +250 -0
- Documentation/templates/documentation.html +225 -0
- Documentation/templates/nav_item.html +41 -0
- Documentation/urls.py +11 -0
- Documentation/views.py +442 -0
- LogstashUI/__init__.py +0 -0
- LogstashUI/__main__.py +10 -0
- LogstashUI/asgi.py +16 -0
- LogstashUI/cli.py +626 -0
- LogstashUI/config.py +116 -0
- LogstashUI/database.py +263 -0
- LogstashUI/insecure_http.py +117 -0
- LogstashUI/logging_config.py +99 -0
- LogstashUI/migrate_engine.py +282 -0
- LogstashUI/packaging/__init__.py +3 -0
- LogstashUI/packaging/logstashui.default +68 -0
- LogstashUI/packaging/logstashui.service.in +22 -0
- LogstashUI/paths.py +181 -0
- LogstashUI/settings.py +437 -0
- LogstashUI/telemetry.py +159 -0
- LogstashUI/urls.py +56 -0
- LogstashUI/wsgi.py +77 -0
- Management/__init__.py +0 -0
- Management/apps.py +10 -0
- Management/migrations/0001_initial.py +29 -0
- Management/migrations/0002_settings.py +25 -0
- Management/migrations/0003_settings_agent_ui_url.py +29 -0
- Management/migrations/0004_settings_logstash_artifact_base_url.py +29 -0
- Management/migrations/__init__.py +0 -0
- Management/models.py +92 -0
- Management/templates/api_tokens.html +214 -0
- Management/templates/components/api_token_created.html +38 -0
- Management/templates/components/api_token_row.html +84 -0
- Management/templates/components/logstash_artifact_row.html +100 -0
- Management/templates/components/logstash_artifact_tbody.html +26 -0
- Management/templates/components/user_row.html +67 -0
- Management/templates/logs.html +98 -0
- Management/templates/logstash_artifacts.html +172 -0
- Management/templates/management.html +80 -0
- Management/templates/management_settings.html +320 -0
- Management/templates/registration/login.html +404 -0
- Management/templates/users.html +304 -0
- Management/urls.py +23 -0
- Management/views.py +804 -0
- Monitoring/__init__.py +0 -0
- Monitoring/apps.py +9 -0
- Monitoring/migrations/__init__.py +0 -0
- Monitoring/static/js/monitoring.js +463 -0
- Monitoring/templates/components/node_metrics.html +161 -0
- Monitoring/templates/components/pipeline_metrics.html +189 -0
- Monitoring/templates/monitoring.html +271 -0
- Monitoring/urls.py +16 -0
- Monitoring/views.py +724 -0
- PipelineManager/__init__.py +0 -0
- PipelineManager/agent_api.py +1173 -0
- PipelineManager/agent_client.py +59 -0
- PipelineManager/agent_modes.py +880 -0
- PipelineManager/agent_policies.py +689 -0
- PipelineManager/agent_versions.py +151 -0
- PipelineManager/apps.py +10 -0
- PipelineManager/artifact_metrics.py +171 -0
- PipelineManager/artifacts.py +820 -0
- PipelineManager/connections_crud.py +722 -0
- PipelineManager/data/default_jvm.options +76 -0
- PipelineManager/data/default_log4j2.properties +165 -0
- PipelineManager/data/default_logstash.yml +405 -0
- PipelineManager/data/plugins.json +29109 -0
- PipelineManager/editor_views.py +608 -0
- PipelineManager/forms.py +284 -0
- PipelineManager/manager_views.py +490 -0
- PipelineManager/migrations/0001_initial.py +38 -0
- PipelineManager/migrations/0002_alter_connection_connection_type_and_more.py +38 -0
- PipelineManager/migrations/0003_policy_connection_policy.py +38 -0
- PipelineManager/migrations/0004_policy_current_revision_number_and_more.py +75 -0
- PipelineManager/migrations/0005_apikey_enrollmenttoken.py +38 -0
- PipelineManager/migrations/0006_enrollmenttoken_name.py +18 -0
- PipelineManager/migrations/0007_alter_enrollmenttoken_options_and_more.py +21 -0
- PipelineManager/migrations/0008_connection_agent_id.py +18 -0
- PipelineManager/migrations/0009_connection_last_check_in_policy_jvm_options_hash_and_more.py +33 -0
- PipelineManager/migrations/0010_keystore_revision_number_pipeline_revision_number.py +23 -0
- PipelineManager/migrations/0011_keystore_kv_hash.py +18 -0
- PipelineManager/migrations/0012_policy_binary_path.py +18 -0
- PipelineManager/migrations/0013_connection_status_blob.py +18 -0
- PipelineManager/migrations/0014_pipeline_pipeline_batch_delay_and_more.py +43 -0
- PipelineManager/migrations/0015_add_pipeline_hash.py +18 -0
- PipelineManager/migrations/0016_backfill_pipeline_hash.py +32 -0
- PipelineManager/migrations/0017_policy_keystore_password.py +31 -0
- PipelineManager/migrations/0018_policy_last_deployed_at.py +18 -0
- PipelineManager/migrations/0019_connection_restart_on_next_checkin.py +18 -0
- PipelineManager/migrations/0020_pipeline_no_input_pipeline_non_reloadable.py +23 -0
- PipelineManager/migrations/0021_connection_desired_agent_version.py +18 -0
- PipelineManager/migrations/0022_keystore_managed_by_pipeline_managed_by.py +23 -0
- PipelineManager/migrations/0023_agent_modes_policy_connection.py +89 -0
- PipelineManager/migrations/0024_seed_system_policies.py +173 -0
- PipelineManager/migrations/0025_packaged_managed_policy_types.py +166 -0
- PipelineManager/migrations/0026_normalize_opt_logstash_agent_paths.py +63 -0
- PipelineManager/migrations/0027_packaged_managed_default_ports.py +49 -0
- PipelineManager/migrations/0028_apikey_admin_tokens.py +80 -0
- PipelineManager/migrations/0029_logstash_artifacts.py +45 -0
- PipelineManager/migrations/0030_connection_allow_self_signed_certs.py +33 -0
- PipelineManager/migrations/0031_deploy_system_policies.py +93 -0
- PipelineManager/migrations/0032_connection_agent_inbound_key.py +30 -0
- PipelineManager/migrations/0033_simulation_result.py +26 -0
- PipelineManager/migrations/__init__.py +0 -0
- PipelineManager/models.py +1300 -0
- PipelineManager/pipelines_crud.py +738 -0
- PipelineManager/policies_crud.py +772 -0
- PipelineManager/sim_keystore.py +319 -0
- PipelineManager/simulation.py +1581 -0
- PipelineManager/static/css/codemirror.min.css +1 -0
- PipelineManager/static/css/graph_move.css +79 -0
- PipelineManager/static/css/monokai.min.css +1 -0
- PipelineManager/static/css/move_mode.css +144 -0
- PipelineManager/static/css/show-hint.min.css +1 -0
- PipelineManager/static/images/age.png +0 -0
- PipelineManager/static/images/aggregate.png +0 -0
- PipelineManager/static/images/alter.png +0 -0
- PipelineManager/static/images/azure_event_hubs.png +0 -0
- PipelineManager/static/images/beats.png +0 -0
- PipelineManager/static/images/boundary.png +0 -0
- PipelineManager/static/images/bytes.png +0 -0
- PipelineManager/static/images/cidr.png +0 -0
- PipelineManager/static/images/cipher.png +0 -0
- PipelineManager/static/images/circonus.png +0 -0
- PipelineManager/static/images/clone.png +0 -0
- PipelineManager/static/images/cloudwatch.png +0 -0
- PipelineManager/static/images/comment.png +0 -0
- PipelineManager/static/images/continue.png +0 -0
- PipelineManager/static/images/couchdb_changes.png +0 -0
- PipelineManager/static/images/csv.png +0 -0
- PipelineManager/static/images/datadog.png +0 -0
- PipelineManager/static/images/datadog_metrics.png +0 -0
- PipelineManager/static/images/date.png +0 -0
- PipelineManager/static/images/de_dot.png +0 -0
- PipelineManager/static/images/dead_letter_queue.png +0 -0
- PipelineManager/static/images/dissect.png +0 -0
- PipelineManager/static/images/dns.png +0 -0
- PipelineManager/static/images/drop.png +0 -0
- PipelineManager/static/images/dynatrace.png +0 -0
- PipelineManager/static/images/elapsed.png +0 -0
- PipelineManager/static/images/elastic_agent.png +0 -0
- PipelineManager/static/images/elastic_integration.png +0 -0
- PipelineManager/static/images/elastic_serverless_forwarder.png +0 -0
- PipelineManager/static/images/elastic_workplace_search.png +0 -0
- PipelineManager/static/images/elasticsearch.png +0 -0
- PipelineManager/static/images/else.png +0 -0
- PipelineManager/static/images/else_if.png +0 -0
- PipelineManager/static/images/email.png +0 -0
- PipelineManager/static/images/environment.png +0 -0
- PipelineManager/static/images/exec.png +0 -0
- PipelineManager/static/images/extractnumbers.png +0 -0
- PipelineManager/static/images/file.png +0 -0
- PipelineManager/static/images/fingerprint.png +0 -0
- PipelineManager/static/images/ganglia.png +0 -0
- PipelineManager/static/images/gelf.png +0 -0
- PipelineManager/static/images/generator.png +0 -0
- PipelineManager/static/images/geoip.png +0 -0
- PipelineManager/static/images/github.png +0 -0
- PipelineManager/static/images/google_bigquery.png +0 -0
- PipelineManager/static/images/google_cloud_storage.png +0 -0
- PipelineManager/static/images/google_pubsub.png +0 -0
- PipelineManager/static/images/graphite.png +0 -0
- PipelineManager/static/images/graphtastic.png +0 -0
- PipelineManager/static/images/grok.png +0 -0
- PipelineManager/static/images/heartbeat.png +0 -0
- PipelineManager/static/images/http.png +0 -0
- PipelineManager/static/images/http_poller.png +0 -0
- PipelineManager/static/images/i18n.png +0 -0
- PipelineManager/static/images/if.png +0 -0
- PipelineManager/static/images/imap.png +0 -0
- PipelineManager/static/images/influxdb.png +0 -0
- PipelineManager/static/images/irc.png +0 -0
- PipelineManager/static/images/java_generator.png +0 -0
- PipelineManager/static/images/java_stdin.png +0 -0
- PipelineManager/static/images/java_stdout.png +0 -0
- PipelineManager/static/images/java_uuid.png +0 -0
- PipelineManager/static/images/jdbc.png +0 -0
- PipelineManager/static/images/jdbc_static.png +0 -0
- PipelineManager/static/images/jdbc_streaming.png +0 -0
- PipelineManager/static/images/jms.png +0 -0
- PipelineManager/static/images/jmx.png +0 -0
- PipelineManager/static/images/json.png +0 -0
- PipelineManager/static/images/json_encode.png +0 -0
- PipelineManager/static/images/juggernaut.png +0 -0
- PipelineManager/static/images/kafka.png +0 -0
- PipelineManager/static/images/kinesis.png +0 -0
- PipelineManager/static/images/kv.png +0 -0
- PipelineManager/static/images/librato.png +0 -0
- PipelineManager/static/images/log4j.png +0 -0
- PipelineManager/static/images/loggly.png +0 -0
- PipelineManager/static/images/logstash.png +0 -0
- PipelineManager/static/images/lumberjack.png +0 -0
- PipelineManager/static/images/meetup.png +0 -0
- PipelineManager/static/images/memcached.png +0 -0
- PipelineManager/static/images/metriccatcher.png +0 -0
- PipelineManager/static/images/metricize.png +0 -0
- PipelineManager/static/images/metrics.png +0 -0
- PipelineManager/static/images/mongodb.png +0 -0
- PipelineManager/static/images/mutate.png +0 -0
- PipelineManager/static/images/nagios.png +0 -0
- PipelineManager/static/images/nagios_nsca.png +0 -0
- PipelineManager/static/images/opentsdb.png +0 -0
- PipelineManager/static/images/pagerduty.png +0 -0
- PipelineManager/static/images/pipe.png +0 -0
- PipelineManager/static/images/pipeline.png +0 -0
- PipelineManager/static/images/prune.png +0 -0
- PipelineManager/static/images/puppet_facter.png +0 -0
- PipelineManager/static/images/rabbitmq.png +0 -0
- PipelineManager/static/images/range.png +0 -0
- PipelineManager/static/images/redis.png +0 -0
- PipelineManager/static/images/redmine.png +0 -0
- PipelineManager/static/images/relp.png +0 -0
- PipelineManager/static/images/riak.png +0 -0
- PipelineManager/static/images/riemann.png +0 -0
- PipelineManager/static/images/rss.png +0 -0
- PipelineManager/static/images/ruby.png +0 -0
- PipelineManager/static/images/s3-sns-sqs.png +0 -0
- PipelineManager/static/images/s3.png +0 -0
- PipelineManager/static/images/salesforce.png +0 -0
- PipelineManager/static/images/sink.png +0 -0
- PipelineManager/static/images/sleep.png +0 -0
- PipelineManager/static/images/snmp.png +0 -0
- PipelineManager/static/images/snmptrap.png +0 -0
- PipelineManager/static/images/sns.png +0 -0
- PipelineManager/static/images/solr_http.png +0 -0
- PipelineManager/static/images/split.png +0 -0
- PipelineManager/static/images/sqlite.png +0 -0
- PipelineManager/static/images/sqs.png +0 -0
- PipelineManager/static/images/statsd.png +0 -0
- PipelineManager/static/images/stdin.png +0 -0
- PipelineManager/static/images/stdout.png +0 -0
- PipelineManager/static/images/stomp.png +0 -0
- PipelineManager/static/images/syslog.png +0 -0
- PipelineManager/static/images/syslog_pri.png +0 -0
- PipelineManager/static/images/tcp.png +0 -0
- PipelineManager/static/images/threats_classifier.png +0 -0
- PipelineManager/static/images/throttle.png +0 -0
- PipelineManager/static/images/timber.png +0 -0
- PipelineManager/static/images/tld.png +0 -0
- PipelineManager/static/images/translate.png +0 -0
- PipelineManager/static/images/truncate.png +0 -0
- PipelineManager/static/images/twitter.png +0 -0
- PipelineManager/static/images/udp.png +0 -0
- PipelineManager/static/images/unix.png +0 -0
- PipelineManager/static/images/urldecode.png +0 -0
- PipelineManager/static/images/useragent.png +0 -0
- PipelineManager/static/images/uuid.png +0 -0
- PipelineManager/static/images/varnishlog.png +0 -0
- PipelineManager/static/images/webhdfs.png +0 -0
- PipelineManager/static/images/websocket.png +0 -0
- PipelineManager/static/images/wmi.png +0 -0
- PipelineManager/static/images/wurfl_device_detection.png +0 -0
- PipelineManager/static/images/xml.png +0 -0
- PipelineManager/static/images/xmpp.png +0 -0
- PipelineManager/static/images/zabbix.png +0 -0
- PipelineManager/static/js/agent_inspect_modal.js +141 -0
- PipelineManager/static/js/agent_policies.js +3746 -0
- PipelineManager/static/js/agent_status_sse.js +166 -0
- PipelineManager/static/js/codemirror.min.js +1 -0
- PipelineManager/static/js/connections_table.js +551 -0
- PipelineManager/static/js/d3.v7.js +20625 -0
- PipelineManager/static/js/diff_modal.js +995 -0
- PipelineManager/static/js/expression_editor.js +291 -0
- PipelineManager/static/js/js-yaml.min.js +1 -0
- PipelineManager/static/js/logstashyml_guides.js +1063 -0
- PipelineManager/static/js/move_graph.js +577 -0
- PipelineManager/static/js/move_mode.js +559 -0
- PipelineManager/static/js/pipeline_editor.js +4102 -0
- PipelineManager/static/js/pipeline_graph_editor.js +3542 -0
- PipelineManager/static/js/pipeline_list.js +274 -0
- PipelineManager/static/js/pipeline_settings.js +121 -0
- PipelineManager/static/js/pipeline_text_editor.js +2088 -0
- PipelineManager/static/js/plugin_config_modal.js +2827 -0
- PipelineManager/static/js/policy_deploy_modal.js +1066 -0
- PipelineManager/static/js/show-hint.min.js +1 -0
- PipelineManager/static/js/sim_targets.js +380 -0
- PipelineManager/static/js/simple-comment-mode.js +56 -0
- PipelineManager/static/js/simulation_modal.js +1135 -0
- PipelineManager/static/js/simulation_results.js +2778 -0
- PipelineManager/static/js/stats_strip.js +231 -0
- PipelineManager/static/js/yaml.js +120 -0
- PipelineManager/system_policy_defaults.py +279 -0
- PipelineManager/templates/components/pipeline_editor/diff_modal.html +127 -0
- PipelineManager/templates/components/pipeline_editor/expression_editor.html +160 -0
- PipelineManager/templates/components/pipeline_editor/plugin_config_modal.html +119 -0
- PipelineManager/templates/components/pipeline_editor/plugin_modal.html +1016 -0
- PipelineManager/templates/components/pipeline_editor/simulation_modal.html +394 -0
- PipelineManager/templates/components/pipeline_editor/simulation_results.html +123 -0
- PipelineManager/templates/components/pipeline_editor/stats_strip.html +123 -0
- PipelineManager/templates/components/pipeline_editor/view_code_modal.html +133 -0
- PipelineManager/templates/components/pipeline_manager/agent_inspect_content.html +805 -0
- PipelineManager/templates/components/pipeline_manager/agent_inspect_modal.html +40 -0
- PipelineManager/templates/components/pipeline_manager/agent_policies.html +2421 -0
- PipelineManager/templates/components/pipeline_manager/change_policy_modal.html +210 -0
- PipelineManager/templates/components/pipeline_manager/collapsible_row.html +11 -0
- PipelineManager/templates/components/pipeline_manager/connection_modal.html +1361 -0
- PipelineManager/templates/components/pipeline_manager/keystore_modal.html +269 -0
- PipelineManager/templates/components/pipeline_manager/logstashyml_guides/centralized_pipeline_management.html +291 -0
- PipelineManager/templates/components/pipeline_manager/logstashyml_guides/default.html +166 -0
- PipelineManager/templates/components/pipeline_manager/mcp_modal.html +241 -0
- PipelineManager/templates/components/pipeline_manager/pipeline_list_content.html +586 -0
- PipelineManager/templates/components/pipeline_manager/policy_deploy_modal.html +238 -0
- PipelineManager/templates/pipeline_editor.html +1738 -0
- PipelineManager/templates/pipeline_graph_editor.html +99 -0
- PipelineManager/templates/pipeline_manager.html +584 -0
- PipelineManager/templates/pipeline_text_editor.html +350 -0
- PipelineManager/urls.py +99 -0
- SNMP/__init__.py +0 -0
- SNMP/ai_template_generation.py +232 -0
- SNMP/apps.py +9 -0
- SNMP/assets/device_template_generation/agents/snmp-profile-author.json +15 -0
- SNMP/assets/device_template_generation/skills/snmp-catalog.json +9 -0
- SNMP/data/authoring_instructions.md +65 -0
- SNMP/data/grounding/.gitignore +4 -0
- SNMP/data/grounding/build_grounding.py +35 -0
- SNMP/data/grounding/grounding.json +1 -0
- SNMP/data/grounding/sample_agent_payload.cisco2960x.json +2184 -0
- SNMP/data/mib_reference/std_bgp4_mib.json +43 -0
- SNMP/data/mib_reference/std_entity_sensors.json +28 -0
- SNMP/data/mib_reference/std_host_resources.json +32 -0
- SNMP/data/mib_reference/std_ospf_mib.json +55 -0
- SNMP/data/mib_reference/std_ucd_linux.json +27 -0
- SNMP/data/normalizers.json +103 -0
- SNMP/data/official_device_templates/arista_eos.json +24 -0
- SNMP/data/official_device_templates/aruba_wireless_controller.json +23 -0
- SNMP/data/official_device_templates/brocade_fc_switch.json +20 -0
- SNMP/data/official_device_templates/cisco_ios.json +21 -0
- SNMP/data/official_device_templates/default.json +13 -0
- SNMP/data/official_device_templates/dell_idrac.json +22 -0
- SNMP/data/official_device_templates/dell_x1026.json +16 -0
- SNMP/data/official_device_templates/dlink_dgs1210_switch.json +19 -0
- SNMP/data/official_device_templates/eastpower_ups.json +20 -0
- SNMP/data/official_device_templates/eaton_ups.json +22 -0
- SNMP/data/official_device_templates/epson_printer.json +18 -0
- SNMP/data/official_device_templates/geist_watchdog.json +20 -0
- SNMP/data/official_device_templates/generic_linux.json +18 -0
- SNMP/data/official_device_templates/generic_ont.json +18 -0
- SNMP/data/official_device_templates/generic_ups.json +16 -0
- SNMP/data/official_device_templates/hp_laserjet_mfp_m281cdw.json +18 -0
- SNMP/data/official_device_templates/hpe_nimble.json +17 -0
- SNMP/data/official_device_templates/huawei_ups.json +19 -0
- SNMP/data/official_device_templates/ingrasys_ups.json +19 -0
- SNMP/data/official_device_templates/isilon_onefs.json +22 -0
- SNMP/data/official_device_templates/mellanox_sx6036.json +20 -0
- SNMP/data/official_device_templates/netapp_7mode.json +22 -0
- SNMP/data/official_device_templates/palo_alto_firewall.json +21 -0
- SNMP/data/official_device_templates/phoenixtec_ups.json +18 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_ap.json +19 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_switch.json +18 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_udm.json +19 -0
- SNMP/data/official_device_templates/versa_flexvnf_appliance.json +19 -0
- SNMP/data/official_profiles/arista_eos.json +16 -0
- SNMP/data/official_profiles/aruba_wireless_controller.json +145 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_fibre_channel_ports.json +35 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_name_server.json +23 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_system_metrics.json +36 -0
- SNMP/data/official_profiles/cisco_cdp.json +26 -0
- SNMP/data/official_profiles/cisco_fans.json +18 -0
- SNMP/data/official_profiles/cisco_sensors.json +21 -0
- SNMP/data/official_profiles/cisco_system_metrics.json +40 -0
- SNMP/data/official_profiles/dell_idrac_cpu.json +19 -0
- SNMP/data/official_profiles/dell_idrac_fans.json +20 -0
- SNMP/data/official_profiles/dell_idrac_global_status.json +13 -0
- SNMP/data/official_profiles/dell_idrac_memory.json +20 -0
- SNMP/data/official_profiles/dell_idrac_power_supply.json +19 -0
- SNMP/data/official_profiles/dell_idrac_raid_controller.json +19 -0
- SNMP/data/official_profiles/dlink_dgs1210.json +15 -0
- SNMP/data/official_profiles/dlink_dgs1210_system_metrics.json +38 -0
- SNMP/data/official_profiles/eaton_ups.json +40 -0
- SNMP/data/official_profiles/geist_environment.json +50 -0
- SNMP/data/official_profiles/generic_arp.json +19 -0
- SNMP/data/official_profiles/generic_bgp.json +24 -0
- SNMP/data/official_profiles/generic_entity_psu.json +26 -0
- SNMP/data/official_profiles/generic_entity_sensor.json +22 -0
- SNMP/data/official_profiles/generic_host_system_metrics.json +68 -0
- SNMP/data/official_profiles/generic_interfaces.json +86 -0
- SNMP/data/official_profiles/generic_ip_addr.json +19 -0
- SNMP/data/official_profiles/generic_lldp.json +54 -0
- SNMP/data/official_profiles/generic_lm_sensors.json +37 -0
- SNMP/data/official_profiles/generic_mac_table.json +19 -0
- SNMP/data/official_profiles/generic_ont.json +88 -0
- SNMP/data/official_profiles/generic_ospf.json +21 -0
- SNMP/data/official_profiles/generic_printer_mib.json +48 -0
- SNMP/data/official_profiles/generic_rmon.json +38 -0
- SNMP/data/official_profiles/generic_system.json +17 -0
- SNMP/data/official_profiles/generic_ucd_system_metrics.json +63 -0
- SNMP/data/official_profiles/generic_ups_mib.json +154 -0
- SNMP/data/official_profiles/hpe_nimble_volumes.json +59 -0
- SNMP/data/official_profiles/huawei_ups.json +111 -0
- SNMP/data/official_profiles/isilon_performance.json +92 -0
- SNMP/data/official_profiles/isilon_protocols.json +77 -0
- SNMP/data/official_profiles/isilon_system.json +86 -0
- SNMP/data/official_profiles/mellanox_mlnx_os.json +15 -0
- SNMP/data/official_profiles/netapp_7mode_data_protection.json +106 -0
- SNMP/data/official_profiles/netapp_7mode_disks.json +51 -0
- SNMP/data/official_profiles/netapp_7mode_protocols.json +66 -0
- SNMP/data/official_profiles/netapp_7mode_system.json +92 -0
- SNMP/data/official_profiles/netapp_7mode_volumes.json +166 -0
- SNMP/data/official_profiles/paloalto_components.json +36 -0
- SNMP/data/official_profiles/paloalto_system.json +15 -0
- SNMP/data/official_profiles/traps.json +16 -0
- SNMP/data/official_profiles/ubiquiti_unifi_switch.json +18 -0
- SNMP/data/official_profiles/ubiquiti_unifi_switch_system.json +14 -0
- SNMP/data/official_profiles/ubiquiti_unifi_wireless.json +60 -0
- SNMP/data/official_profiles/versa_flexvnf.json +14 -0
- SNMP/data/schema.md +650 -0
- SNMP/data/schema_reference/snmp_field_schema.md +747 -0
- SNMP/data/snmp_template.json +629 -0
- SNMP/data/template_profile_context.md +3986 -0
- SNMP/inline_grounding.py +77 -0
- SNMP/management/__init__.py +1 -0
- SNMP/management/commands/__init__.py +1 -0
- SNMP/management/commands/generate_template_profile_context.py +272 -0
- SNMP/management/commands/load_test_snmp_data.py +240 -0
- SNMP/management/commands/sync_snmp_official_data.py +263 -0
- SNMP/management/commands/unload_test_snmp_data.py +77 -0
- SNMP/migrations/0001_initial.py +101 -0
- SNMP/migrations/0002_devicetemplate.py +34 -0
- SNMP/migrations/0003_remove_devicetemplate_type_remove_profile_type_and_more.py +31 -0
- SNMP/migrations/0004_device_device_template.py +19 -0
- SNMP/migrations/0005_devicetemplate_product_profile_product.py +23 -0
- SNMP/migrations/0006_alter_devicetemplate_model_and_more.py +28 -0
- SNMP/migrations/0007_remove_device_profiles.py +17 -0
- SNMP/migrations/0008_devicetemplate_type.py +18 -0
- SNMP/migrations/0009_alter_device_device_template.py +19 -0
- SNMP/migrations/0010_alter_device_device_template.py +19 -0
- SNMP/migrations/0011_network_namespace.py +18 -0
- SNMP/migrations/0012_profile_normalizers.py +18 -0
- SNMP/migrations/0013_snmpdeploymentstate.py +26 -0
- SNMP/migrations/0014_alter_snmpdeploymentstate_last_config_change.py +18 -0
- SNMP/migrations/0015_alter_snmpdeploymentstate_last_config_change.py +20 -0
- SNMP/migrations/0016_alter_snmpdeploymentstate_last_config_change.py +18 -0
- SNMP/migrations/0017_remove_network_logstash_name.py +17 -0
- SNMP/migrations/0018_add_official_key.py +39 -0
- SNMP/migrations/0019_network_namespace_from_device_template.py +18 -0
- SNMP/migrations/0020_device_hostname_alter_device_ip_address_and_more.py +27 -0
- SNMP/migrations/0021_device_building_device_latitude_device_longitude_and_more.py +43 -0
- SNMP/migrations/0022_alter_device_latitude_alter_device_longitude.py +23 -0
- SNMP/migrations/0023_network_agent_connection_network_deployment_mode_and_more.py +30 -0
- SNMP/migrations/0024_network_credential_mode.py +18 -0
- SNMP/migrations/0025_network_ssl_certificate_authorities.py +18 -0
- SNMP/migrations/__init__.py +0 -0
- SNMP/models.py +892 -0
- SNMP/network_map.py +660 -0
- SNMP/overview.py +394 -0
- SNMP/snmp_crud.py +6082 -0
- SNMP/snmp_grounding.py +146 -0
- SNMP/snmp_normalizers.py +594 -0
- SNMP/snmp_pipeline_generator.py +1658 -0
- SNMP/snmp_test.py +962 -0
- SNMP/static/css/snmp.css +33 -0
- SNMP/static/images/apc.png +0 -0
- SNMP/static/images/arista.png +0 -0
- SNMP/static/images/aruba.png +0 -0
- SNMP/static/images/brocade.png +0 -0
- SNMP/static/images/cisco.png +0 -0
- SNMP/static/images/dell.png +0 -0
- SNMP/static/images/dlink.png +0 -0
- SNMP/static/images/east.png +0 -0
- SNMP/static/images/eaton.png +0 -0
- SNMP/static/images/epson.png +0 -0
- SNMP/static/images/hauwei.png +0 -0
- SNMP/static/images/hp.png +0 -0
- SNMP/static/images/hpe.png +0 -0
- SNMP/static/images/ingrasys.png +0 -0
- SNMP/static/images/linux.png +0 -0
- SNMP/static/images/mellanox.png +0 -0
- SNMP/static/images/netapp.png +0 -0
- SNMP/static/images/paloalto.png +0 -0
- SNMP/static/images/phoenixtec.png +0 -0
- SNMP/static/images/ubiquiti.png +0 -0
- SNMP/static/images/unknown.png +0 -0
- SNMP/static/images/versa.png +0 -0
- SNMP/static/images/vertiv.png +0 -0
- SNMP/static/js/ai_device_template_modal.js +1116 -0
- SNMP/static/js/credentials_table.js +291 -0
- SNMP/static/js/devices_table.js +588 -0
- SNMP/static/js/discovered_devices.js +291 -0
- SNMP/static/js/network_map.js +1657 -0
- SNMP/static/js/networks_table.js +360 -0
- SNMP/static/js/onboarding.js +866 -0
- SNMP/static/js/overview.js +416 -0
- SNMP/static/js/snmp_changes_indicator.js +76 -0
- SNMP/static/js/snmp_commit_modal.js +39 -0
- SNMP/static/js/snmp_credentials_modal.js +217 -0
- SNMP/static/js/snmp_device_template_modal.js +669 -0
- SNMP/static/js/snmp_device_visual_preview.js +1707 -0
- SNMP/static/js/snmp_devices_modal.js +912 -0
- SNMP/static/js/snmp_diff_modal.js +1559 -0
- SNMP/static/js/snmp_network_modal.js +940 -0
- SNMP/static/js/snmp_profile_modal.js +1212 -0
- SNMP/static/js/snmp_profile_modal_helpers.js +17 -0
- SNMP/static/js/snmp_test.js +538 -0
- SNMP/templates/Credentials.html +325 -0
- SNMP/templates/DeviceTemplates.html +1059 -0
- SNMP/templates/Devices.html +274 -0
- SNMP/templates/Networks.html +469 -0
- SNMP/templates/Onboarding.html +521 -0
- SNMP/templates/Overview.html +227 -0
- SNMP/templates/components/ai_device_template_modal.html +46 -0
- SNMP/templates/components/ai_generate_template_content.html +224 -0
- SNMP/templates/components/device_template_profile_modal.html +60 -0
- SNMP/templates/components/discovered_devices_content.html +86 -0
- SNMP/templates/components/discovered_devices_modal.html +43 -0
- SNMP/templates/components/gmaps_latlon_modal.html +93 -0
- SNMP/templates/components/network_map.html +110 -0
- SNMP/templates/components/snmp_commit_modal.html +53 -0
- SNMP/templates/components/snmp_credentials_modal.html +189 -0
- SNMP/templates/components/snmp_device_modal.html +6 -0
- SNMP/templates/components/snmp_device_template_modal.html +129 -0
- SNMP/templates/components/snmp_device_visual_preview.html +347 -0
- SNMP/templates/components/snmp_devices_modal.html +330 -0
- SNMP/templates/components/snmp_diff_modal.html +148 -0
- SNMP/templates/components/snmp_network_modal.html +380 -0
- SNMP/templates/components/snmp_profile_modal.html +147 -0
- SNMP/templates/components/snmp_test_modal.html +398 -0
- SNMP/templatetags/__init__.py +0 -0
- SNMP/templatetags/snmp_extras.py +17 -0
- SNMP/urls.py +94 -0
- SNMP/views.py +913 -0
- Site/__init__.py +0 -0
- Site/apps.py +9 -0
- Site/migrations/__init__.py +0 -0
- Site/product_ca_views.py +41 -0
- Site/static/images/ElasticIcon.png +0 -0
- Site/static/images/LoggyIcon.png +0 -0
- Site/static/images/LoggyWizardIcon.png +0 -0
- Site/static/images/LogstashAgentIcon.png +0 -0
- Site/static/images/LogstashIcon.png +0 -0
- Site/static/js/base.js +192 -0
- Site/static/js/marked.min.js +69 -0
- Site/templates/base.html +52 -0
- Site/templates/error.html +65 -0
- Site/templates/home.html +148 -0
- Site/templates/navigation.html +530 -0
- Site/templates/popup.html +251 -0
- Site/templatetags/__init__.py +0 -0
- Site/templatetags/custom_filters.py +36 -0
- Site/urls.py +21 -0
- Site/views.py +200 -0
- Utilities/__init__.py +0 -0
- Utilities/apps.py +9 -0
- Utilities/data/grok-patterns/LICENSE +202 -0
- Utilities/data/grok-patterns/ecs-v1/aws +33 -0
- Utilities/data/grok-patterns/ecs-v1/bacula +53 -0
- Utilities/data/grok-patterns/ecs-v1/bind +13 -0
- Utilities/data/grok-patterns/ecs-v1/bro +30 -0
- Utilities/data/grok-patterns/ecs-v1/exim +26 -0
- Utilities/data/grok-patterns/ecs-v1/firewalls +111 -0
- Utilities/data/grok-patterns/ecs-v1/grok-patterns +95 -0
- Utilities/data/grok-patterns/ecs-v1/haproxy +40 -0
- Utilities/data/grok-patterns/ecs-v1/httpd +17 -0
- Utilities/data/grok-patterns/ecs-v1/java +34 -0
- Utilities/data/grok-patterns/ecs-v1/junos +13 -0
- Utilities/data/grok-patterns/ecs-v1/linux-syslog +16 -0
- Utilities/data/grok-patterns/ecs-v1/maven +1 -0
- Utilities/data/grok-patterns/ecs-v1/mcollective +4 -0
- Utilities/data/grok-patterns/ecs-v1/mongodb +7 -0
- Utilities/data/grok-patterns/ecs-v1/nagios +124 -0
- Utilities/data/grok-patterns/ecs-v1/postgresql +2 -0
- Utilities/data/grok-patterns/ecs-v1/rails +13 -0
- Utilities/data/grok-patterns/ecs-v1/redis +3 -0
- Utilities/data/grok-patterns/ecs-v1/ruby +2 -0
- Utilities/data/grok-patterns/ecs-v1/squid +6 -0
- Utilities/data/grok-patterns/ecs-v1/zeek +33 -0
- Utilities/data/grok-patterns/legacy/aws +14 -0
- Utilities/data/grok-patterns/legacy/bacula +50 -0
- Utilities/data/grok-patterns/legacy/bind +3 -0
- Utilities/data/grok-patterns/legacy/bro +13 -0
- Utilities/data/grok-patterns/legacy/exim +19 -0
- Utilities/data/grok-patterns/legacy/firewalls +91 -0
- Utilities/data/grok-patterns/legacy/grok-patterns +95 -0
- Utilities/data/grok-patterns/legacy/haproxy +39 -0
- Utilities/data/grok-patterns/legacy/httpd +15 -0
- Utilities/data/grok-patterns/legacy/java +17 -0
- Utilities/data/grok-patterns/legacy/junos +9 -0
- Utilities/data/grok-patterns/legacy/linux-syslog +16 -0
- Utilities/data/grok-patterns/legacy/maven +1 -0
- Utilities/data/grok-patterns/legacy/mcollective +1 -0
- Utilities/data/grok-patterns/legacy/mcollective-patterns +4 -0
- Utilities/data/grok-patterns/legacy/mongodb +7 -0
- Utilities/data/grok-patterns/legacy/nagios +124 -0
- Utilities/data/grok-patterns/legacy/postgresql +3 -0
- Utilities/data/grok-patterns/legacy/rails +13 -0
- Utilities/data/grok-patterns/legacy/redis +3 -0
- Utilities/data/grok-patterns/legacy/ruby +2 -0
- Utilities/data/grok-patterns/legacy/squid +4 -0
- Utilities/dissect.py +302 -0
- Utilities/grok.py +412 -0
- Utilities/migrations/__init__.py +0 -0
- Utilities/static/css/debugger_editor.css +88 -0
- Utilities/static/js/debugger_editor.js +93 -0
- Utilities/static/js/grok_debugger.js +131 -0
- Utilities/templates/dissect_debugger.html +95 -0
- Utilities/templates/grok_debugger.html +99 -0
- Utilities/urls.py +14 -0
- Utilities/views.py +363 -0
- logstashui-0.5.5.dev0.dist-info/METADATA +333 -0
- logstashui-0.5.5.dev0.dist-info/RECORD +762 -0
- logstashui-0.5.5.dev0.dist-info/WHEEL +4 -0
- logstashui-0.5.5.dev0.dist-info/entry_points.txt +2 -0
- logstashui-0.5.5.dev0.dist-info/licenses/LICENSE.txt +93 -0
- logstashui-0.5.5.dev0.dist-info/licenses/NOTICE.txt +2772 -0
- theme/__init__.py +0 -0
- theme/apps.py +9 -0
- theme/package-lock.json +6 -0
- theme/static/css/dist/styles.css +2 -0
- theme/static/images/favicon.ico +0 -0
- theme/static_src/.gitignore +1 -0
- theme/static_src/package-lock.json +1930 -0
- theme/static_src/package.json +26 -0
- theme/static_src/postcss.config.js +7 -0
- theme/static_src/src/styles.css +38 -0
- theme/static_src/tailwind.config.js +43 -0
- theme/templates/base.html +32 -0
API/mcp/tools.py
ADDED
|
@@ -0,0 +1,890 @@
|
|
|
1
|
+
"""Declarative MCP tool registry mapped onto REST API routes.
|
|
2
|
+
|
|
3
|
+
Each :class:`Tool` names the URL pattern and HTTP method it dispatches to;
|
|
4
|
+
:mod:`API.mcp.dispatch` builds the request. Arguments are flat: path
|
|
5
|
+
parameters, query parameters, and body fields share one ``inputSchema``.
|
|
6
|
+
A tool with ``variants`` covers several routes and picks one from the
|
|
7
|
+
arguments it gets, so agent and CPM pipelines share one set of tools.
|
|
8
|
+
|
|
9
|
+
Examples:
|
|
10
|
+
>>> from API.mcp.tools import select_tools
|
|
11
|
+
>>> tools = select_tools(['policies'])
|
|
12
|
+
>>> tools['policies_get'].url_name
|
|
13
|
+
'api-policies-detail'
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from dataclasses import dataclass, field
|
|
17
|
+
|
|
18
|
+
from API.guides import GUIDES
|
|
19
|
+
|
|
20
|
+
TOOLSETS = ('guides', 'connections', 'pipelines', 'policies', 'snmp')
|
|
21
|
+
|
|
22
|
+
#: Toolsets that no longer exist. Old client URLs may still name them, so
|
|
23
|
+
#: they are ignored instead of rejected.
|
|
24
|
+
RETIRED_TOOLSETS = ('security',)
|
|
25
|
+
|
|
26
|
+
#: Routes deliberately not exposed over MCP, as ``(url_name, method)``.
|
|
27
|
+
#: Bootstrap is an unauthenticated setup flow; user and API key management
|
|
28
|
+
#: stays out of model reach; enrollment-token creation returns a raw secret
|
|
29
|
+
#: that would land in the model's transcript. The pipelines deploy route does
|
|
30
|
+
#: the same as ``policies_deploy``, and one tool per destructive action is
|
|
31
|
+
#: less for a model to confuse. ``security/me`` only reports the key's role,
|
|
32
|
+
#: and tools/list already hides what that role can't call.
|
|
33
|
+
EXCLUDED_ROUTES = frozenset({
|
|
34
|
+
('api-pipeline-deploy', 'POST'),
|
|
35
|
+
('api-security-me', 'GET'),
|
|
36
|
+
('api-security-bootstrap', 'GET'),
|
|
37
|
+
('api-security-bootstrap', 'POST'),
|
|
38
|
+
('api-security-user-list', 'GET'),
|
|
39
|
+
('api-security-user-list', 'POST'),
|
|
40
|
+
('api-security-user-detail', 'GET'),
|
|
41
|
+
('api-security-user-detail', 'PUT'),
|
|
42
|
+
('api-security-user-detail', 'DELETE'),
|
|
43
|
+
('api-security-key-list', 'GET'),
|
|
44
|
+
('api-security-key-list', 'POST'),
|
|
45
|
+
('api-security-key-revoke', 'POST'),
|
|
46
|
+
('api-security-key-detail', 'DELETE'),
|
|
47
|
+
('api-policies-tokens', 'POST'),
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
REDACTED = '[redacted]'
|
|
51
|
+
|
|
52
|
+
#: 422 hints for connection writes: Elasticsearch rejected the connectivity test.
|
|
53
|
+
_CONNECTION_TEST_FAILED = ('The Elasticsearch connectivity test failed (error has the reason). '
|
|
54
|
+
'Check the host, credentials, and certificate settings with the user; '
|
|
55
|
+
'do not retry with guessed values.')
|
|
56
|
+
|
|
57
|
+
#: Default ``hint`` added to error responses, by HTTP status.
|
|
58
|
+
STATUS_HINTS = {
|
|
59
|
+
400: 'Fix the arguments named in the error and retry. If a value is unclear, ask the user '
|
|
60
|
+
'instead of guessing.',
|
|
61
|
+
401: 'The MCP API key is missing or invalid. Tell the user; do not look for another key.',
|
|
62
|
+
403: "This API key's role cannot do this. Tell the user; do not try another route.",
|
|
63
|
+
404: 'Not found. List the resource to get the exact ID or name, and confirm with the user '
|
|
64
|
+
'if more than one could match.',
|
|
65
|
+
408: 'Timed out. Retry once; if it times out again, report it to the user and stop.',
|
|
66
|
+
409: 'Conflicts with an existing object, usually one with the same name. Ask the user for '
|
|
67
|
+
'another name or which object to change.',
|
|
68
|
+
502: 'An upstream system (Elasticsearch or a LogstashAgent) failed. Report the error to '
|
|
69
|
+
'the user; connections_test can check a connection.',
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#: Hint for errors with ``code: protected``: official and system objects no role can change.
|
|
73
|
+
PROTECTED_HINT = ('This object ships with LogstashUI and is read-only for every role. Do not '
|
|
74
|
+
'retry or try another route; offer to create a custom copy under a new name.')
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class ToolArgumentError(ValueError):
|
|
78
|
+
"""Raised when tool arguments cannot be mapped onto the REST route."""
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@dataclass(frozen=True)
|
|
82
|
+
class Variant:
|
|
83
|
+
"""One concrete tool behind a tool with ``variants``.
|
|
84
|
+
|
|
85
|
+
Attributes:
|
|
86
|
+
keys: Arguments that select this variant; any one of them present picks it.
|
|
87
|
+
usage: How errors tell the caller to pick it, e.g. ``'pipeline_id (agent pipeline)'``.
|
|
88
|
+
label: Plural name for errors about arguments it doesn't take.
|
|
89
|
+
tool: The :class:`Tool` that runs.
|
|
90
|
+
drop: Arguments removed before dispatch because this variant doesn't use them.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
keys: tuple
|
|
94
|
+
usage: str
|
|
95
|
+
label: str
|
|
96
|
+
tool: 'Tool'
|
|
97
|
+
drop: tuple = ()
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@dataclass(frozen=True)
|
|
101
|
+
class Tool:
|
|
102
|
+
"""One MCP tool backed by one REST route + method.
|
|
103
|
+
|
|
104
|
+
Attributes:
|
|
105
|
+
name: MCP tool name, ``<toolset>_<action>``.
|
|
106
|
+
toolset: Group used by the ``?toolsets=`` filter.
|
|
107
|
+
url_name: Django URL name in ``API/urls.py``.
|
|
108
|
+
method: HTTP method to dispatch with.
|
|
109
|
+
description: Text shown to the model.
|
|
110
|
+
path_params: Schemas for URL kwargs, keyed by kwarg name.
|
|
111
|
+
query_params: Schemas for query-string parameters.
|
|
112
|
+
body: Schemas for JSON body fields (POST/PUT only).
|
|
113
|
+
required: Argument names that must be present.
|
|
114
|
+
destructive: Mark a non-DELETE write as destructive (deploys, revokes).
|
|
115
|
+
read_only: Mark a non-GET call that changes nothing (tests, previews,
|
|
116
|
+
simulations) as read-only.
|
|
117
|
+
redact: Response keys replaced with ``[redacted]`` at any depth.
|
|
118
|
+
next_steps: Added to successful object responses as ``next_steps``.
|
|
119
|
+
guidance: ``callable(payload) -> str`` that writes ``next_steps``
|
|
120
|
+
from a successful response, for tools whose right next step
|
|
121
|
+
depends on what they returned. Takes precedence over
|
|
122
|
+
``next_steps``.
|
|
123
|
+
hints: ``{status_code: text}`` added to error responses as ``hint``;
|
|
124
|
+
overrides :data:`STATUS_HINTS` for this tool.
|
|
125
|
+
defaults: Argument values used when the caller omits them. Lets MCP
|
|
126
|
+
ask for compact responses while REST keeps its full default.
|
|
127
|
+
aliases: ``{alias: argument}`` names accepted in place of an argument
|
|
128
|
+
and renamed before dispatch. Not advertised in ``inputSchema``.
|
|
129
|
+
A tool with exactly one path parameter also accepts ``id``.
|
|
130
|
+
variants: :class:`Variant` tools this one dispatches to. Its own
|
|
131
|
+
schema is what clients see; :meth:`resolve` picks the variant.
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
name: str
|
|
135
|
+
toolset: str
|
|
136
|
+
url_name: str
|
|
137
|
+
method: str
|
|
138
|
+
description: str
|
|
139
|
+
path_params: dict = field(default_factory=dict)
|
|
140
|
+
query_params: dict = field(default_factory=dict)
|
|
141
|
+
body: dict = field(default_factory=dict)
|
|
142
|
+
required: tuple = ()
|
|
143
|
+
destructive: bool = False
|
|
144
|
+
read_only: bool = False
|
|
145
|
+
redact: frozenset = frozenset()
|
|
146
|
+
next_steps: str = ''
|
|
147
|
+
guidance: object = None
|
|
148
|
+
hints: dict = field(default_factory=dict)
|
|
149
|
+
defaults: dict = field(default_factory=dict)
|
|
150
|
+
aliases: dict = field(default_factory=dict)
|
|
151
|
+
variants: tuple = ()
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def admin_only(self):
|
|
155
|
+
"""Whether only admin-role keys can call it; tests keep this in step with the views."""
|
|
156
|
+
return 'Admin only.' in self.description
|
|
157
|
+
|
|
158
|
+
def resolve(self, arguments):
|
|
159
|
+
"""Pick the tool that runs for these arguments.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
arguments: Raw ``arguments`` object from ``tools/call``.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
tuple: ``(tool, arguments)``. A tool without variants returns
|
|
166
|
+
itself and the arguments unchanged.
|
|
167
|
+
|
|
168
|
+
Raises:
|
|
169
|
+
ToolArgumentError: If no variant's keys are present, several are,
|
|
170
|
+
or the chosen variant doesn't take an argument that was sent.
|
|
171
|
+
|
|
172
|
+
Examples:
|
|
173
|
+
>>> tool, args = TOOLS_BY_NAME['pipelines_get'].resolve({'pipeline_id': 4})
|
|
174
|
+
>>> tool.url_name, args
|
|
175
|
+
('api-pipeline-detail', {'pipeline_id': 4})
|
|
176
|
+
"""
|
|
177
|
+
if not self.variants or not isinstance(arguments, dict):
|
|
178
|
+
return self, arguments
|
|
179
|
+
chosen = [v for v in self.variants
|
|
180
|
+
if any(arguments.get(key) not in (None, '') for key in v.keys)]
|
|
181
|
+
options = ' or '.join(v.usage for v in self.variants)
|
|
182
|
+
if len(chosen) != 1:
|
|
183
|
+
raise ToolArgumentError(f'Pass {options}' + (', not both.' if chosen else '.'))
|
|
184
|
+
variant = chosen[0]
|
|
185
|
+
own = set(variant.tool.input_schema()['properties'])
|
|
186
|
+
# Clients may echo schema defaults or send nulls for arguments the variant doesn't take.
|
|
187
|
+
arguments = {k: v for k, v in arguments.items() if k not in variant.drop
|
|
188
|
+
and (k in own or (v is not None and v != self.defaults.get(k)))}
|
|
189
|
+
if not variant.tool.body:
|
|
190
|
+
extra = sorted(set(arguments) - own - set(variant.tool.argument_aliases()))
|
|
191
|
+
if extra:
|
|
192
|
+
raise ToolArgumentError(f"{', '.join(extra)}: not used for {variant.label}.")
|
|
193
|
+
return variant.tool, arguments
|
|
194
|
+
|
|
195
|
+
def argument_aliases(self):
|
|
196
|
+
"""Return every accepted alias, including the implicit ``id``.
|
|
197
|
+
|
|
198
|
+
Examples:
|
|
199
|
+
>>> TOOLS_BY_NAME['snmp_networks_get'].argument_aliases()
|
|
200
|
+
{'id': 'network_id'}
|
|
201
|
+
"""
|
|
202
|
+
aliases = dict(self.aliases)
|
|
203
|
+
if len(self.path_params) == 1:
|
|
204
|
+
aliases.setdefault('id', next(iter(self.path_params)))
|
|
205
|
+
return aliases
|
|
206
|
+
|
|
207
|
+
def input_schema(self):
|
|
208
|
+
"""Return the JSON Schema for this tool's flat argument object."""
|
|
209
|
+
properties = {**self.path_params, **self.query_params, **self.body}
|
|
210
|
+
for name, value in self.defaults.items():
|
|
211
|
+
properties[name] = {**properties[name], 'default': value}
|
|
212
|
+
return {
|
|
213
|
+
'type': 'object',
|
|
214
|
+
'properties': properties,
|
|
215
|
+
'required': list(dict.fromkeys((*self.path_params, *self.required))),
|
|
216
|
+
# Views own field validation; unknown body keys pass through to them.
|
|
217
|
+
'additionalProperties': bool(self.body),
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
def annotations(self):
|
|
221
|
+
"""Return MCP tool annotations so clients can auto-approve reads."""
|
|
222
|
+
if self.method == 'GET' or self.read_only:
|
|
223
|
+
return {'readOnlyHint': True}
|
|
224
|
+
return {
|
|
225
|
+
'readOnlyHint': False,
|
|
226
|
+
'destructiveHint': self.method == 'DELETE' or self.destructive,
|
|
227
|
+
'idempotentHint': self.method in ('PUT', 'DELETE'),
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
def to_mcp(self):
|
|
231
|
+
"""Return the ``tools/list`` entry for this tool."""
|
|
232
|
+
return {
|
|
233
|
+
'name': self.name,
|
|
234
|
+
'description': self.description,
|
|
235
|
+
'inputSchema': self.input_schema(),
|
|
236
|
+
'annotations': self.annotations(),
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def _str(description='', enum=None):
|
|
241
|
+
schema = {'type': 'string', 'description': description}
|
|
242
|
+
if enum:
|
|
243
|
+
schema['enum'] = list(enum)
|
|
244
|
+
return schema
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def _int(description=''):
|
|
248
|
+
return {'type': 'integer', 'description': description}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def _bool(description=''):
|
|
252
|
+
return {'type': 'boolean', 'description': description}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def _obj(description=''):
|
|
256
|
+
return {'type': 'object', 'description': description}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _arr(description='', items=None):
|
|
260
|
+
return {'type': 'array', 'description': description, 'items': items or {}}
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def _nullable_int(description=''):
|
|
264
|
+
return {'type': ['integer', 'null'], 'description': description}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
# ---------------------------------------------------------------------------
|
|
268
|
+
# Shared field sets
|
|
269
|
+
# ---------------------------------------------------------------------------
|
|
270
|
+
|
|
271
|
+
_CONNECTION_FIELDS = {
|
|
272
|
+
'name': _str('Unique connection name.'),
|
|
273
|
+
'connection_type': _str('Connection type.', ['CENTRALIZED', 'AGENT']),
|
|
274
|
+
'connection_mode': _str('How to reach Elasticsearch.', ['url', 'cloud']),
|
|
275
|
+
'auth_type': _str('Elasticsearch auth method: basic or api_key.'),
|
|
276
|
+
'host': _str('Elasticsearch URL without the port, e.g. https://es.example.com; put the '
|
|
277
|
+
'port in port.'),
|
|
278
|
+
'cloud_id': _str('Elastic Cloud ID.'),
|
|
279
|
+
'cloud_url': _str('Full cluster URL for Cloud deployments.'),
|
|
280
|
+
'port': _int('9200 for URL mode, 443 for Cloud.'),
|
|
281
|
+
'username': _str('Basic-auth username.'),
|
|
282
|
+
'password': _str('Basic-auth password. Omit on update to keep the stored value.'),
|
|
283
|
+
'api_key': _str('Elasticsearch API key. Omit on update to keep the stored value.'),
|
|
284
|
+
'allow_self_signed_certs': _bool('Skip TLS verification for Elasticsearch/Kibana calls.'),
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
_PIPELINE_SETTINGS = {
|
|
288
|
+
'description': _str('Pipeline description.'),
|
|
289
|
+
'pipeline_workers': _int('pipeline.workers (default 1).'),
|
|
290
|
+
'pipeline_batch_size': _int('pipeline.batch.size (default 128).'),
|
|
291
|
+
'pipeline_batch_delay': _int('pipeline.batch.delay in ms (default 50).'),
|
|
292
|
+
'queue_type': _str('queue.type.', ['memory', 'persisted']),
|
|
293
|
+
'queue_max_bytes': _str('queue.max_bytes, e.g. "1gb".'),
|
|
294
|
+
'queue_checkpoint_writes': _int('queue.checkpoint.writes (default 1024).'),
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
_POLICY_FIELDS = {
|
|
298
|
+
'name': _str('Unique policy name.'),
|
|
299
|
+
'policy_type': _str('Policy type; immutable after creation.', ['PACKAGED', 'MANAGED', 'SIMULATE']),
|
|
300
|
+
'settings_path': _str('Logstash settings dir (default /etc/logstash/).'),
|
|
301
|
+
'logs_path': _str('Logstash logs dir (default /var/log/logstash).'),
|
|
302
|
+
'binary_path': _str('Logstash bin dir (default /usr/share/logstash/bin).'),
|
|
303
|
+
'data_path': _str('Logstash data dir.'),
|
|
304
|
+
'keystore_env_file': _str('Keystore env file (default /etc/default/logstash).'),
|
|
305
|
+
'agent_api_port': _int('LogstashAgent API port.'),
|
|
306
|
+
'logstash_api_port': _int('Logstash API port.'),
|
|
307
|
+
'logstash_source': _str('Where the Logstash binary comes from.', ['SYSTEM', 'VERSION']),
|
|
308
|
+
'logstash_version': _str('Logstash version; required when logstash_source is VERSION.'),
|
|
309
|
+
'logstash_download_dir': _str('Directory for downloaded Logstash versions.'),
|
|
310
|
+
'logstash_via_ui': _bool('Download Logstash through LogstashUI.'),
|
|
311
|
+
'logstash_yml': _str('Full logstash.yml contents.'),
|
|
312
|
+
'jvm_options': _str('Full jvm.options contents.'),
|
|
313
|
+
'log4j2_properties': _str('Full log4j2.properties contents.'),
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
_DEVICE_FIELDS = {
|
|
317
|
+
'name': _str('Unique device name.'),
|
|
318
|
+
'ip_address': _str('Device IP. One of ip_address or hostname is required on create.'),
|
|
319
|
+
'hostname': _str('Device hostname.'),
|
|
320
|
+
'port': _int('SNMP port (default 161).'),
|
|
321
|
+
'retries': _int('Retries (default 2).'),
|
|
322
|
+
'timeout': _int('Timeout in ms (default 1000).'),
|
|
323
|
+
'credential': _nullable_int('SNMP credential ID; null clears it.'),
|
|
324
|
+
'network': _nullable_int('SNMP network ID; null clears it.'),
|
|
325
|
+
'device_template': _nullable_int('Device template ID; null clears it.'),
|
|
326
|
+
'site': _str('Site label.'),
|
|
327
|
+
'building': _str('Building label.'),
|
|
328
|
+
'room': _str('Room label.'),
|
|
329
|
+
'latitude': {'type': ['number', 'null'], 'description': 'Decimal degrees.'},
|
|
330
|
+
'longitude': {'type': ['number', 'null'], 'description': 'Decimal degrees.'},
|
|
331
|
+
'metadata': _obj('Arbitrary JSON metadata.'),
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
_CREDENTIAL_FIELDS = {
|
|
335
|
+
'name': _str('Unique credential name.'),
|
|
336
|
+
'description': _str('Description.'),
|
|
337
|
+
'version': _str('SNMP version.', ['1', '2c', '3']),
|
|
338
|
+
'community': _str('v1/v2c community string. Empty or omitted on update keeps it.'),
|
|
339
|
+
'security_name': _str('SNMPv3 username.'),
|
|
340
|
+
'security_level': _str('SNMPv3 security level.', ['noAuthNoPriv', 'authNoPriv', 'authPriv']),
|
|
341
|
+
'auth_protocol': _str('SNMPv3 auth protocol, e.g. sha, md5, hmac192sha256.'),
|
|
342
|
+
'auth_pass': _str('SNMPv3 auth password. Empty or omitted on update keeps it.'),
|
|
343
|
+
'priv_protocol': _str('SNMPv3 privacy protocol, e.g. aes, des, aes256.'),
|
|
344
|
+
'priv_pass': _str('SNMPv3 privacy password. Empty or omitted on update keeps it.'),
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
_NETWORK_FIELDS = {
|
|
348
|
+
'name': _str('Unique network name.'),
|
|
349
|
+
'network_range': _str('CIDR range; prefix must be /20 or longer.'),
|
|
350
|
+
'deployment_mode': _str('Where polling runs.', ['CENTRALIZED', 'AGENT']),
|
|
351
|
+
'credential_mode': _str('How credentials reach Logstash.', ['KEYSTORE', 'PLAINTEXT']),
|
|
352
|
+
'connection': _nullable_int('Elasticsearch connection ID (centralized polling).'),
|
|
353
|
+
'agent_connection': _nullable_int('Agent connection ID (agent-mode polling).'),
|
|
354
|
+
'discovery_credential': _nullable_int('Credential ID used for discovery.'),
|
|
355
|
+
'credential': _nullable_int('Credential ID used for trap ingestion.'),
|
|
356
|
+
'discovery_enabled': _bool('Run discovery (default true).'),
|
|
357
|
+
'traps_enabled': _bool('Ingest traps (default false).'),
|
|
358
|
+
'interval': _int('Poll interval in seconds (default 30).'),
|
|
359
|
+
'namespace': _str('Data-stream namespace (default "default").'),
|
|
360
|
+
'namespace_from_device_template': _bool('Derive namespace from device template name.'),
|
|
361
|
+
'ssl_certificate_authorities': _str('Comma-separated CA paths on the Logstash host.'),
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
_PROFILE_FIELDS = {
|
|
365
|
+
'name': _str('Unique profile name. Names ending in .json are reserved for official profiles.'),
|
|
366
|
+
'vendor': _str('Vendor.'),
|
|
367
|
+
'product': _str('Product.'),
|
|
368
|
+
'description': _str('Description.'),
|
|
369
|
+
'profile_data': _obj('OIDs to poll, keyed by ECS-style field name: {"get": {"field": "oid"}, '
|
|
370
|
+
'"walk": {"field": "oid"}, "table": {"table.name": {"columns": '
|
|
371
|
+
'{"column": "oid"}}}}. get for scalar OIDs ending in .0, walk for a flat '
|
|
372
|
+
'subtree, table for per-row data. See guides_get("snmp").'),
|
|
373
|
+
'normalizers': _arr('Unit conversions and derived fields: {"operation": "multiply", '
|
|
374
|
+
'"translate", "average", "sum", or "ratio", "target": {"scope": "get" or '
|
|
375
|
+
'"table", ...}, "params": {...}}. Unknown operations or params are '
|
|
376
|
+
'rejected with 400. See guides_get("snmp") for the params of each.'),
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
_TEMPLATE_FIELDS = {
|
|
380
|
+
'name': _str('Unique template name.'),
|
|
381
|
+
'vendor': _str('Vendor.'),
|
|
382
|
+
'model': _str('Model label.'),
|
|
383
|
+
'product': _str('Product label.'),
|
|
384
|
+
'type': _str('Device type label, e.g. switch.'),
|
|
385
|
+
'description': _str('Description.'),
|
|
386
|
+
'matching_rules': _arr('sysDescr substrings used for auto-classification.', {'type': 'string'}),
|
|
387
|
+
'profiles': _arr('Profile IDs to attach; replaces the existing list on update.', {'type': 'integer'}),
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
_SEARCH = {'search': _str('Case-insensitive search.')}
|
|
391
|
+
_OFFICIAL = {'official': _str('Filter by official status.', ['true', 'false'])}
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def _crud(toolset, resource, list_url, detail_url, id_param, fields, *,
|
|
395
|
+
label, list_query=None, create_required=(), read_note='', write_note='',
|
|
396
|
+
write_next_steps=''):
|
|
397
|
+
"""Build list/create/get/update/delete tools for a standard REST resource."""
|
|
398
|
+
path = {id_param: _int(f'{label} ID.')}
|
|
399
|
+
not_found = {404: f'{label} not found. Use {toolset}_{resource}_list to find the ID.'}
|
|
400
|
+
return [
|
|
401
|
+
Tool(f'{toolset}_{resource}_list', toolset, list_url, 'GET',
|
|
402
|
+
f'List {label}s.{read_note}', query_params=list_query or {}),
|
|
403
|
+
Tool(f'{toolset}_{resource}_create', toolset, list_url, 'POST',
|
|
404
|
+
f'Create a {label}. Admin only.{write_note}', body=fields, required=create_required,
|
|
405
|
+
next_steps=write_next_steps),
|
|
406
|
+
Tool(f'{toolset}_{resource}_get', toolset, detail_url, 'GET',
|
|
407
|
+
f'Get one {label} by ID.{read_note}', path_params=path, hints=not_found),
|
|
408
|
+
Tool(f'{toolset}_{resource}_update', toolset, detail_url, 'PUT',
|
|
409
|
+
f'Update a {label}; send only fields to change. Admin only.{write_note}',
|
|
410
|
+
path_params=path, body=fields, next_steps=write_next_steps, hints=not_found),
|
|
411
|
+
Tool(f'{toolset}_{resource}_delete', toolset, detail_url, 'DELETE',
|
|
412
|
+
f'Delete a {label}. Admin only.{write_note}', path_params=path,
|
|
413
|
+
next_steps=write_next_steps, hints=not_found),
|
|
414
|
+
]
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
_SNMP_DEPLOY_NOTE = (
|
|
418
|
+
' Flags SNMP config as changed; nothing is pushed until snmp_deploy_diff and '
|
|
419
|
+
'snmp_deploy_apply.'
|
|
420
|
+
)
|
|
421
|
+
_SNMP_NEXT_STEPS = (
|
|
422
|
+
'Not pushed yet. When the user is done editing, run snmp_deploy_diff, show them the plan, '
|
|
423
|
+
'and run snmp_deploy_apply only after they confirm.'
|
|
424
|
+
)
|
|
425
|
+
_AGENT_PIPELINE_NEXT_STEPS = (
|
|
426
|
+
'Not live yet: agents run the last deployed revision. To go live, show the user '
|
|
427
|
+
'policies_diff(policy_id) and run policies_deploy only after they confirm.'
|
|
428
|
+
)
|
|
429
|
+
_CPM_NEXT_STEPS = (
|
|
430
|
+
'Live now: Logstash nodes using CPM on this connection pick up the change without a '
|
|
431
|
+
'deploy step.'
|
|
432
|
+
)
|
|
433
|
+
_CPM_NOT_FOUND = {
|
|
434
|
+
404: 'CPM pipeline not found. Use pipelines_find(name) to locate it on any connection.',
|
|
435
|
+
}
|
|
436
|
+
_AGENT_PIPELINE_NOT_FOUND = {
|
|
437
|
+
404: 'Pipeline not found. Use pipelines_find(name) to get the ID.',
|
|
438
|
+
}
|
|
439
|
+
_PIPELINE_REF = {
|
|
440
|
+
'pipeline_id': _int('Agent pipeline ID, from pipelines_find.'),
|
|
441
|
+
'connection_id': _int('CENTRALIZED connection ID holding the CPM pipeline, from '
|
|
442
|
+
'pipelines_find; use with name.'),
|
|
443
|
+
'name': _str('CPM pipeline name; use with connection_id.'),
|
|
444
|
+
}
|
|
445
|
+
_CPM_PATH = {'connection_id': _int(), 'name': _str()}
|
|
446
|
+
|
|
447
|
+
#: Asked when a pipeline the user wants simulated exists nowhere. The
|
|
448
|
+
#: ``simulation`` guide quotes it; a test keeps the two identical.
|
|
449
|
+
ASK_TO_BUILD_PIPELINE = (
|
|
450
|
+
"This pipeline doesn't exist on any of your connections. Would you like for me to build "
|
|
451
|
+
"one to simulate with? I won't save it until you tell me to, though."
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
def _find_next_steps(result):
|
|
456
|
+
"""Turn a ``pipelines_find`` result into the agent's next step.
|
|
457
|
+
|
|
458
|
+
Args:
|
|
459
|
+
result: The find response: ``matches``, ``similar``, ``unreachable``.
|
|
460
|
+
|
|
461
|
+
Returns:
|
|
462
|
+
str: What to do with this result.
|
|
463
|
+
|
|
464
|
+
Examples:
|
|
465
|
+
>>> _find_next_steps({'matches': [{'type': 'agent', 'pipeline_id': 4}]})
|
|
466
|
+
'Found one match. Pass pipeline_id=4 to pipelines_simulate or pipelines_get.'
|
|
467
|
+
"""
|
|
468
|
+
matches = result.get('matches') or []
|
|
469
|
+
unreachable = result.get('unreachable') or []
|
|
470
|
+
if len(matches) == 1:
|
|
471
|
+
match = matches[0]
|
|
472
|
+
if match['type'] == 'cpm':
|
|
473
|
+
steps = (f"Found one match. Pass connection_id={match['connection_id']} and "
|
|
474
|
+
f"name={match['name']!r} to pipelines_simulate or pipelines_get.")
|
|
475
|
+
else:
|
|
476
|
+
steps = (f"Found one match. Pass pipeline_id={match['pipeline_id']} to "
|
|
477
|
+
'pipelines_simulate or pipelines_get.')
|
|
478
|
+
if result.get('similar'):
|
|
479
|
+
steps += (' If the user described the pipeline instead of naming it, this name only '
|
|
480
|
+
'matched your keyword: show them it and the similar pipelines (name, where '
|
|
481
|
+
'it is, last_modified) and ask which to use.')
|
|
482
|
+
return steps
|
|
483
|
+
if matches:
|
|
484
|
+
return 'Several pipelines have this name. Show the user where each one is and ask which.'
|
|
485
|
+
if unreachable:
|
|
486
|
+
names = ', '.join(c['connection_name'] for c in unreachable)
|
|
487
|
+
return (f'No match on the connections that answered, but {names} could not be searched. '
|
|
488
|
+
'Tell the user it may be there and ask how to proceed. Do not build a '
|
|
489
|
+
'replacement yet.')
|
|
490
|
+
if result.get('similar'):
|
|
491
|
+
return ('No exact match. Show the user the similar pipelines (name, where it is, '
|
|
492
|
+
'last_modified) and ask which they meant; do not pick one yourself. If none and '
|
|
493
|
+
f'they asked to simulate, ask exactly: "{ASK_TO_BUILD_PIPELINE}"')
|
|
494
|
+
return (f'No pipeline has this name anywhere. If the user asked to simulate, ask exactly: '
|
|
495
|
+
f'"{ASK_TO_BUILD_PIPELINE}" Write and simulate your own config (lscl) only after '
|
|
496
|
+
'they say yes, and save it only if they ask.')
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
def _snmp_plan_next_steps(plan):
|
|
500
|
+
"""Turn an ``snmp_deploy_diff`` plan into the agent's next step.
|
|
501
|
+
|
|
502
|
+
Args:
|
|
503
|
+
plan: The deploy plan response; ``has_changes`` says whether anything would change.
|
|
504
|
+
|
|
505
|
+
Returns:
|
|
506
|
+
str: What to do with this plan.
|
|
507
|
+
|
|
508
|
+
Examples:
|
|
509
|
+
>>> _snmp_plan_next_steps({'has_changes': False})
|
|
510
|
+
'Nothing to deploy: the SNMP pipelines already match the configuration. Do not run snmp_deploy_apply.'
|
|
511
|
+
"""
|
|
512
|
+
if not plan.get('has_changes'):
|
|
513
|
+
return ('Nothing to deploy: the SNMP pipelines already match the configuration. '
|
|
514
|
+
'Do not run snmp_deploy_apply.')
|
|
515
|
+
return ('Show this plan to the user. Run snmp_deploy_apply only after they confirm; '
|
|
516
|
+
'if more than 60 seconds pass, run snmp_deploy_diff again first.')
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
TOOLS = [
|
|
520
|
+
# --- Guides -----------------------------------------------------------
|
|
521
|
+
Tool('guides_list', 'guides', 'api-guides-list', 'GET',
|
|
522
|
+
'List how-to guides for working with LogstashUI (concepts, pipeline review, '
|
|
523
|
+
'simulation, deploy, SNMP, troubleshooting).'),
|
|
524
|
+
Tool('guides_get', 'guides', 'api-guides-detail', 'GET',
|
|
525
|
+
'Read one how-to guide as Markdown. Read concepts before your first change, and the '
|
|
526
|
+
'guide for a task before starting it, such as pipeline-review before reviewing a '
|
|
527
|
+
'pipeline.',
|
|
528
|
+
path_params={'topic': _str('Guide topic.', GUIDES)}),
|
|
529
|
+
|
|
530
|
+
# --- Connections ------------------------------------------------------
|
|
531
|
+
Tool('connections_list', 'connections', 'api-connections-list', 'GET',
|
|
532
|
+
'List connections. CENTRALIZED connections are Elasticsearch clusters holding CPM '
|
|
533
|
+
'pipelines (pipelines_list with connection_id). AGENT connections are enrolled LogstashAgent '
|
|
534
|
+
'nodes; policy_id is the policy they run, and SIMULATE-policy agents run simulations. '
|
|
535
|
+
'Credentials are never returned.'),
|
|
536
|
+
Tool('connections_create', 'connections', 'api-connections-list', 'POST',
|
|
537
|
+
'Create a connection. It is connectivity-tested first and rolled back on failure. Admin only.',
|
|
538
|
+
body=_CONNECTION_FIELDS, required=('name', 'connection_type'),
|
|
539
|
+
hints={422: _CONNECTION_TEST_FAILED + ' Nothing was saved.'}),
|
|
540
|
+
Tool('connections_get', 'connections', 'api-connections-detail', 'GET',
|
|
541
|
+
'Get one connection by ID.', path_params={'connection_id': _int('Connection ID.')}),
|
|
542
|
+
Tool('connections_update', 'connections', 'api-connections-detail', 'PUT',
|
|
543
|
+
'Update a connection; send only fields to change. Re-tested and rolled back on failure. Admin only.',
|
|
544
|
+
path_params={'connection_id': _int('Connection ID.')}, body=_CONNECTION_FIELDS,
|
|
545
|
+
hints={422: _CONNECTION_TEST_FAILED + ' The update was rolled back.'}),
|
|
546
|
+
Tool('connections_delete', 'connections', 'api-connections-detail', 'DELETE',
|
|
547
|
+
'Delete a connection. Admin only.', path_params={'connection_id': _int('Connection ID.')}),
|
|
548
|
+
Tool('connections_test', 'connections', 'api-connections-test', 'POST',
|
|
549
|
+
'Run a live connectivity check against a saved connection without changing it.',
|
|
550
|
+
path_params={'connection_id': _int('Connection ID.')}, read_only=True,
|
|
551
|
+
hints={404: 'Connection not found. Use connections_list to find the ID.',
|
|
552
|
+
422: _CONNECTION_TEST_FAILED + ' Fix it with connections_update.'}),
|
|
553
|
+
|
|
554
|
+
# --- Finding pipelines --------------------------------------------------
|
|
555
|
+
Tool('pipelines_find', 'pipelines', 'api-pipeline-find', 'GET',
|
|
556
|
+
'Find Logstash pipelines in every policy and on every CENTRALIZED connection in one '
|
|
557
|
+
'call. Use this whenever the user names or describes a pipeline ("asa-new", "the ASA '
|
|
558
|
+
'pipeline"), before any other pipeline tool and instead of listing policies or '
|
|
559
|
+
'connections. Returns exact matches, similar names, and connections that could not be '
|
|
560
|
+
'searched; next_steps says what to do with the result.',
|
|
561
|
+
query_params={'name': _str('A pipeline name, part of one, or a topic keyword such as '
|
|
562
|
+
'"asa".')},
|
|
563
|
+
required=('name',),
|
|
564
|
+
aliases={'query': 'name'},
|
|
565
|
+
guidance=_find_next_steps),
|
|
566
|
+
Tool('pipelines_recent', 'pipelines', 'api-pipeline-recent', 'GET',
|
|
567
|
+
'List Logstash pipelines in every policy and on every CENTRALIZED connection, most '
|
|
568
|
+
'recently modified first, in one call. Use it for "what changed lately" questions '
|
|
569
|
+
'instead of listing each policy and connection. Shows when a pipeline last changed, '
|
|
570
|
+
'not who changed it or what changed.',
|
|
571
|
+
query_params={
|
|
572
|
+
'since': _str('ISO 8601 timestamp, e.g. 2026-11-01 or 2026-11-01T09:00:00Z; only '
|
|
573
|
+
'pipelines modified at or after it.'),
|
|
574
|
+
'limit': _int('Maximum pipelines to return (default 20, max 200).'),
|
|
575
|
+
}),
|
|
576
|
+
|
|
577
|
+
# --- Agent and CPM pipelines ----------------------------------------------
|
|
578
|
+
# One tool per operation; the arguments pick the agent or CPM route.
|
|
579
|
+
Tool('pipelines_list', 'pipelines', '', 'GET',
|
|
580
|
+
'List the Logstash pipelines in one place, without their config: policy_id for a '
|
|
581
|
+
"policy's agent pipelines, or connection_id for the CPM pipelines on a CENTRALIZED "
|
|
582
|
+
'connection. To search every place at once, use pipelines_find or pipelines_recent.',
|
|
583
|
+
query_params={
|
|
584
|
+
'policy_id': _int('Policy ID (agent pipelines).'),
|
|
585
|
+
'connection_id': _int('CENTRALIZED connection ID (CPM pipelines).'),
|
|
586
|
+
'managed_by': _str('Agent pipelines only. Ownership filter (default user): snmp for '
|
|
587
|
+
'SNMP-generated pipelines, library for library pipelines.',
|
|
588
|
+
['user', 'snmp', 'library']),
|
|
589
|
+
'include_lscl': _bool("CPM pipelines only. Include each pipeline's full config, "
|
|
590
|
+
'which is large; use pipelines_get for one pipeline.'),
|
|
591
|
+
},
|
|
592
|
+
defaults={'include_lscl': False},
|
|
593
|
+
variants=(
|
|
594
|
+
Variant(('policy_id',), 'policy_id (agent pipelines)', 'agent pipelines',
|
|
595
|
+
Tool('pipelines_list', 'pipelines', 'api-pipeline-list', 'GET', '',
|
|
596
|
+
query_params={'policy_id': _int(), 'managed_by': _str()},
|
|
597
|
+
required=('policy_id',),
|
|
598
|
+
hints={404: 'Policy not found. Use policies_list to find the ID.'})),
|
|
599
|
+
Variant(('connection_id',), 'connection_id (CPM pipelines)', 'CPM pipelines',
|
|
600
|
+
Tool('pipelines_list', 'pipelines', 'api-centralized-pipeline-list', 'GET', '',
|
|
601
|
+
path_params={'connection_id': _int()},
|
|
602
|
+
query_params={'include_lscl': _bool()},
|
|
603
|
+
defaults={'include_lscl': False},
|
|
604
|
+
hints={404: 'Connection not found. Use connections_list and pick a '
|
|
605
|
+
'CENTRALIZED connection.'})),
|
|
606
|
+
)),
|
|
607
|
+
Tool('pipelines_get', 'pipelines', '', 'GET',
|
|
608
|
+
'Get one Logstash pipeline with its config (lscl) and settings. Pass pipeline_id for an '
|
|
609
|
+
'agent pipeline or connection_id + name for a CPM pipeline, as pipelines_find returns '
|
|
610
|
+
'them. pipelines_simulate takes the same arguments.',
|
|
611
|
+
query_params=_PIPELINE_REF,
|
|
612
|
+
variants=(
|
|
613
|
+
Variant(('pipeline_id', 'id'), 'pipeline_id (agent pipeline)', 'agent pipelines',
|
|
614
|
+
Tool('pipelines_get', 'pipelines', 'api-pipeline-detail', 'GET', '',
|
|
615
|
+
path_params={'pipeline_id': _int()},
|
|
616
|
+
hints=_AGENT_PIPELINE_NOT_FOUND),
|
|
617
|
+
drop=('name',)),
|
|
618
|
+
Variant(('connection_id',), 'connection_id + name (CPM pipeline)', 'CPM pipelines',
|
|
619
|
+
Tool('pipelines_get', 'pipelines', 'api-centralized-pipeline-detail', 'GET', '',
|
|
620
|
+
path_params=_CPM_PATH, hints=_CPM_NOT_FOUND)),
|
|
621
|
+
)),
|
|
622
|
+
Tool('pipelines_create', 'pipelines', '', 'POST',
|
|
623
|
+
'Create a Logstash pipeline. policy_id adds an agent pipeline to a policy; it is not '
|
|
624
|
+
'live until the policy is deployed. connection_id writes a CPM pipeline, which is live '
|
|
625
|
+
'immediately and overwrites a CPM pipeline with the same name. Admin only.',
|
|
626
|
+
body={
|
|
627
|
+
'policy_id': _int('Policy ID (agent pipeline).'),
|
|
628
|
+
'connection_id': _int('CENTRALIZED connection ID (CPM pipeline).'),
|
|
629
|
+
'name': _str('Pipeline name, unique within the policy or connection.'),
|
|
630
|
+
'lscl': _str('Full Logstash config text.'),
|
|
631
|
+
**_PIPELINE_SETTINGS,
|
|
632
|
+
},
|
|
633
|
+
required=('name', 'lscl'),
|
|
634
|
+
variants=(
|
|
635
|
+
Variant(('policy_id',), 'policy_id (agent pipeline)', 'agent pipelines',
|
|
636
|
+
Tool('pipelines_create', 'pipelines', 'api-pipeline-list', 'POST', '',
|
|
637
|
+
body={'policy_id': _int(), 'name': _str(), 'lscl': _str()},
|
|
638
|
+
required=('policy_id', 'name', 'lscl'),
|
|
639
|
+
next_steps=_AGENT_PIPELINE_NEXT_STEPS)),
|
|
640
|
+
Variant(('connection_id',), 'connection_id (CPM pipeline)', 'CPM pipelines',
|
|
641
|
+
Tool('pipelines_create', 'pipelines', 'api-centralized-pipeline-list', 'POST',
|
|
642
|
+
'', path_params={'connection_id': _int()},
|
|
643
|
+
body={'name': _str(), 'lscl': _str()}, required=('name', 'lscl'),
|
|
644
|
+
next_steps=_CPM_NEXT_STEPS)),
|
|
645
|
+
)),
|
|
646
|
+
Tool('pipelines_update', 'pipelines', '', 'PUT',
|
|
647
|
+
'Update a Logstash pipeline; send only fields to change. Pass pipeline_id for an agent '
|
|
648
|
+
'pipeline (not live until the policy is deployed) or connection_id + name for a CPM '
|
|
649
|
+
'pipeline (live immediately; unspecified settings keep their values). Pipelines cannot '
|
|
650
|
+
'be renamed here. Admin only.',
|
|
651
|
+
body={**_PIPELINE_REF, 'lscl': _str('Full Logstash config text.'), **_PIPELINE_SETTINGS},
|
|
652
|
+
variants=(
|
|
653
|
+
Variant(('pipeline_id', 'id'), 'pipeline_id (agent pipeline)', 'agent pipelines',
|
|
654
|
+
Tool('pipelines_update', 'pipelines', 'api-pipeline-detail', 'PUT', '',
|
|
655
|
+
path_params={'pipeline_id': _int()}, body={'lscl': _str()},
|
|
656
|
+
next_steps=_AGENT_PIPELINE_NEXT_STEPS, hints=_AGENT_PIPELINE_NOT_FOUND),
|
|
657
|
+
drop=('name',)),
|
|
658
|
+
Variant(('connection_id',), 'connection_id + name (CPM pipeline)', 'CPM pipelines',
|
|
659
|
+
Tool('pipelines_update', 'pipelines', 'api-centralized-pipeline-detail', 'PUT',
|
|
660
|
+
'', path_params=_CPM_PATH, body={'lscl': _str()},
|
|
661
|
+
next_steps=_CPM_NEXT_STEPS, hints=_CPM_NOT_FOUND)),
|
|
662
|
+
)),
|
|
663
|
+
Tool('pipelines_delete', 'pipelines', '', 'DELETE',
|
|
664
|
+
'Delete a Logstash pipeline. Pass pipeline_id for an agent pipeline (agents keep '
|
|
665
|
+
'running it until the policy is deployed) or connection_id + name for a CPM pipeline '
|
|
666
|
+
'(Logstash nodes using CPM stop running it immediately). Admin only.',
|
|
667
|
+
query_params=_PIPELINE_REF,
|
|
668
|
+
variants=(
|
|
669
|
+
Variant(('pipeline_id', 'id'), 'pipeline_id (agent pipeline)', 'agent pipelines',
|
|
670
|
+
Tool('pipelines_delete', 'pipelines', 'api-pipeline-detail', 'DELETE', '',
|
|
671
|
+
path_params={'pipeline_id': _int()},
|
|
672
|
+
next_steps=_AGENT_PIPELINE_NEXT_STEPS, hints=_AGENT_PIPELINE_NOT_FOUND),
|
|
673
|
+
drop=('name',)),
|
|
674
|
+
Variant(('connection_id',), 'connection_id + name (CPM pipeline)', 'CPM pipelines',
|
|
675
|
+
Tool('pipelines_delete', 'pipelines', 'api-centralized-pipeline-detail',
|
|
676
|
+
'DELETE', '', path_params=_CPM_PATH,
|
|
677
|
+
next_steps=_CPM_NEXT_STEPS, hints=_CPM_NOT_FOUND)),
|
|
678
|
+
)),
|
|
679
|
+
Tool('pipelines_simulate', 'pipelines', 'api-pipeline-simulate', 'POST',
|
|
680
|
+
"Run sample events through a pipeline's filters on a simulate agent and return what "
|
|
681
|
+
'each filter did. Pass exactly one config source: connection_id + name (CPM pipeline) '
|
|
682
|
+
'or pipeline_id (agent pipeline), both from pipelines_find, or lscl for config that '
|
|
683
|
+
"isn't saved. Never use lscl in place of a pipeline the user named. Pass event or "
|
|
684
|
+
'events. Read-only: nothing is saved or deployed. Admin only.',
|
|
685
|
+
body={
|
|
686
|
+
'connection_id': _int('CENTRALIZED connection ID holding the CPM pipeline; '
|
|
687
|
+
'use with name.'),
|
|
688
|
+
'name': _str('CPM pipeline name; use with connection_id.'),
|
|
689
|
+
'pipeline_id': _int('Agent pipeline ID.'),
|
|
690
|
+
'lscl': _str("Logstash config that isn't saved, such as a proposed fix. Input and "
|
|
691
|
+
'output blocks are ignored.'),
|
|
692
|
+
'event': _str('One sample log line or JSON string.'),
|
|
693
|
+
'events': _arr('Up to 100 log lines or JSON events, run on one slot in a single '
|
|
694
|
+
'call. Events run about 1.5s apart; keep a batch under about 30 to '
|
|
695
|
+
'stay within a 60s client tool timeout.',
|
|
696
|
+
{'type': ['string', 'object']}),
|
|
697
|
+
'sim_connection_id': _int('Specific simulate-agent connection ID.'),
|
|
698
|
+
'policy_id': _int('Policy whose keystore backs ${var} references.'),
|
|
699
|
+
'timeout': _int('Seconds to wait for all events (default 30, max 180).'),
|
|
700
|
+
'detail': _str('Per-event output. steps: final event plus what each filter added, '
|
|
701
|
+
'changed, or removed. final: final event only, for large batches. '
|
|
702
|
+
'full: raw snapshots, large; only when steps is not enough.',
|
|
703
|
+
('final', 'steps', 'full')),
|
|
704
|
+
},
|
|
705
|
+
read_only=True,
|
|
706
|
+
defaults={'detail': 'steps'},
|
|
707
|
+
hints={
|
|
708
|
+
404: 'Config source not found. Use pipelines_find(name) to get the exact source.',
|
|
709
|
+
408: 'No results in time. Retry once with the same arguments; if it times out '
|
|
710
|
+
'again, report that the simulate agent is not returning results and stop.',
|
|
711
|
+
}),
|
|
712
|
+
|
|
713
|
+
# --- Policies -----------------------------------------------------------
|
|
714
|
+
Tool('policies_list', 'policies', 'api-policies-list', 'GET',
|
|
715
|
+
'List agent policies with active agent counts and deploy state. Config files '
|
|
716
|
+
'(logstash.yml, jvm.options, log4j2.properties) are left out unless include_config is '
|
|
717
|
+
'set. Admin only.',
|
|
718
|
+
query_params={'include_config': _bool('Include config file contents.')},
|
|
719
|
+
defaults={'include_config': False}),
|
|
720
|
+
Tool('policies_create', 'policies', 'api-policies-list', 'POST',
|
|
721
|
+
'Create an agent policy. Config files default to system defaults when omitted. Admin only.',
|
|
722
|
+
body=_POLICY_FIELDS, required=('name', 'policy_type')),
|
|
723
|
+
Tool('policies_get', 'policies', 'api-policies-detail', 'GET',
|
|
724
|
+
'Get one agent policy by ID. Config files (logstash.yml, jvm.options, '
|
|
725
|
+
'log4j2.properties) are left out unless include_config is set; set it before editing '
|
|
726
|
+
'them. Admin only.',
|
|
727
|
+
path_params={'policy_id': _int('Policy ID.')},
|
|
728
|
+
query_params={'include_config': _bool('Include config file contents.')},
|
|
729
|
+
defaults={'include_config': False}),
|
|
730
|
+
Tool('policies_update', 'policies', 'api-policies-detail', 'PUT',
|
|
731
|
+
'Update an agent policy; send only fields to change. Name and policy_type cannot change. '
|
|
732
|
+
'Not live until the policy is deployed. Admin only.',
|
|
733
|
+
path_params={'policy_id': _int('Policy ID.')},
|
|
734
|
+
body={k: v for k, v in _POLICY_FIELDS.items() if k not in ('name', 'policy_type')},
|
|
735
|
+
next_steps=_AGENT_PIPELINE_NEXT_STEPS),
|
|
736
|
+
Tool('policies_delete', 'policies', 'api-policies-detail', 'DELETE',
|
|
737
|
+
'Delete an agent policy. System policies and policies with agents cannot be deleted. Admin only.',
|
|
738
|
+
path_params={'policy_id': _int('Policy ID.')}),
|
|
739
|
+
Tool('policies_deploy', 'policies', 'api-policies-deploy', 'POST',
|
|
740
|
+
'Deploy a policy: snapshot its pipelines, keystore, and config as a new revision that '
|
|
741
|
+
'agents pick up on next check-in. Show the user policies_diff first and deploy only '
|
|
742
|
+
'after they confirm. Admin only.',
|
|
743
|
+
path_params={'policy_id': _int('Policy ID.')}, destructive=True),
|
|
744
|
+
Tool('policies_clone', 'policies', 'api-policies-clone', 'POST',
|
|
745
|
+
'Clone a policy with all its user pipelines and keystore entries. Admin only.',
|
|
746
|
+
path_params={'policy_id': _int('Source policy ID.')},
|
|
747
|
+
body={'new_name': _str('Unique name for the clone.')}, required=('new_name',)),
|
|
748
|
+
Tool('policies_diff', 'policies', 'api-policies-diff', 'GET',
|
|
749
|
+
'Compare a policy\'s live state against its last deployed revision. Returns the '
|
|
750
|
+
'pending change count and the names of changed config files, paths, pipelines, and '
|
|
751
|
+
'keystore keys by default; call again with detail=changes to read the diffs. '
|
|
752
|
+
'Keystore values are never shown. Admin only.',
|
|
753
|
+
path_params={'policy_id': _int('Policy ID.')},
|
|
754
|
+
query_params={
|
|
755
|
+
'detail': _str('summary: what changed, by name. changes: plus unified diffs of '
|
|
756
|
+
'changed config files and pipeline LSCL. full: both complete '
|
|
757
|
+
'snapshots, very large.', ('summary', 'changes', 'full')),
|
|
758
|
+
},
|
|
759
|
+
defaults={'detail': 'summary'},
|
|
760
|
+
redact=frozenset({'key_value', 'keystore_password_hash'})),
|
|
761
|
+
Tool('policies_tokens_list', 'policies', 'api-policies-tokens', 'GET',
|
|
762
|
+
'List enrollment tokens for a policy (IDs and names; token values are redacted). Admin only.',
|
|
763
|
+
path_params={'policy_id': _int('Policy ID.')},
|
|
764
|
+
redact=frozenset({'raw_token', 'encoded_token', 'enroll_command'})),
|
|
765
|
+
Tool('policies_tokens_get', 'policies', 'api-policies-token-detail', 'GET',
|
|
766
|
+
'Get one enrollment token\'s metadata (token value is redacted). Admin only.',
|
|
767
|
+
path_params={'policy_id': _int('Policy ID.'), 'token_id': _int('Token ID.')},
|
|
768
|
+
redact=frozenset({'raw_token', 'encoded_token', 'enroll_command'})),
|
|
769
|
+
Tool('policies_tokens_delete', 'policies', 'api-policies-token-detail', 'DELETE',
|
|
770
|
+
'Delete an enrollment token. Admin only.',
|
|
771
|
+
path_params={'policy_id': _int('Policy ID.'), 'token_id': _int('Token ID.')}),
|
|
772
|
+
|
|
773
|
+
# --- SNMP -----------------------------------------------------------------
|
|
774
|
+
*_crud('snmp', 'devices', 'api-snmp-device-list', 'api-snmp-device-detail', 'device_id',
|
|
775
|
+
_DEVICE_FIELDS, label='SNMP device', create_required=('name',),
|
|
776
|
+
write_note=_SNMP_DEPLOY_NOTE, write_next_steps=_SNMP_NEXT_STEPS,
|
|
777
|
+
list_query={
|
|
778
|
+
'page': _int('Page number (default 1).'),
|
|
779
|
+
'page_size': _int('Page size (default 25, max 200).'),
|
|
780
|
+
**_SEARCH,
|
|
781
|
+
'network': _int('Filter by network ID.'),
|
|
782
|
+
'sort_by': _str('Sort order.', ['name', '-name', 'ip_address', '-ip_address',
|
|
783
|
+
'hostname', '-hostname', 'created_at', '-created_at']),
|
|
784
|
+
}),
|
|
785
|
+
*_crud('snmp', 'credentials', 'api-snmp-credential-list', 'api-snmp-credential-detail',
|
|
786
|
+
'credential_id', _CREDENTIAL_FIELDS, label='SNMP credential',
|
|
787
|
+
create_required=('name', 'version'), write_note=_SNMP_DEPLOY_NOTE,
|
|
788
|
+
write_next_steps=_SNMP_NEXT_STEPS,
|
|
789
|
+
read_note=' Secret values are never returned.',
|
|
790
|
+
list_query={**_SEARCH, 'version': _str('SNMP version filter.', ['1', '2c', '3'])}),
|
|
791
|
+
*_crud('snmp', 'networks', 'api-snmp-network-list', 'api-snmp-network-detail', 'network_id',
|
|
792
|
+
_NETWORK_FIELDS, label='SNMP network', create_required=('name', 'network_range'),
|
|
793
|
+
write_note=_SNMP_DEPLOY_NOTE, write_next_steps=_SNMP_NEXT_STEPS, list_query=_SEARCH),
|
|
794
|
+
*_crud('snmp', 'profiles', 'api-snmp-profile-list', 'api-snmp-profile-detail', 'profile_id',
|
|
795
|
+
_PROFILE_FIELDS, label='SNMP OID profile',
|
|
796
|
+
create_required=('name', 'vendor', 'profile_data'), list_query={**_SEARCH, **_OFFICIAL}),
|
|
797
|
+
*_crud('snmp', 'templates', 'api-snmp-template-list', 'api-snmp-template-detail', 'template_id',
|
|
798
|
+
_TEMPLATE_FIELDS, label='SNMP device template', create_required=('name', 'vendor'),
|
|
799
|
+
read_note=' Official templates are read-only.', list_query={**_SEARCH, **_OFFICIAL}),
|
|
800
|
+
Tool('snmp_deploy_status', 'snmp', 'api-snmp-deploy-status', 'GET',
|
|
801
|
+
'Check whether SNMP configuration has undeployed changes.'),
|
|
802
|
+
Tool('snmp_deploy_diff', 'snmp', 'api-snmp-deploy-diff', 'POST',
|
|
803
|
+
'Preview the SNMP deployment plan (pipelines to create/update/delete) and cache it for '
|
|
804
|
+
'60 seconds. Changes nothing. Returns counts and one row per pipeline by default; to '
|
|
805
|
+
'see what changes inside specific pipelines, call again with detail=changes and '
|
|
806
|
+
'pipelines=[names]. Admin only.',
|
|
807
|
+
body={
|
|
808
|
+
'detail': _str('summary: counts and pipeline names. changes: plus a unified diff '
|
|
809
|
+
'per pipeline. full: raw current and new config, very large.',
|
|
810
|
+
('summary', 'changes', 'full')),
|
|
811
|
+
'pipelines': _arr('Only include these pipeline names in the rows (counts still '
|
|
812
|
+
'cover the whole plan).', {'type': 'string'}),
|
|
813
|
+
},
|
|
814
|
+
defaults={'detail': 'summary'},
|
|
815
|
+
redact=frozenset({'manual_keystore_values'}),
|
|
816
|
+
read_only=True,
|
|
817
|
+
guidance=_snmp_plan_next_steps),
|
|
818
|
+
Tool('snmp_deploy_apply', 'snmp', 'api-snmp-deploy-apply', 'POST',
|
|
819
|
+
'Apply the SNMP deployment plan: push pipelines and keystore values. Run snmp_deploy_diff '
|
|
820
|
+
'first, show the user the plan, and apply only after they confirm. Admin only.',
|
|
821
|
+
destructive=True),
|
|
822
|
+
]
|
|
823
|
+
|
|
824
|
+
TOOLS_BY_NAME = {tool.name: tool for tool in TOOLS}
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
def concrete_tools():
|
|
828
|
+
"""Return every tool that maps to a route: plain tools plus each tool's variants.
|
|
829
|
+
|
|
830
|
+
Examples:
|
|
831
|
+
>>> 'api-centralized-pipeline-detail' in {t.url_name for t in concrete_tools()}
|
|
832
|
+
True
|
|
833
|
+
"""
|
|
834
|
+
return [v.tool for t in TOOLS for v in t.variants] + [t for t in TOOLS if not t.variants]
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
def parse_toolsets(raw):
|
|
838
|
+
"""Parse the ``?toolsets=`` query value.
|
|
839
|
+
|
|
840
|
+
Args:
|
|
841
|
+
raw: Comma-separated toolset names, or ``None``/empty for all.
|
|
842
|
+
|
|
843
|
+
Returns:
|
|
844
|
+
Tuple of ``(toolsets, unknown)``: the selected names (all when
|
|
845
|
+
``raw`` names none) and any names that are not in :data:`TOOLSETS`.
|
|
846
|
+
:data:`RETIRED_TOOLSETS` are dropped without counting as unknown.
|
|
847
|
+
|
|
848
|
+
Examples:
|
|
849
|
+
>>> parse_toolsets('pipelines, snmp')
|
|
850
|
+
(['pipelines', 'snmp'], [])
|
|
851
|
+
>>> parse_toolsets('nope')
|
|
852
|
+
([], ['nope'])
|
|
853
|
+
>>> parse_toolsets('snmp,security')
|
|
854
|
+
(['snmp'], [])
|
|
855
|
+
"""
|
|
856
|
+
names = [n.strip() for n in (raw or '').split(',')
|
|
857
|
+
if n.strip() and n.strip() not in RETIRED_TOOLSETS]
|
|
858
|
+
if not names:
|
|
859
|
+
return list(TOOLSETS), []
|
|
860
|
+
return [n for n in names if n in TOOLSETS], [n for n in names if n not in TOOLSETS]
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
def select_tools(toolsets):
|
|
864
|
+
"""Return ``{name: Tool}`` for tools in the given toolsets, in registry order."""
|
|
865
|
+
wanted = set(toolsets)
|
|
866
|
+
return {t.name: t for t in TOOLS if t.toolset in wanted}
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
def toolset_catalog():
|
|
870
|
+
"""List each toolset's tools for display in the UI.
|
|
871
|
+
|
|
872
|
+
Returns:
|
|
873
|
+
list[dict]: One ``{'name', 'tools'}`` entry per toolset, in
|
|
874
|
+
:data:`TOOLSETS` order. Each tool is ``{'name', 'summary', 'writes'}``,
|
|
875
|
+
where ``summary`` is the first sentence of its description.
|
|
876
|
+
|
|
877
|
+
Examples:
|
|
878
|
+
>>> catalog = toolset_catalog()
|
|
879
|
+
>>> catalog[0]['name'], catalog[0]['tools'][0]['name'], catalog[0]['tools'][0]['writes']
|
|
880
|
+
('guides', 'guides_list', False)
|
|
881
|
+
"""
|
|
882
|
+
return [
|
|
883
|
+
{'name': toolset, 'tools': [
|
|
884
|
+
{'name': t.name,
|
|
885
|
+
'summary': t.description.split('. ')[0].rstrip('.') + '.',
|
|
886
|
+
'writes': not t.annotations()['readOnlyHint']}
|
|
887
|
+
for t in TOOLS if t.toolset == toolset
|
|
888
|
+
]}
|
|
889
|
+
for toolset in TOOLSETS
|
|
890
|
+
]
|