modified: app.py
modified: openapi.yaml modified: requirements.txt modified: test_agent.sh
This commit is contained in:
parent
5af4d5a7e4
commit
638d19fd77
4 changed files with 242 additions and 252 deletions
420
openapi.yaml
420
openapi.yaml
|
|
@ -1,25 +1,25 @@
|
|||
openapi: 3.0.3
|
||||
info:
|
||||
title: PyraFiles API
|
||||
title: PyraLogs API
|
||||
version: 1.0.0
|
||||
description: |
|
||||
API specification for the PyraFiles application.
|
||||
PyraFiles allows users to register, authenticate, upload media files,
|
||||
and manage their media content.
|
||||
API specification for the PyraLogs application.
|
||||
PyraLogs allows users to register, authenticate, manage namespaces,
|
||||
generate JWT tokens for agents, and submit logs via a webhook.
|
||||
servers:
|
||||
- url: http://localhost:{port}
|
||||
- url: http://127.0.0.1:{port}
|
||||
description: Local development server
|
||||
variables:
|
||||
port:
|
||||
default: '6544'
|
||||
- url: https://upload.unturf.com
|
||||
description: prod for humans & agents to mingle.
|
||||
- url: https://logs.unturf.com
|
||||
description: Production server
|
||||
|
||||
paths:
|
||||
/:
|
||||
get:
|
||||
summary: Home Page
|
||||
description: Displays the home page.
|
||||
description: Displays the home page with public namespaces and user namespaces.
|
||||
responses:
|
||||
'200':
|
||||
description: Successful response
|
||||
|
|
@ -106,7 +106,7 @@ paths:
|
|||
/auth/profile:
|
||||
get:
|
||||
summary: Display User Profile
|
||||
description: Shows the user's profile, including upload stats.
|
||||
description: Shows the user's profile, including owned namespaces.
|
||||
security:
|
||||
- sessionAuth: []
|
||||
responses:
|
||||
|
|
@ -143,212 +143,64 @@ paths:
|
|||
'403':
|
||||
description: Unauthorized (user not logged in or guest mode)
|
||||
|
||||
/auth/download_db:
|
||||
/namespace/create:
|
||||
get:
|
||||
summary: Download User Database
|
||||
description: Allows the user to download their personal database file.
|
||||
summary: Display Namespace Creation Page
|
||||
description: Renders the form to create a new namespace.
|
||||
security:
|
||||
- sessionAuth: []
|
||||
responses:
|
||||
'200':
|
||||
description: Database file downloaded
|
||||
content:
|
||||
application/octet-stream:
|
||||
schema:
|
||||
type: string
|
||||
format: binary
|
||||
'403':
|
||||
description: Unauthorized (user not logged in or unverified)
|
||||
'404':
|
||||
description: Database file not found
|
||||
|
||||
/auth/export_user_record:
|
||||
get:
|
||||
summary: Export User Record
|
||||
description: Exports the user's record as a JSON file.
|
||||
security:
|
||||
- sessionAuth: []
|
||||
responses:
|
||||
'200':
|
||||
description: User record JSON file downloaded
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
'403':
|
||||
description: Unauthorized (user not logged in or unverified)
|
||||
|
||||
/admin/import_user_record:
|
||||
get:
|
||||
summary: Display Import User Record Page
|
||||
description: Renders a page to import a user record (Admin only).
|
||||
security:
|
||||
- sessionAuth: []
|
||||
responses:
|
||||
'200':
|
||||
description: Import user record page rendered
|
||||
description: Namespace creation page rendered
|
||||
content:
|
||||
text/html:
|
||||
schema:
|
||||
type: string
|
||||
'403':
|
||||
description: Forbidden (user not admin)
|
||||
description: Unauthorized (user not logged in)
|
||||
post:
|
||||
summary: Import User Record
|
||||
description: Processes uploaded user record file and imports the user (Admin only).
|
||||
summary: Create Namespace
|
||||
description: Processes the namespace creation form.
|
||||
security:
|
||||
- sessionAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
multipart/form-data:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
user_record_file:
|
||||
type: string
|
||||
format: binary
|
||||
required:
|
||||
- user_record_file
|
||||
responses:
|
||||
'302':
|
||||
description: Redirects to the home page after successful import
|
||||
'400':
|
||||
description: Bad Request (e.g., invalid file)
|
||||
'403':
|
||||
description: Forbidden (user not admin)
|
||||
|
||||
/media/upload:
|
||||
get:
|
||||
summary: Display Media Upload Page
|
||||
description: Renders the media upload form.
|
||||
security:
|
||||
- sessionAuth: []
|
||||
responses:
|
||||
'200':
|
||||
description: Upload media page rendered
|
||||
content:
|
||||
text/html:
|
||||
schema:
|
||||
type: string
|
||||
'403':
|
||||
description: Unauthorized (user not logged in or unverified)
|
||||
post:
|
||||
summary: Upload Media
|
||||
description: Processes the uploaded media file.
|
||||
security:
|
||||
- sessionAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
media_file:
|
||||
type: string
|
||||
format: binary
|
||||
title:
|
||||
name:
|
||||
type: string
|
||||
is_public:
|
||||
type: string
|
||||
enum: ['on']
|
||||
required:
|
||||
- media_file
|
||||
- name
|
||||
responses:
|
||||
'302':
|
||||
description: Redirects to the media details page
|
||||
description: Redirects to the namespace management page
|
||||
'400':
|
||||
description: Bad Request (e.g., no file uploaded, unsupported media type)
|
||||
description: Bad Request (e.g., namespace name already exists)
|
||||
'403':
|
||||
description: Unauthorized (user not logged in or unverified)
|
||||
description: Unauthorized (user not logged in)
|
||||
|
||||
/media/list:
|
||||
/namespace/{namespace_short_id}/manage:
|
||||
get:
|
||||
summary: List Public Media
|
||||
description: Displays a list of public media from all users.
|
||||
responses:
|
||||
'200':
|
||||
description: Media list page rendered
|
||||
content:
|
||||
text/html:
|
||||
schema:
|
||||
type: string
|
||||
|
||||
/media/user/{user_short_id}:
|
||||
get:
|
||||
summary: Display User's Media
|
||||
description: Shows all media uploaded by a specific user.
|
||||
parameters:
|
||||
- in: path
|
||||
name: user_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the user
|
||||
responses:
|
||||
'200':
|
||||
description: User's media page rendered
|
||||
content:
|
||||
text/html:
|
||||
schema:
|
||||
type: string
|
||||
'404':
|
||||
description: User not found
|
||||
'500':
|
||||
description: Internal Server Error
|
||||
|
||||
/media/{user_short_id}/{media_short_id}/details:
|
||||
get:
|
||||
summary: Display Media Details
|
||||
description: Shows details of a specific media item.
|
||||
parameters:
|
||||
- in: path
|
||||
name: user_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the user
|
||||
- in: path
|
||||
name: media_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the media item
|
||||
responses:
|
||||
'200':
|
||||
description: Media details page rendered
|
||||
content:
|
||||
text/html:
|
||||
schema:
|
||||
type: string
|
||||
'404':
|
||||
description: Media or user not found
|
||||
'403':
|
||||
description: Forbidden (media not public and not owner)
|
||||
|
||||
/media/{user_short_id}/{media_short_id}/edit:
|
||||
get:
|
||||
summary: Display Media Edit Page
|
||||
description: Renders a form to edit media details (owner only).
|
||||
summary: Manage Namespace
|
||||
description: Displays the namespace management page (owners only).
|
||||
security:
|
||||
- sessionAuth: []
|
||||
parameters:
|
||||
- in: path
|
||||
name: user_short_id
|
||||
name: namespace_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the user
|
||||
- in: path
|
||||
name: media_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the media item
|
||||
description: The short ID of the namespace
|
||||
responses:
|
||||
'200':
|
||||
description: Media edit page rendered
|
||||
description: Namespace management page rendered
|
||||
content:
|
||||
text/html:
|
||||
schema:
|
||||
|
|
@ -356,112 +208,205 @@ paths:
|
|||
'403':
|
||||
description: Forbidden (not owner or not logged in)
|
||||
'404':
|
||||
description: Media not found
|
||||
description: Namespace not found
|
||||
|
||||
/namespace/{namespace_short_id}/update:
|
||||
post:
|
||||
summary: Edit Media
|
||||
description: Updates the media item (owner only).
|
||||
summary: Update Namespace
|
||||
description: Updates namespace properties (owners only).
|
||||
security:
|
||||
- sessionAuth: []
|
||||
parameters:
|
||||
- in: path
|
||||
name: user_short_id
|
||||
name: namespace_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the user
|
||||
- in: path
|
||||
name: media_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the media item
|
||||
description: The short ID of the namespace
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
multipart/form-data:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
title:
|
||||
type: string
|
||||
is_public:
|
||||
type: string
|
||||
enum: ['on']
|
||||
media_file:
|
||||
type: string
|
||||
format: binary
|
||||
responses:
|
||||
'302':
|
||||
description: Redirects to the media details page
|
||||
'400':
|
||||
description: Bad Request (e.g., file too large)
|
||||
description: Redirects to the namespace management page
|
||||
'403':
|
||||
description: Forbidden (not owner)
|
||||
description: Forbidden (not owner or not logged in)
|
||||
'404':
|
||||
description: Media not found
|
||||
description: Namespace not found
|
||||
|
||||
/media/{user_short_id}/{media_short_id}/delete:
|
||||
/namespace/{namespace_short_id}/invite:
|
||||
post:
|
||||
summary: Delete Media
|
||||
description: Deletes the media item (owner only).
|
||||
summary: Invite User to Namespace
|
||||
description: Invites a user to the namespace with a specified role (owners only).
|
||||
security:
|
||||
- sessionAuth: []
|
||||
parameters:
|
||||
- in: path
|
||||
name: user_short_id
|
||||
name: namespace_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the user
|
||||
- in: path
|
||||
name: media_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the media item
|
||||
description: The short ID of the namespace
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
role:
|
||||
type: string
|
||||
enum: ['owner', 'editor', 'reader']
|
||||
required:
|
||||
- email
|
||||
- role
|
||||
responses:
|
||||
'302':
|
||||
description: Redirects to the user's media list
|
||||
description: Redirects to the namespace management page
|
||||
'400':
|
||||
description: Bad Request (e.g., invalid role)
|
||||
'403':
|
||||
description: Forbidden (not owner)
|
||||
description: Forbidden (not owner or not logged in)
|
||||
'404':
|
||||
description: Media not found
|
||||
description: Namespace not found
|
||||
|
||||
/media/{user_short_id}/{media_short_id}:
|
||||
get:
|
||||
summary: View Media
|
||||
description: Retrieves the media file for viewing or download.
|
||||
/namespace/{namespace_short_id}/generate_agent_jwt:
|
||||
post:
|
||||
summary: Generate Agent JWT
|
||||
description: Generates a JWT token for an agent (owners only).
|
||||
security:
|
||||
- sessionAuth: []
|
||||
parameters:
|
||||
- in: path
|
||||
name: user_short_id
|
||||
name: namespace_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the user
|
||||
- in: path
|
||||
name: media_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the media item
|
||||
- in: query
|
||||
name: download
|
||||
schema:
|
||||
type: string
|
||||
enum: ['true', 'false']
|
||||
description: Set to 'true' to trigger download
|
||||
description: The short ID of the namespace
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
agent_name:
|
||||
type: string
|
||||
required:
|
||||
- agent_name
|
||||
responses:
|
||||
'200':
|
||||
description: Media file retrieved
|
||||
description: Agent JWT generated and displayed
|
||||
content:
|
||||
'*/*':
|
||||
text/html:
|
||||
schema:
|
||||
type: string
|
||||
format: binary
|
||||
'400':
|
||||
description: Bad Request (e.g., agent name missing)
|
||||
'403':
|
||||
description: Forbidden (media not public and not owner)
|
||||
description: Forbidden (not owner or not logged in)
|
||||
'404':
|
||||
description: Media not found
|
||||
description: Namespace not found
|
||||
|
||||
/namespace/{namespace_short_id}/revoke_agent:
|
||||
post:
|
||||
summary: Revoke Agent
|
||||
description: Revokes an agent's access by invalidating their JWT (owners only).
|
||||
security:
|
||||
- sessionAuth: []
|
||||
parameters:
|
||||
- in: path
|
||||
name: namespace_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the namespace
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
agent_id:
|
||||
type: string
|
||||
required:
|
||||
- agent_id
|
||||
responses:
|
||||
'302':
|
||||
description: Redirects to the namespace management page
|
||||
'400':
|
||||
description: Bad Request (e.g., agent ID missing)
|
||||
'403':
|
||||
description: Forbidden (not owner or not logged in)
|
||||
'404':
|
||||
description: Namespace or agent not found
|
||||
|
||||
/namespace/{namespace_short_id}/logs:
|
||||
get:
|
||||
summary: View Namespace Logs
|
||||
description: Displays logs for the namespace (readers and above).
|
||||
security:
|
||||
- sessionAuth: []
|
||||
parameters:
|
||||
- in: path
|
||||
name: namespace_short_id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The short ID of the namespace
|
||||
responses:
|
||||
'200':
|
||||
description: Logs page rendered
|
||||
content:
|
||||
text/html:
|
||||
schema:
|
||||
type: string
|
||||
'403':
|
||||
description: Forbidden (user does not have access)
|
||||
'404':
|
||||
description: Namespace not found
|
||||
|
||||
/webhook:
|
||||
post:
|
||||
summary: Submit Log Entry
|
||||
description: Allows agents to submit log entries via JWT authentication.
|
||||
security:
|
||||
- agentAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
level:
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
required:
|
||||
- message
|
||||
responses:
|
||||
'201':
|
||||
description: Log entry created
|
||||
'400':
|
||||
description: Bad Request (e.g., message missing)
|
||||
'401':
|
||||
description: Unauthorized (missing or invalid JWT)
|
||||
'404':
|
||||
description: Namespace or agent not found
|
||||
|
||||
components:
|
||||
securitySchemes:
|
||||
|
|
@ -470,3 +415,8 @@ components:
|
|||
in: cookie
|
||||
name: session
|
||||
description: Session cookie for authenticated users
|
||||
agentAuth:
|
||||
type: http
|
||||
scheme: bearer
|
||||
bearerFormat: JWT
|
||||
description: JWT authentication for agents
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue