Added create and delete operations for projects and boards with validation and error handling
This commit is contained in:
@@ -52,7 +52,7 @@ The system SHALL implement cursor-based pagination for all list endpoints that s
|
||||
- **THEN** the client SHALL return those items without making additional requests
|
||||
|
||||
### Requirement: Project operations
|
||||
The client SHALL provide methods to list all accessible projects (`GET /projects`) and get a single project by ID (`GET /projects/{id}`).
|
||||
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
|
||||
@@ -62,8 +62,16 @@ The client SHALL provide methods to list all accessible projects (`GET /projects
|
||||
- **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}`) and list board actions (`GET /boards/{boardId}/actions`) with pagination support.
|
||||
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
|
||||
@@ -73,6 +81,14 @@ The client SHALL provide a method to get a single board by ID (`GET /boards/{id}
|
||||
- **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}`
|
||||
|
||||
### Requirement: Card CRUD operations
|
||||
The client SHALL provide methods for: get card (`GET /cards/{id}`), create card (`POST /lists/{listId}/cards`), update card (`PATCH /cards/{id}`), delete card (`DELETE /cards/{id}`), and duplicate card (`POST /cards/{id}/duplicate`). The client SHALL provide a method to list cards in a list (`GET /lists/{listId}/cards`) with pagination support. The client SHALL provide a method to list card actions (`GET /cards/{cardId}/actions`) with pagination support.
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ The system SHALL provide a root command `pcli` that serves as the entry point. T
|
||||
- **AND** the system SHALL exit with code 1
|
||||
|
||||
### Requirement: Project commands
|
||||
The system SHALL provide a `project` command group with subcommands `list` and `get`. `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.
|
||||
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
|
||||
@@ -36,8 +36,32 @@ The system SHALL provide a `project` command group with subcommands `list` and `
|
||||
- **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` and `actions`. `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.
|
||||
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
|
||||
@@ -51,6 +75,34 @@ The system SHALL provide a `board` command group with subcommands `get` and `act
|
||||
- **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"
|
||||
|
||||
### Requirement: Card commands
|
||||
The system SHALL provide a `card` command group with subcommands: `list`, `get`, `create`, `update`, `delete`, `duplicate`, `move`, `assign`, `unassign`, `add-label`, `remove-label`, `actions`.
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user