swagger: "2.0"
info: { version: "", title: "" }

paths:
  /settings:
    get:
      tags: [ "settings" ]
      summary: "Get settings"
      operationId: "getSettings"
      responses:
        "200":
          description: "successful operation"
          schema: { $ref: "#/definitions/SettingsResponse" }
          examples:
            test:
              version: "0.0.0-test"
              tier: community
              timeformat: "yyyy-MM-dd hh:mm:ss"
              ticketTypes:
                - { icon: "mdi-alert", id: "alert", name: "Alerts", default_template: "default", default_playbooks: [ ] }
                - { icon: "mdi-radioactive", id: "incident", name: "Incidents", default_template: "default", default_playbooks: [ ] }
                - { icon: "mdi-fingerprint", id: "investigation", name: "Forensic Investigations", default_template: "default", default_playbooks: [ ] }
                - { icon: "mdi-target", id: "hunt", name: "Threat Hunting", default_template: "default", default_playbooks: [ ] }
              artifactKinds:
                - { icon: "mdi-server", id: "asset", name: "Asset" }
                - { icon: "mdi-bullseye", id: "ioc", name: "IOC" }
              artifactStates:
                - { icon: "mdi-help-circle-outline", id: "unknown", name: "Unknown", color: "info" }
                - { icon: "mdi-skull", id: "malicious", name: "Malicious", color: "error" }
                - { icon: "mdi-check", id: "clean", name: "Clean", color: "success" }
      security: [ { roles: [ "settings:read" ] } ]
    post:
      tags: [ "settings" ]
      summary: "Save settings"
      operationId: "saveSettings"
      parameters:
        - { name: "settings", in: "body", description: "Save settings", required: true, schema: { $ref: "#/definitions/Settings" }, x-example: { timeformat: "yyyy-MM-dd hh:mm:ss", artifactKinds: [ { icon: "mdi-server", id: "asset", name: "Asset" }, { icon: "mdi-bullseye", id: "ioc", name: "IOC" } ], artifactStates: [ { icon: "mdi-help-circle-outline", id: "unknown", name: "Unknown", color: "info" },{ icon: "mdi-skull", id: "malicious", name: "Malicious", color: "error" },{ icon: "mdi-check", id: "clean", name: "Clean", color: "success" } ] } }
      responses:
        "200":
          description: "successful operation"
          schema: { $ref: "#/definitions/SettingsResponse" }
          examples:
            test:
              version: "0.0.0-test"
              tier: community
              timeformat: "yyyy-MM-dd hh:mm:ss"
              ticketTypes:
                - { icon: "mdi-alert", id: "alert", name: "Alerts", default_template: "default", default_playbooks: [ ] }
                - { icon: "mdi-radioactive", id: "incident", name: "Incidents", default_template: "default", default_playbooks: [ ] }
                - { icon: "mdi-fingerprint", id: "investigation", name: "Forensic Investigations", default_template: "default", default_playbooks: [ ] }
                - { icon: "mdi-target", id: "hunt", name: "Threat Hunting", default_template: "default", default_playbooks: [ ] }
              artifactKinds:
                - { icon: "mdi-server", id: "asset", name: "Asset" }
                - { icon: "mdi-bullseye", id: "ioc", name: "IOC" }
              artifactStates:
                - { icon: "mdi-help-circle-outline", id: "unknown", name: "Unknown", color: "info" }
                - { icon: "mdi-skull", id: "malicious", name: "Malicious", color: "error" }
                - { icon: "mdi-check", id: "clean", name: "Clean", color: "success" }
      security: [ { roles: [ "settings:write" ] } ]

definitions:
  Settings:
    type: object
    required: [ timeformat, artifactKinds, artifactStates ]
    properties:
      timeformat: { title: "Time Format", type: string }
      artifactKinds: { title: "Artifact Kinds", type: array, items: { $ref: "#/definitions/Type" } }
      artifactStates: { title: "Artifact States", type: array, items: { $ref: "#/definitions/Type" } }

  SettingsResponse:
    type: object
    required: [ version, tier, timeformat, ticketTypes, artifactKinds, artifactStates ]
    properties:
      version: { title: "Version", type: string }
      tier: { title: "Tier", type: string, enum: [ "community", "enterprise" ] }
      timeformat: { title: "Time Format", type: string }
      ticketTypes: { title: "Ticket Types", type: array, items: { $ref: "#/definitions/TicketTypeResponse" } }
      artifactKinds: { title: "Artifact Kinds", type: array, items: { $ref: "#/definitions/Type" } }
      artifactStates: { title: "Artifact States", type: array, items: { $ref: "#/definitions/Type" } }
      roles: { title: "Roles", type: array, items: { type: string } }

  Type:
    type: object
    required: [ id, name, icon ]
    properties:
      id: { title: ID, type: string, x-cols: 3, x-class: pr-2 }
      name: { title: Name, type: string, x-cols: 3, x-class: pr-2 }
      icon: { title: "Icon (https://materialdesignicons.com)", type: string, x-cols: 3, x-class: pr-2 }
      color: { title: Color, type: string, x-cols: 3, enum: [ error, info, success, warning ] }
