openapi: 3.0.3
info:
  title: Repzo API - Media Storage
  version: 1.0.0
  description: OpenAPI specification for Repzo Media Storage endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /media-storage:
    get:
      summary: Find media storage items
      operationId: findMediaStorage
      parameters:
        - in: query
          name: params
          schema:
            type: object
            properties:
              _id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              search:
                type: string
              filename:
                type: string
              mimeType:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              category:
                type: string
              entityType:
                type: string
              entityId:
                type: string
              from_updatedAt:
                type: number
              from__id:
                type: string
              to__id:
                type: string
              sortBy:
                type: array
                items:
                  type: object
                  properties:
                    field:
                      type: string
                      enum: [_id, createdAt, updatedAt, filename, size]
                    type:
                      type: string
                      enum: [asc, desc]
          description: Query parameters for filtering media storage items
      responses:
        "200":
          description: A list of media storage items
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MediaStorageFindResult"
    post:
      summary: Create a media storage item
      operationId: createMediaStorage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MediaStorageCreateBody"
      responses:
        "201":
          description: Media storage item created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MediaStorageCreateResult"
  /media-storage/{id}:
    get:
      summary: Get a media storage item by ID
      operationId: getMediaStorage
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Media storage item details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MediaStorageGetResult"
    put:
      summary: Update a media storage item
      operationId: updateMediaStorage
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MediaStorageUpdateBody"
      responses:
        "200":
          description: Media storage item updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MediaStorageUpdateResult"
    delete:
      summary: Remove a media storage item
      operationId: removeMediaStorage
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Media storage item removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MediaStorageRemoveResult"
components:
  schemas:
    MediaStorageFindResult:
      type: object
      description: Result of finding media storage items
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/MediaStorageSchema"
        total_result:
          type: number
          description: Total number of media storage items
        current_count:
          type: number
          description: Count of media storage items in current page
        total_pages:
          type: number
          description: Total number of pages
        current_page:
          type: number
          description: Current page number
        per_page:
          type: number
          description: Number of media storage items per page
    MediaStorageSchema:
      type: object
      description: Media storage schema
      properties:
        _id:
          type: string
          description: Unique identifier for the media storage item
        filename:
          type: string
          description: Original filename
        url:
          type: string
          description: URL to access the media file
        mimeType:
          type: string
          description: MIME type of the file
        size:
          type: number
          description: File size in bytes
        category:
          type: string
          description: Media category
        entityType:
          type: string
          description: Type of entity this media is associated with
        entityId:
          type: string
          description: ID of the entity this media is associated with
        uploadedBy:
          type: string
          description: ID of user who uploaded the media
        isPublic:
          type: boolean
          description: Whether the media is publicly accessible
        thumbnailUrl:
          type: string
          description: URL to thumbnail version (for images)
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata about the file
        tags:
          type: array
          items:
            type: string
          description: Tags associated with the media
        description:
          type: string
          description: Description of the media
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
        __v:
          type: number
          description: Version number
    MediaStorageCreateBody:
      type: object
      description: Body for creating a media storage item
      required:
        - filename
        - url
        - mimeType
        - size
      properties:
        filename:
          type: string
          description: Original filename
        url:
          type: string
          description: URL to access the media file
        mimeType:
          type: string
          description: MIME type of the file
        size:
          type: number
          description: File size in bytes
        category:
          type: string
          description: Media category
        entityType:
          type: string
          description: Type of entity this media is associated with
        entityId:
          type: string
          description: ID of the entity this media is associated with
        isPublic:
          type: boolean
          description: Whether the media is publicly accessible
        thumbnailUrl:
          type: string
          description: URL to thumbnail version (for images)
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata about the file
        tags:
          type: array
          items:
            type: string
          description: Tags associated with the media
        description:
          type: string
          description: Description of the media
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    MediaStorageCreateResult:
      $ref: "#/components/schemas/MediaStorageSchema"
      description: Result of creating a media storage item
    MediaStorageGetResult:
      $ref: "#/components/schemas/MediaStorageSchema"
      description: Result of getting a media storage item
    MediaStorageUpdateBody:
      type: object
      description: Body for updating a media storage item
      properties:
        filename:
          type: string
          description: Original filename
        category:
          type: string
          description: Media category
        entityType:
          type: string
          description: Type of entity this media is associated with
        entityId:
          type: string
          description: ID of the entity this media is associated with
        isPublic:
          type: boolean
          description: Whether the media is publicly accessible
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata about the file
        tags:
          type: array
          items:
            type: string
          description: Tags associated with the media
        description:
          type: string
          description: Description of the media
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    MediaStorageUpdateResult:
      $ref: "#/components/schemas/MediaStorageSchema"
      description: Result of updating a media storage item
    MediaStorageRemoveResult:
      $ref: "#/components/schemas/MediaStorageSchema"
      description: Result of removing a media storage item
