#!/usr/bin/env python3 """RBAC path registration for pipeline_ops module.""" import os, sys, subprocess MOD = "pipeline_ops" PATHS_ANY = [ f"/{MOD}/index.ui", ] PATHS_LOGINED = [ f"/{MOD}", f"/{MOD}/api/ops_dashboard_data.dspy", # Pricing f"/{MOD}/pipeline_pricing/index.ui", f"/{MOD}/pipeline_pricing/get_pipeline_pricing.dspy", f"/{MOD}/pipeline_pricing/add_pipeline_pricing.dspy", f"/{MOD}/pipeline_pricing/update_pipeline_pricing.dspy", f"/{MOD}/pipeline_pricing/delete_pipeline_pricing.dspy", # Capacity f"/{MOD}/pipeline_capacity/index.ui", f"/{MOD}/pipeline_capacity/get_pipeline_capacity.dspy", f"/{MOD}/pipeline_capacity/add_pipeline_capacity.dspy", f"/{MOD}/pipeline_capacity/update_pipeline_capacity.dspy", f"/{MOD}/pipeline_capacity/delete_pipeline_capacity.dspy", # Usage Log f"/{MOD}/pipeline_usage_log/index.ui", f"/{MOD}/pipeline_usage_log/get_pipeline_usage_log.dspy", f"/{MOD}/pipeline_usage_log/add_pipeline_usage_log.dspy", f"/{MOD}/pipeline_usage_log/update_pipeline_usage_log.dspy", f"/{MOD}/pipeline_usage_log/delete_pipeline_usage_log.dspy", # API f"/{MOD}/api/pipeline_pricing_create.dspy", f"/{MOD}/api/pipeline_pricing_update.dspy", f"/{MOD}/api/pipeline_pricing_delete.dspy", f"/{MOD}/api/pipeline_capacity_create.dspy", f"/{MOD}/api/pipeline_capacity_update.dspy", f"/{MOD}/api/pipeline_capacity_delete.dspy", f"/{MOD}/api/pipeline_usage_log_create.dspy", f"/{MOD}/api/pipeline_usage_log_update.dspy", f"/{MOD}/api/pipeline_usage_log_delete.dspy", f"/{MOD}/api/get_search_pipeline_id.dspy", ] def main(): root = os.path.expanduser("~/pipeline") set_perm = os.path.join(root, "set_role_perm.py") if not os.path.isfile(set_perm): print("ERROR: pipeline root not found"); sys.exit(1) py = sys.executable count = 0 for role, paths in [("any", PATHS_ANY), ("logined", PATHS_LOGINED)]: for path in paths: r = subprocess.run([py, set_perm, role, path], capture_output=True, text=True, cwd=root) if r.returncode == 0: count += 1 else: print(f" WARN: {path}") print(f"Registered {count}/{len(PATHS_ANY)+len(PATHS_LOGINED)} paths for {MOD}") if __name__ == "__main__": main()