openapi: 3.1.0
info:
  title: OakWall Panel API
  description: Panel API for dedicated GRE tunnel purchases and management.
  version: 1.0.0
servers:
  - url: https://panel.oakwall.mom/api
    description: Production
tags:
  - name: Dedicated
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: JWT session token or oak_* API key (admin-issued)
  schemas:
    DedicatedPricing:
      type: object
      properties:
        price:
          type: integer
          example: 100
        currency:
          type: string
          example: RUB
        price_usd:
          type: number
          example: 1.0
        usd_rub_rate:
          type: number
        availability:
          type: object
          properties:
            available:
              type: integer
            in_stock:
              type: boolean
    DedicatedTunnel:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        origin_ip:
          type: string
        protected_ip:
          type: string
        ports:
          type: string
          example: "*"
        protocol:
          type: string
          example: both
        tunnel_name:
          type: string
        status:
          type: string
          enum: [pending, active, error, disabled]
        admin_ssh_port:
          type: integer
          example: 52222
    PurchaseRequest:
      type: object
      required: [name, origin_ip]
      properties:
        name:
          type: string
        origin_ip:
          type: string
          description: Hidden server IP behind GRE
        promocode:
          type: string
    Error:
      type: object
      properties:
        error:
          type: string
paths:
  /dedicated/pricing:
    get:
      tags: [Dedicated]
      summary: Pricing and IP availability
      operationId: dedicatedPricing
      responses:
        "200":
          description: Pricing
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DedicatedPricing"
  /dedicated:
    get:
      tags: [Dedicated]
      summary: List dedicated tunnels
      operationId: listDedicatedTunnels
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Tunnel list
    post:
      tags: [Dedicated]
      summary: Purchase dedicated tunnel
      operationId: purchaseDedicatedTunnel
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PurchaseRequest"
      responses:
        "201":
          description: Purchased
        "400":
          description: Validation or insufficient balance
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /dedicated/{id}/setup:
    get:
      tags: [Dedicated]
      summary: GRE setup scripts for origin
      operationId: dedicatedSetup
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Setup scripts
  /dedicated/{id}/provision:
    post:
      tags: [Dedicated]
      summary: Provision OakWall dedicated proxy
      operationId: dedicatedProvision
      security:
        - bearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Provision result
