Skip to content

fix(network): sg show/delete accept name as well as ID (closes #194)#198

Merged
crowdy merged 1 commit into
mainfrom
fix/issue-194-sg-delete-by-name
May 9, 2026
Merged

fix(network): sg show/delete accept name as well as ID (closes #194)#198
crowdy merged 1 commit into
mainfrom
fix/issue-194-sg-delete-by-name

Conversation

@crowdy
Copy link
Copy Markdown
Owner

@crowdy crowdy commented May 9, 2026

Summary

  • `conoha network sg delete ` returned an HTTP 405 from the upstream OpenStack endpoint because the CLI passed the literal name where the API expects a UUID. Other commands (e.g., `server delete <name|id>`) already accept either; this aligns sg show/delete with that.
  • New `NetworkAPI.FindSecurityGroup(nameOrID)` helper, used by both `sg show` and `sg delete`. The existing internal `resolveSecurityGroupID` now delegates to it.
  • `sg show` re-fetches by ID after the lookup so the rules array is included (list endpoint can return abbreviated form).
  • The `sg delete` confirm prompt now shows both name and ID, and accepts an exact name match (no fuzzy resolution).

Test plan

  • `go test ./internal/api/... -run Find` — new `TestSecurityGroupFindSecurityGroup` covers by-name, by-id, not-found
  • `go test ./...` — full suite green
  • Live verify: `conoha network sg create --name temp-sg && conoha network sg delete temp-sg` succeeds (no 405)
  • Live verify: `conoha network sg show temp-sg` returns details

🤖 Generated with Claude Code

Previously `network sg delete <name>` returned a confusing HTTP 405 from
the upstream OpenStack endpoint because the CLI passed the literal name
where the API expects a UUID. Other resources (server delete, etc.)
already accept either form; align security-group show/delete with that
convention.

- Add `NetworkAPI.FindSecurityGroup(nameOrID)` returning *SecurityGroup
  and refactor the existing internal `resolveSecurityGroupID` to use it
- `sg show <id|name>` looks up first, then re-fetches by ID to include
  rules (the list endpoint may abbreviate)
- `sg delete <id|name>` resolves up front; the confirm prompt and
  output now show both name and ID

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@crowdy crowdy merged commit b70a533 into main May 9, 2026
5 checks passed
@crowdy crowdy deleted the fix/issue-194-sg-delete-by-name branch May 9, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants