personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove old vertex-credentials endpoint (replaced by unified providers API)

Post-merge cleanup from hopper-zgw4ggix-vertex-sa-creds. The separate
/api/vertex-credentials POST/DELETE endpoints are superseded by the
unified PUT /api/providers with vertex_credentials field.

-112
-112
apps/settings/routes.py
··· 524 524 return jsonify({"error": "something went wrong — try again, and if it persists, check the health dashboard"}), 500 525 525 526 526 527 - @settings_bp.route("/api/vertex-credentials", methods=["POST"]) 528 - def upload_vertex_credentials() -> Any: 529 - """Upload or paste Vertex AI service account credentials JSON. 530 - 531 - Accepts JSON body with a "credentials" key containing the service account JSON. 532 - Validates required fields, saves to {journal}/config/vertex-credentials.json, 533 - and stores the path in providers.vertex_credentials. 534 - """ 535 - try: 536 - request_data = request.get_json() 537 - if not request_data or "credentials" not in request_data: 538 - return jsonify({"error": "No credentials provided"}), 400 539 - 540 - creds = request_data["credentials"] 541 - if isinstance(creds, str): 542 - try: 543 - creds = json.loads(creds) 544 - except json.JSONDecodeError: 545 - return jsonify({"error": "Invalid JSON"}), 400 546 - 547 - if not isinstance(creds, dict): 548 - return jsonify({"error": "Credentials must be a JSON object"}), 400 549 - 550 - # Validate required fields 551 - required = ("type", "project_id", "client_email", "private_key") 552 - missing = [f for f in required if not creds.get(f)] 553 - if missing: 554 - return ( 555 - jsonify( 556 - {"error": f"Missing required fields: {', '.join(missing)}"} 557 - ), 558 - 400, 559 - ) 560 - 561 - if creds.get("type") != "service_account": 562 - return jsonify({"error": "Credentials type must be 'service_account'"}), 400 563 - 564 - # Save credentials file 565 - config_dir = Path(state.journal_root) / "config" 566 - config_dir.mkdir(parents=True, exist_ok=True) 567 - creds_path = config_dir / "vertex-credentials.json" 568 - with open(creds_path, "w", encoding="utf-8") as f: 569 - json.dump(creds, f, indent=2, ensure_ascii=False) 570 - f.write("\n") 571 - os.chmod(creds_path, 0o600) 572 - 573 - # Store path in config 574 - config = get_journal_config() 575 - if "providers" not in config: 576 - config["providers"] = {} 577 - config["providers"]["vertex_credentials"] = str(creds_path) 578 - 579 - config_path = config_dir / "journal.json" 580 - with open(config_path, "w", encoding="utf-8") as f: 581 - json.dump(config, f, indent=2, ensure_ascii=False) 582 - f.write("\n") 583 - os.chmod(config_path, 0o600) 584 - 585 - log_app_action( 586 - app="settings", 587 - facet=None, 588 - action="vertex_credentials_upload", 589 - params={"client_email": creds.get("client_email")}, 590 - ) 591 - 592 - return jsonify( 593 - { 594 - "success": True, 595 - "client_email": creds.get("client_email"), 596 - } 597 - ) 598 - except Exception: 599 - logger.exception("error saving vertex credentials") 600 - return jsonify({"error": "something went wrong — try again, and if it persists, check the health dashboard"}), 500 601 - 602 - 603 - @settings_bp.route("/api/vertex-credentials", methods=["DELETE"]) 604 - def delete_vertex_credentials() -> Any: 605 - """Remove Vertex AI service account credentials.""" 606 - try: 607 - # Remove credentials file 608 - config_dir = Path(state.journal_root) / "config" 609 - creds_path = config_dir / "vertex-credentials.json" 610 - if creds_path.exists(): 611 - creds_path.unlink() 612 - 613 - # Remove from config 614 - config = get_journal_config() 615 - if "providers" in config: 616 - config["providers"].pop("vertex_credentials", None) 617 - # Clear stale validation result 618 - if "key_validation" in config["providers"]: 619 - config["providers"]["key_validation"].pop("google", None) 620 - 621 - config_path = config_dir / "journal.json" 622 - config_dir.mkdir(parents=True, exist_ok=True) 623 - with open(config_path, "w", encoding="utf-8") as f: 624 - json.dump(config, f, indent=2, ensure_ascii=False) 625 - f.write("\n") 626 - os.chmod(config_path, 0o600) 627 - 628 - log_app_action( 629 - app="settings", 630 - facet=None, 631 - action="vertex_credentials_delete", 632 - params={}, 633 - ) 634 - 635 - return jsonify({"success": True}) 636 - except Exception: 637 - logger.exception("error deleting vertex credentials") 638 - return jsonify({"error": "something went wrong — try again, and if it persists, check the health dashboard"}), 500 639 527 640 528 641 529 @settings_bp.route("/api/providers", methods=["PUT"])