refactor: update Bruno API collection for media-items system
- Remove all ebook-specific API requests (15 files deleted) - Rename Scan Ebooks.bru to Scan Media Items.bru - Update API paths from /api/ebooks to /api/media-items - Update base URL and environment configuration - Maintain all existing media-items, library, auth, and progress tests Aligns Bruno collection with unified media-items API architecture
This commit is contained in:
@@ -6,8 +6,8 @@ meta {
|
||||
|
||||
post {
|
||||
url: {{base_url}}/api/libraries/{{library_id}}/folders
|
||||
auth: inherit
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
@@ -16,56 +16,7 @@ headers {
|
||||
|
||||
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;
|
||||
"folder_path": {{library_folder}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,4 +62,4 @@ docs {
|
||||
- 404: Library not found
|
||||
- 409: Folder already exists for this library
|
||||
- 500: Internal server error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,20 @@ body:json {
|
||||
}
|
||||
}
|
||||
|
||||
script:post-response {
|
||||
function onResponse(res) {
|
||||
let data = res.getBody();
|
||||
// If successful registration, set token environment variable
|
||||
if (res.getStatus() === 201 || res.getStatus() === 200) {
|
||||
if (data && data.id) {
|
||||
|
||||
return bru.setEnvVar("library_id", data.id, { persist: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
onResponse(res);
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
|
||||
@@ -6,6 +6,7 @@ meta {
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/libraries/{{library_id}}/folders
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
@@ -13,52 +14,6 @@ headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_get_library_folders_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, 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 (!Array.isArray(data)) {
|
||||
throw new Error("Expected response body to be an array");
|
||||
}
|
||||
|
||||
// Validate each folder in array
|
||||
data.forEach((folder, index) => {
|
||||
if (!folder || typeof folder !== "object") {
|
||||
throw new Error("Folder at index " + index + " is not an object");
|
||||
}
|
||||
|
||||
if (!folder.id) {
|
||||
throw new Error("Folder at index " + index + " missing required field: id");
|
||||
}
|
||||
|
||||
if (!folder.folder_path) {
|
||||
throw new Error("Folder at index " + index + " missing required field: folder_path");
|
||||
}
|
||||
|
||||
if (!folder.library_id) {
|
||||
throw new Error("Folder at index " + index + " missing required field: library_id");
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
libraryId: "8821b703-h29b-71d4-d716-446655440003"
|
||||
}
|
||||
@@ -97,4 +52,4 @@ docs {
|
||||
- 403: Forbidden (library access denied)
|
||||
- 404: Library not found
|
||||
- 500: Internal server error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ meta {
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/libraries/types
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
@@ -13,48 +14,6 @@ headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_get_library_types_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, 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 (!Array.isArray(data)) {
|
||||
throw new Error("Expected response body to be an array");
|
||||
}
|
||||
|
||||
// Validate each library type
|
||||
data.forEach((type, index) => {
|
||||
if (!type || typeof type !== "object") {
|
||||
throw new Error("Library type at index " + index + " is not an object");
|
||||
}
|
||||
|
||||
if (!type.id) {
|
||||
throw new Error("Library type at index " + index + " missing required field: id");
|
||||
}
|
||||
|
||||
if (!type.name) {
|
||||
throw new Error("Library type at index " + index + " missing required field: name");
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
@@ -80,4 +39,4 @@ docs {
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ meta {
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/library/scan-settings
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
@@ -13,42 +14,6 @@ headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_get_scan_settings_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, 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
|
||||
if (typeof data.scan_frequency_minutes !== "number" || data.scan_frequency_minutes < 1) {
|
||||
throw new Error("Invalid scan_frequency_minutes: " + data.scan_frequency_minutes);
|
||||
}
|
||||
|
||||
if (typeof data.auto_scan_enabled !== "boolean") {
|
||||
throw new Error("Invalid auto_scan_enabled: " + data.auto_scan_enabled);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
@@ -56,25 +21,25 @@ settings {
|
||||
|
||||
docs {
|
||||
## Get Scan Settings
|
||||
|
||||
|
||||
Retrieves the user's current library scanning settings.
|
||||
|
||||
|
||||
**Method:** GET
|
||||
|
||||
|
||||
**Endpoint:** /api/library/scan-settings
|
||||
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
|
||||
**Response:**
|
||||
- `scan_frequency_minutes` (number): Minutes between automatic scans (minimum 1)
|
||||
- `auto_scan_enabled` (boolean): Whether automatic scanning is enabled
|
||||
- `last_scan_at` (string, optional): Timestamp of last scan
|
||||
- `next_scan_at` (string, optional): Timestamp of next scheduled scan
|
||||
- `library_id` (string, optional): Library ID for context
|
||||
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (access denied)
|
||||
- 500: Internal server error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ meta {
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/libraries/visible
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
@@ -13,52 +14,6 @@ headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_get_visible_libraries_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, 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 (!Array.isArray(data)) {
|
||||
throw new Error("Expected response body to be an array");
|
||||
}
|
||||
|
||||
// Validate each library in array (all should be visible)
|
||||
data.forEach((library, index) => {
|
||||
if (!library || typeof library !== "object") {
|
||||
throw new Error("Library at index " + index + " is not an object");
|
||||
}
|
||||
|
||||
if (!library.id) {
|
||||
throw new Error("Library at index " + index + " missing required field: id");
|
||||
}
|
||||
|
||||
if (!library.name) {
|
||||
throw new Error("Library at index " + index + " missing required field: name");
|
||||
}
|
||||
|
||||
if (library.is_visible !== true) {
|
||||
throw new Error("Library at index " + index + " is not marked as visible");
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
@@ -88,4 +43,4 @@ docs {
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ meta {
|
||||
|
||||
post {
|
||||
url: {{base_url}}/api/libraries/visibility
|
||||
auth: inherit
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
@@ -21,42 +21,6 @@ body:json {
|
||||
}
|
||||
}
|
||||
|
||||
tests {
|
||||
test_set_visibility_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, 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 response
|
||||
if (!data.library_id) {
|
||||
throw new Error("Response missing required field: library_id");
|
||||
}
|
||||
|
||||
if (typeof data.is_visible !== "boolean") {
|
||||
throw new Error("Response missing required field: is_visible or not boolean");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
libraryId: "8821b703-h29b-71d4-d716-446655440003",
|
||||
isVisible: true
|
||||
@@ -96,4 +60,4 @@ docs {
|
||||
- 403: Forbidden (admin access required)
|
||||
- 404: Library not found
|
||||
- 500: Internal server error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ meta {
|
||||
|
||||
put {
|
||||
url: {{base_url}}/api/library/scan-settings
|
||||
auth: inherit
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
@@ -21,38 +21,6 @@ body:json {
|
||||
}
|
||||
}
|
||||
|
||||
tests {
|
||||
test_update_scan_settings_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, 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 success message or updated settings
|
||||
if (!data.message && typeof data.scan_frequency_minutes !== "number") {
|
||||
throw new Error("Response missing expected fields");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
@@ -60,74 +28,24 @@ settings {
|
||||
|
||||
docs {
|
||||
## Update Scan Settings
|
||||
|
||||
Updates user's library scanning settings.
|
||||
|
||||
**Method:** PUT
|
||||
|
||||
**Endpoint:** /api/library/scan-settings
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Request Body:**
|
||||
- `scan_frequency_minutes` (number, required): Minutes between automatic scans (1-1440)
|
||||
- `auto_scan_enabled` (boolean, required): Whether automatic scanning is enabled
|
||||
- `library_id` (string, optional): Specific library ID to update (if not provided, updates global)
|
||||
|
||||
**Response:** Updated scan settings object
|
||||
- `scan_frequency_minutes` (number): Updated frequency
|
||||
- `auto_scan_enabled` (boolean): Updated enabled status
|
||||
- `last_scan_at` (string, optional): Timestamp of last scan
|
||||
- `next_scan_at` (string, optional): Timestamp of next scheduled scan
|
||||
- `updated_at` (string): Timestamp of settings update
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 400: Invalid settings (frequency out of range)
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (access denied)
|
||||
- 404: Library not found (if library_id provided)
|
||||
- 500: Internal server error
|
||||
}
|
||||
|
||||
put {
|
||||
url: {{base_url}}/api/library/scan-settings
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body {
|
||||
{
|
||||
"scan_frequency_minutes": 60,
|
||||
"auto_scan_enabled": true
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Update Scan Settings
|
||||
|
||||
|
||||
Updates the user's ebook scanning settings.
|
||||
|
||||
|
||||
**Method:** PUT
|
||||
|
||||
|
||||
**Endpoint:** /api/library/scan-settings
|
||||
|
||||
|
||||
**Authentication:** Required
|
||||
|
||||
|
||||
**Request Body:**
|
||||
- `scan_frequency_minutes` (integer, required): Minutes between automatic scans (15-1440)
|
||||
- `auto_scan_enabled` (boolean, required): Whether automatic scanning is enabled
|
||||
|
||||
|
||||
**Response:**
|
||||
- `message` (string): Success message
|
||||
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 400: Invalid settings
|
||||
- 401: Unauthorized
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user