Files
bookhoard/bruno/library/Add Library Folder.bru
T
john-okeefe 8db5939892 refactor: standardize Bruno API requests with bruToJsonV2 format
- Convert all JSON tests to JavaScript functions for bruToJsonV2 compatibility
- Update authentication to use 'inherit' instead of manual headers
- Fix hardcoded URLs to use {{base_url}} variables
- Standardize variable syntax from {{ _.var }} to {{var}}
- Add comprehensive API documentation to all requests
- Update environment variables with missing required fields
- Apply consistent structure: meta, http method, headers, tests, vars, settings, docs
- Enhanced validation with proper error handling and field checks
2026-01-28 20:13:56 -05:00

114 lines
2.7 KiB
Plaintext

meta {
name: Add Library Folder
type: http
seq: 1
}
post {
url: {{base_url}}/api/libraries/{{libraryId}}/folders
auth: inherit
body: json
}
headers {
Content-Type: application/json
}
body:json {
{
"folder_path": "/path/to/library/media"
}
}
tests {
test_add_library_folder_success(status, headers, body) {
if (status !== 201) {
throw new Error("Expected status 201, got " + status);
}
const contentType = headers["content-type"];
if (!contentType || !contentType.includes("application/json")) {
throw new Error("Expected content-type to contain application/json, got " + contentType);
}
// Verify response body is valid JSON and has expected structure
let data;
try {
data = JSON.parse(body);
} catch (e) {
throw new Error("Response body is not valid JSON");
}
if (!data || typeof data !== "object") {
throw new Error("Expected response body to be an object");
}
// Check for required fields in folder response
if (!data.id) {
throw new Error("Folder response missing required field: id");
}
if (!data.library_id) {
throw new Error("Folder response missing required field: library_id");
}
if (!data.folder_path) {
throw new Error("Folder response missing required field: folder_path");
}
// Validate data types
if (typeof data.id !== "string") {
throw new Error("Folder id must be a string");
}
if (typeof data.folder_path !== "string") {
throw new Error("Folder path must be a string");
}
return true;
}
}
vars:pre-request {
libraryId: "8821b703-h29b-71d4-d716-446655440003"
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## Add Library Folder
Adds a new folder path to a library for media scanning and indexing.
**Method:** POST
**Endpoint:** /api/libraries/{id}/folders
**Authentication:** Required (Bearer token, admin permissions)
**Path Parameters:**
- `id` (string, required): Library UUID
**Request Body:**
- `folder_path` (string, required): Absolute path to the folder containing media files
**Response:** Folder object
- `id` (string): Folder UUID
- `library_id` (string): Library UUID
- `folder_path` (string): Absolute path to folder
- `is_active` (boolean): Whether folder is active for scanning
- `created_at` (string): Creation timestamp
- `updated_at` (string): Last update timestamp
**Status Codes:**
- 201: Folder added successfully
- 400: Invalid folder path or request data
- 401: Unauthorized
- 403: Forbidden (admin access required)
- 404: Library not found
- 409: Folder already exists for this library
- 500: Internal server error
}