#!/usr/bin/env python3 """Resolve provider, region, deploy type, and metrics targets from a cluster ID.""" from __future__ import annotations import argparse import json import os from pathlib import Path from o11y_common import resolve_cluster, write_private_json def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser( description=( "Resolve an O11Y cluster through the installed Clinic Skill when " "authenticated, then the bounded nutshell o11y-data GS scan." ) ) parser.add_argument("--cluster-id", required=True) parser.add_argument("--tenant-id", help="Optional expected tenant ID for safety validation.") parser.add_argument("--provider", choices=("aws", "gcp", "alicloud"), help="Optional hint.") parser.add_argument("--region", help="Optional region hint.") parser.add_argument("--deploy-type", help="Optional expected deploy type.") parser.add_argument("--analysis-time", type=int, help="Optional epoch used while probing targets.") parser.add_argument("--timeout", type=int, default=30) parser.add_argument("--output", type=Path, required=True) return parser.parse_args() def main() -> int: os.umask(0o077) args = parse_args() context, _ = resolve_cluster( cluster_id=args.cluster_id, expected_tenant_id=args.tenant_id, provider_hint=args.provider, region_hint=args.region, deploy_type_hint=args.deploy_type, analysis_timestamp=args.analysis_time, timeout=args.timeout, ) write_private_json(args.output, context) print(json.dumps(context, ensure_ascii=False)) return 0 if __name__ == "__main__": raise SystemExit(main())