@solongate/proxy 0.82.41 → 0.82.43

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.
@@ -523,6 +523,8 @@ function flagBool(flags, name) {
523
523
  // src/commands/policy.ts
524
524
  var USAGE = usage("solongate policy", "manage cloud policies", [
525
525
  ["policy list", "list all policies"],
526
+ ["policy create <name>", "create a new empty policy"],
527
+ ["policy delete <id>", "delete a policy"],
526
528
  ["policy show <id>", "show one policy (rules, mode)"],
527
529
  ["policy allow <id> [--command|--path|--url <val>]", "append an ALLOW rule"],
528
530
  ["policy deny <id> [--command|--path|--url <val>]", "append a DENY rule"],
@@ -572,6 +574,22 @@ async function run(argv) {
572
574
  printRules(p.rules);
573
575
  return 0;
574
576
  }
577
+ case "create": {
578
+ const name = positionals.slice(1).join(" ").trim();
579
+ if (!name) return err(" Usage: policy create <name>"), 1;
580
+ const res = await api.policies.create({ id: `policy-${Date.now()}`, name, rules: [], mode: "denylist" });
581
+ if (json) return printJson(res), 0;
582
+ err(green(` \u2713 Created "${name}"`) + dim(` (${res.id})`));
583
+ return 0;
584
+ }
585
+ case "delete": {
586
+ const id = positionals[1];
587
+ if (!id) return err(" Usage: policy delete <id>"), 1;
588
+ const res = await api.policies.remove(id);
589
+ if (json) return printJson(res), 0;
590
+ err(green(` \u2713 Deleted ${res.policy_id}`));
591
+ return 0;
592
+ }
575
593
  case "allow":
576
594
  case "deny": {
577
595
  const effect = sub === "allow" ? "ALLOW" : "DENY";