Files
bookhoard/bruno/devices/Create Device File Alias.bru
T

98 lines
2.1 KiB
Plaintext

meta {
name: Create Device File Alias
type: http
seq: 1
}
post {
url: {{base_url}}/api/devices/{{device_id}}/file-aliases
body: json
auth: inherit
}
body:json {
{
"file_path": "/mnt/sd/books/my-book.kepub.epub",
"media_item_id": "{{media_item_id}}"
}
}
headers {
Content-Type: application/json
}
tests {
test_create_device_file_alias_success(status, headers, body) {
if (status !== 201 && status !== 200) {
throw new Error("Expected status 201 or 200, got " + status);
}
const contentType = headers["content-type"];
if (!contentType || !contentType.includes("application/json")) {
throw new Error("Expected content-type to contain application/json");
}
let data;
try {
data = JSON.parse(body);
} catch (e) {
throw new Error("Response body is not valid JSON");
}
if (!data.id) {
throw new Error("Response missing id field");
}
if (!data.file_path) {
throw new Error("Response missing file_path field");
}
return true;
}
}
vars:pre-request {
deviceId: "8821b703-1234-5678-9123-446655440002"
mediaItemId: "8821b703-1234-5678-9123-446655440001"
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## Create Device File Alias
Creates a new file alias for a device. File aliases map device-specific file paths to media items.
**Method:** POST
**Endpoint:** /api/devices/:id/file-aliases
**Authentication:** Required (Bearer token)
**Path Parameters:**
- `id` (string, required): Device UUID
**Request Body:**
- `file_path` (string, required): Device-specific file path
- `media_item_id` (string, required): Media item UUID to link to
**Response:** Created file alias object
- `id` (string): Alias UUID
- `device_id` (string): Device UUID
- `file_path` (string): Device-specific file path
- `media_item_id` (string): Associated media item UUID
- `created_at` (string): Creation timestamp
- `updated_at` (string): Last update timestamp
**Status Codes:**
- 201: Created
- 200: Success
- 400: Invalid request body
- 401: Unauthorized
- 404: Device not found
- 500: Internal server error
}