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


paths:
  /tickettypes:
    get:
      tags: [ "tickettypes" ]
      summary: "List tickettypes"
      operationId: "listTicketTypes"
      responses:
        "200":
          description: "successful operation"
          schema: { type: array, items: { $ref: "#/definitions/TicketTypeResponse" } }
          examples:
            test:
              - { 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: [ ] }
      security: [ { roles: [ "tickettype:read" ] } ]
    post:
      tags: [ "tickettypes" ]
      summary: "Create a new tickettype"
      operationId: "createTicketType"
      parameters:
        - { name: "tickettype", in: "body", description: "New tickettype", required: true, schema: { $ref: "#/definitions/TicketTypeForm" }, x-example: { name: "TI Tickets", icon: "mdi-newspaper-variant-outline", default_template: "default", default_playbooks: [ ] } }
      responses:
        "200":
          description: "successful operation"
          schema: { $ref: "#/definitions/TicketTypeResponse" }
          examples:
            test:
              id: "ti-tickets"
              name: "TI Tickets"
              icon: "mdi-newspaper-variant-outline"
              default_template: "default"
              default_playbooks: [ ]
      security: [ { roles: [ "tickettype:write" ] } ]

  /tickettypes/{id}:
    get:
      tags: [ "tickettypes" ]
      summary: "Get a single tickettype"
      operationId: "getTicketType"
      parameters:
        - { name: "id", in: "path", description: "TicketType ID", required: true, type: string, x-example: "alert" }
      responses:
        "200":
          description: "successful operation"
          schema: { $ref: "#/definitions/TicketTypeResponse" }
          examples:
            test:
              icon: "mdi-alert"
              id: "alert"
              name: "Alerts"
              default_template: "default"
              default_playbooks: [ ]
      security: [ { roles: [ "tickettype:read" ] } ]
    put:
      tags: [ "tickettypes" ]
      summary: "Update an existing tickettype"
      operationId: "updateTicketType"
      parameters:
        - { name: "id", in: "path", description: "TicketType ID", required: true, type: string, x-example: "alert" }
        - { name: "tickettype", in: "body", description: "TicketType object that needs to be added", required: true, schema: { $ref: "#/definitions/TicketTypeForm" }, x-example: { icon: "mdi-bell", id: "alert", name: "Alerts", default_template: "default", default_playbooks: [ ] } }
      responses:
        "200":
          description: "successful operation"
          schema: { $ref: "#/definitions/TicketTypeResponse" }
          examples:
            test:
              icon: "mdi-bell"
              id: "alert"
              name: "Alerts"
              default_template: "default"
              default_playbooks: [ ]

      security: [ { roles: [ "tickettype:write" ] } ]
    delete:
      tags: [ "tickettypes" ]
      summary: "Delete a tickettype"
      operationId: "deleteTicketType"
      parameters:
        - { name: "id", in: "path", description: "TicketType ID", required: true, type: string, x-example: "alert" }
      responses:
        "204": { description: "successful operation" }
      security: [ { roles: [ "tickettype:write" ] } ]

definitions:
  TicketTypeForm:
    type: object
    required: [ name, icon, default_template, default_playbooks ]
    properties:
      id: { type: string }
      icon: { type: string }
      name: { type: string }
      default_template: { type: string }
      default_playbooks: { type: array, items: { type: string } }
      default_groups: { type: array, items: { type: string } }

  TicketType:
    type: object
    required: [ name, icon, default_template, default_playbooks ]
    properties:
      icon: { type: string }
      name: { type: string }
      default_template: { type: string }
      default_playbooks: { type: array, items: { type: string } }
      default_groups: { type: array, items: { type: string } }

  TicketTypeResponse:
    type: object
    required: [ id, name, icon, default_template, default_playbooks ]
    properties:
      id: { type: string }
      icon: { type: string }
      name: { type: string }
      default_template: { type: string }
      default_playbooks: { type: array, items: { type: string } }
      default_groups: { type: array, items: { type: string } }
