4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
119 lines
3.6 KiB
Python
119 lines
3.6 KiB
Python
"""Integration management CLI commands."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import click
|
|
|
|
from platform.analytics.cli import (
|
|
capture_integration_removed,
|
|
capture_integration_setup_completed,
|
|
capture_integration_setup_started,
|
|
capture_integration_verified,
|
|
capture_integrations_listed,
|
|
)
|
|
from surfaces.cli.constants import (
|
|
MANAGED_INTEGRATION_SERVICES,
|
|
SETUP_SERVICES,
|
|
VERIFY_SERVICES,
|
|
)
|
|
|
|
|
|
class IntegrationServiceChoice(click.Choice):
|
|
"""``click.Choice`` that resolves integration-management service aliases.
|
|
|
|
Without this, passing an intuitive alias such as ``posthog`` (whose only
|
|
management flow is ``posthog_mcp``) fails the enum check with exit code 2
|
|
before ``cmd_setup``/``cmd_verify`` ever run. Resolving the alias here keeps
|
|
Click's friendly ``[[a|b|c]]`` usage/error display and shell completion while
|
|
accepting the canonical service name the handlers expect.
|
|
"""
|
|
|
|
def convert(
|
|
self,
|
|
value: object,
|
|
param: click.Parameter | None,
|
|
ctx: click.Context | None,
|
|
) -> object:
|
|
if isinstance(value, str):
|
|
from integrations.registry import resolve_management_service
|
|
|
|
value = resolve_management_service(value)
|
|
return super().convert(value, param, ctx)
|
|
|
|
|
|
@click.group(name="integrations")
|
|
def integrations() -> None:
|
|
"""Manage local integration credentials."""
|
|
|
|
|
|
@integrations.command(name="setup")
|
|
@click.argument(
|
|
"service", required=False, default=None, type=IntegrationServiceChoice(SETUP_SERVICES)
|
|
)
|
|
def setup_integration(service: str | None) -> None:
|
|
"""Set up credentials for a service."""
|
|
from integrations.cli import cmd_setup, cmd_verify
|
|
|
|
normalized_service = service or "prompt"
|
|
capture_integration_setup_started(normalized_service)
|
|
resolved_service = cmd_setup(service)
|
|
capture_integration_setup_completed(resolved_service)
|
|
|
|
if resolved_service in VERIFY_SERVICES:
|
|
click.echo(f" Verifying {resolved_service}...\n")
|
|
exit_code = cmd_verify(resolved_service)
|
|
if exit_code == 0:
|
|
capture_integration_verified(resolved_service)
|
|
raise SystemExit(exit_code)
|
|
|
|
|
|
@integrations.command(name="list")
|
|
def list_integrations() -> None:
|
|
"""List all configured integrations."""
|
|
from integrations.cli import cmd_list
|
|
|
|
capture_integrations_listed()
|
|
cmd_list()
|
|
|
|
|
|
@integrations.command(name="show")
|
|
@click.argument("service", type=IntegrationServiceChoice(MANAGED_INTEGRATION_SERVICES))
|
|
def show_integration(service: str) -> None:
|
|
"""Show details for a configured integration."""
|
|
from integrations.cli import cmd_show
|
|
|
|
cmd_show(service)
|
|
|
|
|
|
@integrations.command(name="remove")
|
|
@click.argument("service", type=IntegrationServiceChoice(MANAGED_INTEGRATION_SERVICES))
|
|
def remove_integration(service: str) -> None:
|
|
"""Remove a configured integration."""
|
|
from integrations.cli import cmd_remove
|
|
|
|
cmd_remove(service)
|
|
capture_integration_removed(service)
|
|
|
|
|
|
@integrations.command(name="verify")
|
|
@click.argument(
|
|
"service", required=False, default=None, type=IntegrationServiceChoice(VERIFY_SERVICES)
|
|
)
|
|
@click.option(
|
|
"--send-slack-test", is_flag=True, help="Send a test message to the configured Slack webhook."
|
|
)
|
|
def verify_integration(
|
|
service: str | None,
|
|
send_slack_test: bool,
|
|
) -> None:
|
|
"""Verify integration connectivity (all services, or a specific one)."""
|
|
from integrations.cli import cmd_verify
|
|
|
|
exit_code = cmd_verify(
|
|
service,
|
|
send_slack_test=send_slack_test,
|
|
)
|
|
if exit_code == 0:
|
|
capture_integration_verified(service or "all")
|
|
raise SystemExit(exit_code)
|