Skip to content

Commit cf3ccce

Browse files
committed
refactor: ADR-0008 lots 4+5 — migrate object and qos
object (8 leaves): container-list/show/create/delete/set/save → object container <verb> account-set/unset → object account set/unset qos (8 leaves): policy-list/show/create/set/delete → qos policy <verb> rule-list/create/delete → qos rule <verb> Sub-groups created: ``object container``, ``object account``, ``qos policy``, ``qos rule``. All sixteen old hyphenated names live on as deprecated aliases via ``add_command_with_alias``; whitelists for ``object`` and ``qos`` are now empty.
1 parent 37b4751 commit cf3ccce

3 files changed

Lines changed: 90 additions & 26 deletions

File tree

orca_cli/commands/object_store.py

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import click
1212
from rich.tree import Tree
1313

14+
from orca_cli.core.aliases import add_command_with_alias
1415
from orca_cli.core.context import OrcaContext
1516
from orca_cli.core.exceptions import OrcaCLIError
1617
from orca_cli.core.output import console, output_options, print_detail, print_list
@@ -80,7 +81,12 @@ def object_stats(ctx: click.Context, output_format: str, columns: tuple[str, ...
8081
# ── container-list ───────────────────────────────────────────────────────────
8182

8283

83-
@object_store.command("container-list")
84+
@object_store.group("container")
85+
def object_container() -> None:
86+
"""Manage Swift containers."""
87+
88+
89+
@object_container.command("list")
8490
@output_options
8591
@click.pass_context
8692
def container_list(ctx: click.Context, output_format: str, columns: tuple[str, ...], fit_width: bool, max_width: int | None, noindent: bool) -> None:
@@ -109,7 +115,7 @@ def container_list(ctx: click.Context, output_format: str, columns: tuple[str, .
109115
# ── container-show ───────────────────────────────────────────────────────────
110116

111117

112-
@object_store.command("container-show")
118+
@object_container.command("show")
113119
@click.argument("container")
114120
@output_options
115121
@click.pass_context
@@ -141,7 +147,7 @@ def container_show(ctx: click.Context, container: str, output_format: str, colum
141147
# ── container-create ─────────────────────────────────────────────────────────
142148

143149

144-
@object_store.command("container-create")
150+
@object_container.command("create")
145151
@click.argument("container")
146152
@click.pass_context
147153
def container_create(ctx: click.Context, container: str) -> None:
@@ -155,7 +161,7 @@ def container_create(ctx: click.Context, container: str) -> None:
155161
# ── container-delete ─────────────────────────────────────────────────────────
156162

157163

158-
@object_store.command("container-delete")
164+
@object_container.command("delete")
159165
@click.argument("container")
160166
@click.option("--recursive", is_flag=True, default=False, help="Delete all objects before deleting the container.")
161167
@click.option("--yes", "-y", is_flag=True, help="Skip confirmation prompt.")
@@ -186,7 +192,7 @@ def container_delete(ctx: click.Context, container: str, recursive: bool, yes: b
186192
# ── container-set ────────────────────────────────────────────────────────────
187193

188194

189-
@object_store.command("container-set")
195+
@object_container.command("set")
190196
@click.argument("container")
191197
@click.option("--property", "properties", multiple=True, required=True, help="Metadata key=value pair (repeatable).")
192198
@click.pass_context
@@ -209,7 +215,7 @@ def container_set(ctx: click.Context, container: str, properties: tuple[str, ...
209215
# ── container-save ───────────────────────────────────────────────────────────
210216

211217

212-
@object_store.command("container-save")
218+
@object_container.command("save")
213219
@click.argument("container")
214220
@click.option("--output-dir", default=".", show_default=True, help="Local directory to save objects into.")
215221
@click.pass_context
@@ -593,7 +599,12 @@ def object_unset(ctx: click.Context, container: str, object_name: str, propertie
593599
# ── account-set ───────────────────────────────────────────────────────────────
594600

595601

596-
@object_store.command("account-set")
602+
@object_store.group("account")
603+
def object_account() -> None:
604+
"""Manage Swift account-level metadata."""
605+
606+
607+
@object_account.command("set")
597608
@click.option("--property", "properties", multiple=True, required=True, help="Metadata key=value pair (repeatable).")
598609
@click.pass_context
599610
def object_account_set(ctx: click.Context, properties: tuple[str, ...]) -> None:
@@ -615,7 +626,7 @@ def object_account_set(ctx: click.Context, properties: tuple[str, ...]) -> None:
615626
# ── account-unset ─────────────────────────────────────────────────────────────
616627

617628

618-
@object_store.command("account-unset")
629+
@object_account.command("unset")
619630
@click.option("--property", "properties", multiple=True, required=True, help="Metadata key to remove (repeatable).")
620631
@click.pass_context
621632
def object_account_unset(ctx: click.Context, properties: tuple[str, ...]) -> None:
@@ -694,3 +705,31 @@ def _add_nodes(parent_tree: Tree, subtree: dict) -> None:
694705

695706
_add_nodes(tree, folder_tree)
696707
console.print(tree)
708+
709+
710+
# ── ADR-0008 deprecated aliases (backward compatibility) ────────────────
711+
712+
add_command_with_alias(object_store, container_list,
713+
legacy_name="container-list",
714+
primary_path="object container list")
715+
add_command_with_alias(object_store, container_show,
716+
legacy_name="container-show",
717+
primary_path="object container show")
718+
add_command_with_alias(object_store, container_create,
719+
legacy_name="container-create",
720+
primary_path="object container create")
721+
add_command_with_alias(object_store, container_delete,
722+
legacy_name="container-delete",
723+
primary_path="object container delete")
724+
add_command_with_alias(object_store, container_set,
725+
legacy_name="container-set",
726+
primary_path="object container set")
727+
add_command_with_alias(object_store, container_save,
728+
legacy_name="container-save",
729+
primary_path="object container save")
730+
add_command_with_alias(object_store, object_account_set,
731+
legacy_name="account-set",
732+
primary_path="object account set")
733+
add_command_with_alias(object_store, object_account_unset,
734+
legacy_name="account-unset",
735+
primary_path="object account unset")

orca_cli/commands/qos_policy.py

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import click
66

7+
from orca_cli.core.aliases import add_command_with_alias
78
from orca_cli.core.context import OrcaContext
89
from orca_cli.core.exceptions import OrcaCLIError
910
from orca_cli.core.output import console, output_options, print_detail, print_list
@@ -26,7 +27,12 @@ def qos_policy() -> None:
2627

2728
# ── Policy CRUD ────────────────────────────────────────────────────────────
2829

29-
@qos_policy.command("policy-list")
30+
@qos_policy.group("policy")
31+
def qos_policy_group() -> None:
32+
"""Manage QoS policies."""
33+
34+
35+
@qos_policy_group.command("list")
3036
@click.option("--shared", is_flag=True, default=False, help="Show only shared policies.")
3137
@output_options
3238
@click.pass_context
@@ -50,7 +56,7 @@ def qos_policy_list(ctx, shared, output_format, columns, fit_width, max_width, n
5056
)
5157

5258

53-
@qos_policy.command("policy-show")
59+
@qos_policy_group.command("show")
5460
@click.argument("policy_id", callback=validate_id)
5561
@output_options
5662
@click.pass_context
@@ -66,7 +72,7 @@ def qos_policy_show(ctx, policy_id, output_format, columns, fit_width, max_width
6672
)
6773

6874

69-
@qos_policy.command("policy-create")
75+
@qos_policy_group.command("create")
7076
@click.option("--name", required=True, help="Policy name.")
7177
@click.option("--shared", is_flag=True, default=False, help="Share with all projects.")
7278
@click.option("--default", "is_default", is_flag=True, default=False,
@@ -83,7 +89,7 @@ def qos_policy_create(ctx, name, shared, is_default, description):
8389
console.print(f"[green]QoS policy '{name}' created: {p.get('id', '?')}[/green]")
8490

8591

86-
@qos_policy.command("policy-set")
92+
@qos_policy_group.command("set")
8793
@click.argument("policy_id", callback=validate_id)
8894
@click.option("--name", default=None, help="New name.")
8995
@click.option("--description", default=None, help="New description.")
@@ -110,7 +116,7 @@ def qos_policy_set(ctx, policy_id, name, description, shared, is_default):
110116
console.print(f"[green]QoS policy {policy_id} updated.[/green]")
111117

112118

113-
@qos_policy.command("policy-delete")
119+
@qos_policy_group.command("delete")
114120
@click.argument("policy_id", callback=validate_id)
115121
@click.option("--yes", "-y", is_flag=True, help="Skip confirmation.")
116122
@click.pass_context
@@ -125,7 +131,12 @@ def qos_policy_delete(ctx, policy_id, yes):
125131

126132
# ── Rules ─────────────────────────────────────────────────────────────────
127133

128-
@qos_policy.command("rule-list")
134+
@qos_policy.group("rule")
135+
def qos_rule() -> None:
136+
"""Manage QoS rules attached to a policy."""
137+
138+
139+
@qos_rule.command("list")
129140
@click.argument("policy_id", callback=validate_id)
130141
@click.option("--type", "rule_type",
131142
type=click.Choice(list(_RULE_TYPES)),
@@ -155,7 +166,7 @@ def qos_rule_list(ctx, policy_id, rule_type,
155166
)
156167

157168

158-
@qos_policy.command("rule-create")
169+
@qos_rule.command("create")
159170
@click.argument("policy_id", callback=validate_id)
160171
@click.option("--type", "rule_type",
161172
type=click.Choice(list(_RULE_TYPES)),
@@ -208,7 +219,7 @@ def qos_rule_create(ctx, policy_id, rule_type, max_kbps, max_burst_kbps,
208219
console.print(f"[green]QoS {rule_type} rule created: {r.get('id', '?')}[/green]")
209220

210221

211-
@qos_policy.command("rule-delete")
222+
@qos_rule.command("delete")
212223
@click.argument("policy_id", callback=validate_id)
213224
@click.argument("rule_id", callback=validate_id)
214225
@click.option("--type", "rule_type",
@@ -224,3 +235,23 @@ def qos_rule_delete(ctx, policy_id, rule_id, rule_type, yes):
224235
click.confirm(f"Delete QoS {rule_type} rule {rule_id}?", abort=True)
225236
svc.delete_qos_rule(policy_id, _RULE_TYPES[rule_type], rule_id)
226237
console.print(f"[green]QoS rule {rule_id} deleted.[/green]")
238+
239+
240+
# ── ADR-0008 deprecated aliases (backward compatibility) ────────────────
241+
242+
add_command_with_alias(qos_policy, qos_policy_list,
243+
legacy_name="policy-list", primary_path="qos policy list")
244+
add_command_with_alias(qos_policy, qos_policy_show,
245+
legacy_name="policy-show", primary_path="qos policy show")
246+
add_command_with_alias(qos_policy, qos_policy_create,
247+
legacy_name="policy-create", primary_path="qos policy create")
248+
add_command_with_alias(qos_policy, qos_policy_set,
249+
legacy_name="policy-set", primary_path="qos policy set")
250+
add_command_with_alias(qos_policy, qos_policy_delete,
251+
legacy_name="policy-delete", primary_path="qos policy delete")
252+
add_command_with_alias(qos_policy, qos_rule_list,
253+
legacy_name="rule-list", primary_path="qos rule list")
254+
add_command_with_alias(qos_policy, qos_rule_create,
255+
legacy_name="rule-create", primary_path="qos rule create")
256+
add_command_with_alias(qos_policy, qos_rule_delete,
257+
legacy_name="rule-delete", primary_path="qos rule delete")

tests/test_naming_convention.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,8 @@
7474
# nested under a sub-group (agent, port, rbac, segment, subnet,
7575
# auto-allocated-topology, router) or sub-sub-group (router add/remove
7676
# for interface/route, router set/unset for gateway).
77-
"object": {
78-
"account-set", "account-unset",
79-
"container-create", "container-delete", "container-list",
80-
"container-save", "container-set", "container-show",
81-
},
77+
# object — migrated 2026-04-28: account-* moved under
78+
# ``object account``, container-* moved under ``object container``.
8279
"placement": {
8380
"allocation-candidate-list", "allocation-delete", "allocation-set",
8481
"allocation-show",
@@ -104,11 +101,8 @@
104101
"set-color", "set-region",
105102
"to-clouds", "to-openrc",
106103
},
107-
"qos": {
108-
"policy-create", "policy-delete", "policy-list",
109-
"policy-set", "policy-show",
110-
"rule-create", "rule-delete", "rule-list",
111-
},
104+
# qos — migrated 2026-04-28: policy-* under ``qos policy``,
105+
# rule-* under ``qos rule``.
112106
"rating": {
113107
"metric-list", "metric-show",
114108
"module-disable", "module-enable", "module-list",

0 commit comments

Comments
 (0)