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
This commit is contained in:
@@ -1,25 +1,114 @@
|
||||
meta {
|
||||
name: Add Library Folder,
|
||||
type: http,
|
||||
name: Add Library Folder
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: "/api/libraries/{{ _.libraryId }}/folders"
|
||||
headers: {
|
||||
Authorization: "Bearer {{ _.token }}",
|
||||
Content-Type: "application/json"
|
||||
}
|
||||
body: {
|
||||
folder_path: "/path/to/library/media"
|
||||
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_folder_success: {
|
||||
status: 201,
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
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
|
||||
}
|
||||
@@ -1,27 +1,119 @@
|
||||
meta {
|
||||
name: Create Library,
|
||||
type: http,
|
||||
name: Create Library
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: "/api/libraries"
|
||||
headers: {
|
||||
Authorization: "Bearer {{ _.token }}",
|
||||
Content-Type: "application/json"
|
||||
}
|
||||
body: {
|
||||
name: "My Ebook Library",
|
||||
description: "A collection of technical books and novels",
|
||||
type: "ebooks"
|
||||
url: {{base_url}}/api/libraries
|
||||
auth: inherit
|
||||
body: json
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"name": "My Ebook Library",
|
||||
"description": "A collection of technical books and novels",
|
||||
"type": "ebooks"
|
||||
}
|
||||
}
|
||||
|
||||
tests: {
|
||||
test_create_library_success: {
|
||||
status: 201,
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
tests {
|
||||
test_create_library_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 library response
|
||||
if (!data.id) {
|
||||
throw new Error("Library response missing required field: id");
|
||||
}
|
||||
|
||||
if (!data.name) {
|
||||
throw new Error("Library response missing required field: name");
|
||||
}
|
||||
|
||||
if (!data.type) {
|
||||
throw new Error("Library response missing required field: type");
|
||||
}
|
||||
|
||||
// Validate data types
|
||||
if (typeof data.id !== "string") {
|
||||
throw new Error("Library id must be a string");
|
||||
}
|
||||
|
||||
if (typeof data.name !== "string") {
|
||||
throw new Error("Library name must be a string");
|
||||
}
|
||||
|
||||
if (!["ebooks", "audiobooks", "videos", "other"].includes(data.type)) {
|
||||
throw new Error("Invalid library type: " + data.type);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Create Library
|
||||
|
||||
Creates a new library for organizing media items.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/libraries
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Request Body:**
|
||||
- `name` (string, required): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string, required): Library type
|
||||
- `"ebooks"`: Electronic books
|
||||
- `"audiobooks"`: Audio books
|
||||
- `"videos"`: Video content
|
||||
- `"other"`: Other media types
|
||||
|
||||
**Response:** Library object
|
||||
- `id` (string): Library UUID
|
||||
- `name` (string): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string): Library type
|
||||
- `is_visible` (boolean): Library visibility status
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Library created successfully
|
||||
- 400: Invalid request data
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (insufficient permissions)
|
||||
- 409: Library name already exists
|
||||
- 500: Internal server error
|
||||
}
|
||||
@@ -1,22 +1,94 @@
|
||||
meta {
|
||||
name: Get Libraries (Admin),
|
||||
type: http,
|
||||
name: Get Libraries (Admin)
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: "/api/libraries"
|
||||
headers: {
|
||||
Authorization: "Bearer {{ _.token }}",
|
||||
Content-Type: "application/json"
|
||||
url: {{base_url}}/api/libraries
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_get_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
|
||||
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.type) {
|
||||
throw new Error("Library at index " + index + " missing required field: type");
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
tests: {
|
||||
test_get_libraries_success: {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
}
|
||||
}
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get Libraries (Admin)
|
||||
|
||||
Retrieves all libraries in the system (admin access required).
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/libraries
|
||||
|
||||
**Authentication:** Required (Bearer token, admin permissions)
|
||||
|
||||
**Response:** Array of library objects
|
||||
- `id` (string): Library UUID
|
||||
- `name` (string): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string): Library type (ebooks, audiobooks, videos, other)
|
||||
- `is_visible` (boolean): Library visibility to users
|
||||
- `media_count` (number): Number of media items in library
|
||||
- `folder_count` (number): Number of folders associated
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (admin access required)
|
||||
- 500: Internal server error
|
||||
}
|
||||
@@ -1,22 +1,100 @@
|
||||
meta {
|
||||
name: Get Library Folders,
|
||||
type: http,
|
||||
name: Get Library Folders
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: "/api/libraries/{{ _.libraryId }}/folders"
|
||||
headers: {
|
||||
Authorization: "Bearer {{ _.token }}",
|
||||
Content-Type: "application/json"
|
||||
url: {{base_url}}/api/libraries/{{libraryId}}/folders
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
tests: {
|
||||
test_get_folders_success: {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
}
|
||||
}
|
||||
vars:pre-request {
|
||||
libraryId: "8821b703-h29b-71d4-d716-446655440003"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get Library Folders
|
||||
|
||||
Retrieves all folders associated with a specific library.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/libraries/{id}/folders
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Path Parameters:**
|
||||
- `id` (string, required): Library UUID
|
||||
|
||||
**Response:** Array of folder objects
|
||||
- `id` (string): Folder UUID
|
||||
- `library_id` (string): Library UUID
|
||||
- `folder_path` (string): Absolute path to the folder
|
||||
- `is_active` (boolean): Whether the folder is currently active for scanning
|
||||
- `last_scanned` (string, optional): Timestamp of last scan
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (library access denied)
|
||||
- 404: Library not found
|
||||
- 500: Internal server error
|
||||
}
|
||||
@@ -5,18 +5,79 @@ meta {
|
||||
}
|
||||
|
||||
get {
|
||||
url: "/api/libraries/types"
|
||||
headers: {
|
||||
Authorization: "Bearer {{ _.token }}",
|
||||
Content-Type: "application/json"
|
||||
url: {{base_url}}/api/libraries/types
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
tests: {
|
||||
test_library_types_success: {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
}
|
||||
}
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get Library Types
|
||||
|
||||
Retrieves all available library types that can be used when creating libraries.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/libraries/types
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Response:** Array of library type objects
|
||||
- `id` (string): Type identifier (e.g., "ebooks", "audiobooks", "videos", "other")
|
||||
- `name` (string): Display name for the type (e.g., "Ebooks", "Audiobooks", "Videos", "Other")
|
||||
- `description` (string, optional): Description of what this type is used for
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
}
|
||||
@@ -6,10 +6,49 @@ meta {
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/library/scan-settings
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
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
|
||||
@@ -18,19 +57,24 @@ settings {
|
||||
docs {
|
||||
## Get Scan Settings
|
||||
|
||||
Retrieves the user's current ebook scanning settings.
|
||||
Retrieves the user's current library scanning settings.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/library/scan-settings
|
||||
|
||||
**Authentication:** Required
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Response:**
|
||||
- `scan_frequency_minutes` (integer): Minutes between automatic scans
|
||||
- `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
|
||||
}
|
||||
@@ -1,22 +1,91 @@
|
||||
meta {
|
||||
name: Get User Visible Libraries,
|
||||
type: http,
|
||||
name: Get User Visible Libraries
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: "/api/libraries/visible"
|
||||
headers: {
|
||||
Authorization: "Bearer {{ _.token }}",
|
||||
Content-Type: "application/json"
|
||||
url: {{base_url}}/api/libraries/visible
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
tests: {
|
||||
test_get_visible_libraries_success: {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
}
|
||||
}
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get User Visible Libraries
|
||||
|
||||
Retrieves all libraries that are visible to regular users.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/libraries/visible
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Response:** Array of visible library objects
|
||||
- `id` (string): Library UUID
|
||||
- `name` (string): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string): Library type (ebooks, audiobooks, videos, other)
|
||||
- `is_visible` (boolean): Always true for this endpoint
|
||||
- `media_count` (number): Number of media items in library
|
||||
- `created_at` (string): Creation timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
}
|
||||
@@ -1,26 +1,99 @@
|
||||
meta {
|
||||
name: Set Library Visibility,
|
||||
type: http,
|
||||
name: Set Library Visibility
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: "/api/libraries/visibility"
|
||||
headers: {
|
||||
Authorization: "Bearer {{ _.token }}",
|
||||
Content-Type: "application/json"
|
||||
}
|
||||
body: {
|
||||
library_id: "{{ _.libraryId }}",
|
||||
is_visible: {{ _.isVisible }}
|
||||
url: {{base_url}}/api/libraries/visibility
|
||||
auth: inherit
|
||||
body: json
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"library_id": "{{libraryId}}",
|
||||
"is_visible": {{isVisible}}
|
||||
}
|
||||
}
|
||||
|
||||
tests: {
|
||||
test_set_visibility_success: {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/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
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Set Library Visibility
|
||||
|
||||
Updates the visibility status of a library for regular users.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/libraries/visibility
|
||||
|
||||
**Authentication:** Required (Bearer token, admin permissions)
|
||||
|
||||
**Request Body:**
|
||||
- `library_id` (string, required): Library UUID
|
||||
- `is_visible` (boolean, required): Visibility status
|
||||
- `true`: Library visible to all users
|
||||
- `false`: Library hidden from regular users
|
||||
|
||||
**Response:** Updated library visibility object
|
||||
- `library_id` (string): Library UUID
|
||||
- `is_visible` (boolean): Updated visibility status
|
||||
- `updated_at` (string): Update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Visibility updated successfully
|
||||
- 400: Invalid request data
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (admin access required)
|
||||
- 404: Library not found
|
||||
- 500: Internal server error
|
||||
}
|
||||
@@ -4,6 +4,92 @@ meta {
|
||||
seq: 1
|
||||
}
|
||||
|
||||
put {
|
||||
url: {{base_url}}/api/library/scan-settings
|
||||
auth: inherit
|
||||
body: json
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"scan_frequency_minutes": 60,
|
||||
"auto_scan_enabled": true
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user