openapi: 3.1.0
info:
  title: StrafesNET Internal - OpenAPI 3.1
  description: Internal operations inaccessible from the public internet.
  version: 0.1.0
tags:
  - name: Submissions
    description: Submission operations
paths:
  /submissions/{SubmissionID}/model:
    post:
      summary: Update model following role restrictions
      operationId: updateSubmissionModel
      tags:
        - Submissions
      parameters:
        - $ref: '#/components/parameters/SubmissionID'
        - name: ModelID
          in: query
          required: true
          schema:
            type: integer
            format: int64
        - name: VersionID
          in: query
          required: true
          schema:
            type: integer
            format: int64
      responses:
        "204":
          description: Successful response
        default:
          description: General Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /submissions/{SubmissionID}/status/validator-validated:
    post:
      summary: (Internal endpoint) Role Validator changes status from Validating -> Validated
      operationId: actionSubmissionValidated
      tags:
        - Submissions
      parameters:
        - $ref: '#/components/parameters/SubmissionID'
      responses:
        "204":
          description: Successful response
        default:
          description: General Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /submissions/{SubmissionID}/status/validator-failed:
    post:
      summary: (Internal endpoint) Role Validator changes status from Validating -> Accepted
      operationId: actionSubmissionAccepted
      tags:
        - Submissions
      parameters:
        - $ref: '#/components/parameters/SubmissionID'
      responses:
        "204":
          description: Successful response
        default:
          description: General Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /submissions/{SubmissionID}/status/validator-uploaded:
    post:
      summary: (Internal endpoint) Role Validator changes status from Uploading -> Uploaded
      operationId: actionSubmissionUploaded
      tags:
        - Submissions
      parameters:
        - $ref: '#/components/parameters/SubmissionID'
        - name: TargetAssetID
          in: query
          schema:
            type: integer
            format: int64
      responses:
        "204":
          description: Successful response
        default:
          description: General Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /submissions/{SubmissionID}/status/releaser-released:
    post:
      summary: (Internal endpoint) Role Releaser changes status from releasing -> released
      operationId: actionSubmissionReleased
      tags:
        - Submissions
      parameters:
        - $ref: '#/components/parameters/SubmissionID'
      responses:
        "204":
          description: Successful response
        default:
          description: General Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /script-policy:
    get:
      summary: Get list of script policies
      operationId: listScriptPolicy
      tags:
        - ScriptPolicy
      parameters:
      - $ref: "#/components/parameters/Page"
      - $ref: "#/components/parameters/Limit"
      - name: FromScriptHash
        in: query
        schema:
          type: string
          minLength: 16
          maxLength: 16
      - name: ToScriptID
        in: query
        schema:
          type: integer
          format: int64
      - name: Policy
        in: query
        schema:
          type: integer
          format: int32
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/ScriptPolicy"
        default:
          description: General Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    post:
      summary: Create a new script policy
      operationId: createScriptPolicy
      tags:
        - ScriptPolicy
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScriptPolicyCreate'
      responses:
        "201":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Id"
        default:
          description: General Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /scripts:
    get:
      summary: Get list of scripts
      operationId: listScripts
      tags:
        - Script
      parameters:
      - $ref: "#/components/parameters/Page"
      - $ref: "#/components/parameters/Limit"
      - name: Hash
        in: query
        schema:
          type: string
          minLength: 16
          maxLength: 16
      - name: Name
        in: query
        schema:
          type: string
          maxLength: 128
      - name: Source
        in: query
        schema:
          type: string
          maxLength: 1048576
      - name: SubmissionID
        in: query
        schema:
          type: integer
          format: int64
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Script"
        default:
          description: General Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    post:
      summary: Create a new script
      operationId: createScript
      tags:
        - Scripts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScriptCreate'
      responses:
        "201":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Id"
        default:
          description: General Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /scripts/{ScriptID}:
    get:
      summary: Get the specified script by ID
      operationId: getScript
      tags:
        - Scripts
      parameters:
        - $ref: '#/components/parameters/ScriptID'
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Script"
        default:
          description: General Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
components:
  parameters:
    SubmissionID:
      name: SubmissionID
      in: path
      required: true
      description: The unique identifier for a submission.
      schema:
        type: integer
        format: int64
    ScriptID:
      name: ScriptID
      in: path
      required: true
      description: The unique identifier for a script.
      schema:
        type: integer
        format: int64
    Page:
      name: Page
      in: query
      required: true
      schema:
        type: integer
        format: int32
        minimum: 1
    Limit:
      name: Limit
      in: query
      required: true
      schema:
        type: integer
        format: int32
        minimum: 1
        maximum: 100
  schemas:
    Id:
      required:
      - ID
      type: object
      properties:
        ID:
          type: integer
          format: int64
    Script:
      required:
      - ID
      - Name
      - Hash
      - Source
      - SubmissionID
      type: object
      properties:
        ID:
          type: integer
          format: int64
        Name:
          type: string
          maxLength: 128
        Hash:
          type: string
          minLength: 16
          maxLength: 16
        Source:
          type: string
          maxLength: 1048576
        SubmissionID:
          type: integer
          format: int64
    ScriptCreate:
      required:
      - Name
      - Source
#     - SubmissionID
      type: object
      properties:
        Name:
          type: string
          maxLength: 128
        Source:
          type: string
          maxLength: 1048576
        SubmissionID:
          type: integer
          format: int64
    ScriptPolicy:
      required:
      - ID
      - FromScriptHash
      - ToScriptID
      - Policy
      type: object
      properties:
        ID:
          type: integer
          format: int64
        FromScriptHash:
          type: string
          minLength: 16
          maxLength: 16
        ToScriptID:
          type: integer
          format: int64
        Policy:
          type: integer
          format: int32
    ScriptPolicyCreate:
      required:
      - FromScriptID
      - ToScriptID
      - Policy
      type: object
      properties:
        FromScriptID:
          type: integer
          format: int64
        ToScriptID:
          type: integer
          format: int64
        Policy:
          type: integer
          format: int32
    Error:
      description: Represents error object
      type: object
      properties:
        code:
          type: integer
          format: int64
        message:
          type: string
      required:
        - code
        - message