Files
bookhoard/bruno/collections/Bulk Remove Books.bru
T
john-okeefe 3117ce54ec refactor(bruno): migrate API tests to Bruno DSL format
- Convert all existing .bru files from JSON to Bruno DSL format
- Remove obsolete files (conflicts/api.bru, kobo/Kobo Initialization.bru)
- Update auth configuration to use 'inherit' instead of explicit bearer tokens
- Add comprehensive documentation to all test files
- Improve test scripts with proper assertions and error handling
2026-02-08 20:49:06 -05:00

117 lines
2.5 KiB
Plaintext

meta {
name: Bulk Remove Books from Collection
type: http
seq: 1
}
post {
url: {{baseUrl}}/api/collections/{{collection_id}}/books/bulk-remove
body: json
auth: inherit
}
headers {
Content-Type: application/json
Authorization: Bearer {{authToken}}
}
body:json {
{
"book_ids": [
"{{bookId1}}",
"{{bookId2}}",
"{{bookId3}}"
]
}
}
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
tests['Bulk remove successful'] = true;
const body = res.getBody();
tests['Has removed count'] = body.removed !== undefined;
tests['Has total count'] = body.total !== undefined;
tests['Has results array'] = Array.isArray(body.results);
} else {
tests['Bulk remove failed'] = false;
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## Bulk Remove Books from Collection
Removes multiple books from a collection in a single request.
**Method:** POST
**Endpoint:** /api/collections/{collection_id}/books/bulk-remove
**Authentication:** Bearer token
**Path Parameters:**
- `collection_id` (string): Collection UUID
**Request Body:**
- `book_ids` (array): Array of book UUIDs to remove from the collection
**Response:**
- `removed` (number): Number of books successfully removed
- `total` (number): Total number of books processed
- `results` (array): Results for each removal attempt
- `book_id` (string): Book UUID
- `success` (boolean): Whether the removal succeeded
- `error` (string, optional): Error message if failed
**Status Codes:**
- 200: Success (with partial results if some failed)
- 400: Invalid request data (e.g., empty book_ids array)
- 401: Unauthorized
- 403: Forbidden
- 404: Collection not found
- 500: Internal server error
**Example Request:**
```json
{
"book_ids": [
"book-uuid-1",
"book-uuid-2",
"book-uuid-3"
]
}
```
**Example Response:**
```json
{
"removed": 2,
"total": 3,
"results": [
{
"book_id": "book-uuid-1",
"success": true
},
{
"book_id": "book-uuid-2",
"success": true
},
{
"book_id": "book-uuid-3",
"success": false,
"error": "Book not in collection"
}
]
}
```
**Note:** Removing a book that's not in the collection returns success: false for that book but doesn't fail the entire request. Empty book_ids array returns 400.
}