Added create and delete operations for projects and boards with validation and error handling

This commit is contained in:
Steve Cliff
2026-02-17 07:47:49 +00:00
parent c03d05734a
commit c15a48cda3
15 changed files with 571 additions and 4 deletions
@@ -0,0 +1,39 @@
## MODIFIED Requirements
### Requirement: Project operations
The client SHALL provide methods to list all accessible projects (`GET /projects`), get a single project by ID (`GET /projects/{id}`), create a project (`POST /projects`), and delete a project (`DELETE /projects/{id}`).
#### Scenario: List projects
- **WHEN** `ListProjects` is called
- **THEN** the client SHALL send `GET /projects` and return a slice of Project models
#### Scenario: Get project
- **WHEN** `GetProject` is called with a project ID
- **THEN** the client SHALL send `GET /projects/{id}` and return a Project model
#### Scenario: Create project
- **WHEN** `CreateProject` is called with project fields (type, name, description)
- **THEN** the client SHALL send `POST /projects` with the provided fields and return the created Project
#### Scenario: Delete project
- **WHEN** `DeleteProject` is called with a project ID
- **THEN** the client SHALL send `DELETE /projects/{id}`
### Requirement: Board operations
The client SHALL provide a method to get a single board by ID (`GET /boards/{id}`), list board actions (`GET /boards/{boardId}/actions`) with pagination support, create a board (`POST /projects/{projectId}/boards`), and delete a board (`DELETE /boards/{id}`).
#### Scenario: Get board
- **WHEN** `GetBoard` is called with a board ID
- **THEN** the client SHALL send `GET /boards/{id}` and return a Board model including its included lists
#### Scenario: List board actions
- **WHEN** `ListBoardActions` is called with a board ID and limit
- **THEN** the client SHALL send paginated `GET /boards/{boardId}/actions` requests and return a slice of Action models
#### Scenario: Create board
- **WHEN** `CreateBoard` is called with a project ID and board fields (name, position)
- **THEN** the client SHALL send `POST /projects/{projectId}/boards` with the provided fields and return the created Board
#### Scenario: Delete board
- **WHEN** `DeleteBoard` is called with a board ID
- **THEN** the client SHALL send `DELETE /boards/{id}`
@@ -0,0 +1,83 @@
## MODIFIED Requirements
### Requirement: Project commands
The system SHALL provide a `project` command group with subcommands `list`, `get`, `create`, and `delete`. `pcli project list` SHALL call the client's ListProjects method and output the result. `pcli project get <id>` SHALL accept a project ID as a positional argument, call GetProject, and output the result. `pcli project create` SHALL create a new project. `pcli project delete <id>` SHALL delete a project.
#### Scenario: List projects
- **WHEN** `pcli project list` is executed
- **THEN** the system SHALL output all accessible projects
#### Scenario: Get project by ID
- **WHEN** `pcli project get <id>` is executed with a valid project ID
- **THEN** the system SHALL output the project details
#### Scenario: Get project missing ID
- **WHEN** `pcli project get` is executed without an ID argument
- **THEN** the system SHALL print an error indicating the ID is required and exit with code 1
#### Scenario: Create project
- **WHEN** `pcli project create --name "My Project" --type private --description "A test project"` is executed
- **THEN** the system SHALL create the project and output the created project
#### Scenario: Create project missing required flags
- **WHEN** `pcli project create` is executed without `--name` or `--type`
- **THEN** the system SHALL print an error indicating the required flags and exit with code 1
#### Scenario: Create project with insufficient permissions
- **WHEN** `pcli project create` is executed with invalid API credentials
- **THEN** the system SHALL output "create project: authentication failed — check your API key"
#### Scenario: Delete project
- **WHEN** `pcli project delete <id>` is executed with a valid project ID
- **THEN** the system SHALL delete the project and output a success confirmation
#### Scenario: Delete project with insufficient permissions
- **WHEN** `pcli project delete <id>` is executed by a user without project manager permissions
- **THEN** the system SHALL output "delete project: permission denied (requires project manager role)"
#### Scenario: Delete project not found
- **WHEN** `pcli project delete <id>` is executed with a non-existent project ID
- **THEN** the system SHALL output "delete project: not found — the resource may not exist or you may not have access to it"
### Requirement: Board commands
The system SHALL provide a `board` command group with subcommands `get`, `actions`, `create`, and `delete`. `pcli board get <id>` SHALL accept a board ID as a positional argument and output the board details. `pcli board actions <id>` SHALL accept a board ID and an optional `--limit` flag (int, default 0) and output the board's action history. `pcli board create` SHALL create a new board. `pcli board delete <id>` SHALL delete a board.
#### Scenario: Get board
- **WHEN** `pcli board get <id>` is executed
- **THEN** the system SHALL output the board details including its lists
#### Scenario: List board actions
- **WHEN** `pcli board actions <id>` is executed
- **THEN** the system SHALL output the board's action history
#### Scenario: List board actions with limit
- **WHEN** `pcli board actions <id> --limit 10` is executed
- **THEN** the system SHALL output at most 10 action entries
#### Scenario: Create board
- **WHEN** `pcli board create --project <id> --name "Development Board" --position 65536` is executed
- **THEN** the system SHALL create the board and output the created board
#### Scenario: Create board missing required flags
- **WHEN** `pcli board create` is executed without `--project` or `--name`
- **THEN** the system SHALL print an error indicating the required flags and exit with code 1
#### Scenario: Create board with insufficient permissions
- **WHEN** `pcli board create --project <id> --name "Board"` is executed by a user without project manager permissions on the project
- **THEN** the system SHALL output "create board: permission denied (requires project manager role)"
#### Scenario: Create board project not found
- **WHEN** `pcli board create --project <id> --name "Board"` is executed with a project the user cannot access
- **THEN** the system SHALL output "create board: not found — the resource may not exist or you may not have access to it"
#### Scenario: Delete board
- **WHEN** `pcli board delete <id>` is executed with a valid board ID
- **THEN** the system SHALL delete the board and output a success confirmation
#### Scenario: Delete board with insufficient permissions
- **WHEN** `pcli board delete <id>` is executed by a user without project manager permissions
- **THEN** the system SHALL output "delete board: permission denied (requires project manager role)"
#### Scenario: Delete board not found
- **WHEN** `pcli board delete <id>` is executed with a non-existent board ID
- **THEN** the system SHALL output "delete board: not found — the resource may not exist or you may not have access to it"
@@ -0,0 +1,28 @@
## ADDED Requirements
### Requirement: Permission error translation helper
The system SHALL provide a `friendlyAPIError` function in the `cmd` package that translates APIError status codes into human-readable messages with operation context.
#### Scenario: Authentication error (401)
- **WHEN** an APIError with StatusCode 401 is passed to friendlyAPIError with operation "create board"
- **THEN** the function SHALL return an error with message "create board: authentication failed — check your API key"
#### Scenario: Permission denied (403) with hint
- **WHEN** an APIError with StatusCode 403 is passed to friendlyAPIError with operation "create board" and permissionHint "requires project manager role"
- **THEN** the function SHALL return an error with message "create board: permission denied (requires project manager role)"
#### Scenario: Permission denied (403) without hint
- **WHEN** an APIError with StatusCode 403 is passed to friendlyAPIError with operation "create project" and empty permissionHint
- **THEN** the function SHALL return an error with message "create project: permission denied"
#### Scenario: Not found (404)
- **WHEN** an APIError with StatusCode 404 is passed to friendlyAPIError with operation "delete board"
- **THEN** the function SHALL return an error with message "delete board: not found — the resource may not exist or you may not have access to it"
#### Scenario: Non-API error
- **WHEN** a non-APIError (e.g., network error) is passed to friendlyAPIError
- **THEN** the function SHALL return the original error unchanged
#### Scenario: Unknown status code
- **WHEN** an APIError with StatusCode 500 is passed to friendlyAPIError
- **THEN** the function SHALL return the original APIError unchanged