apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: order-coleslaw
  title: Order Coleslaw
  description: Create an order for coleslaw with customizable size and ingredients.
spec:
  owner: kitchen-team
  type: side
  parameters:
    - title: Coleslaw Order Configuration
      required:
        - size
      properties:
        size:
          type: string
          title: Size
          description: Choose the size of the coleslaw.
          enum:
            - small
            - medium
            - large
        extras:
          type: array
          title: Extras
          description: Choose extra ingredients for coleslaw.
          items:
            type: string
            enum:
              - raisins
              - pineapple
              - carrot
            enumNames:
              - Raisins
              - Pineapple
              - Carrot
          uniqueItems: true
          ui:widget: checkboxes
  steps:
    - id: submit-order
      name: Submit Order
      action: http:backstage:request
      input:
        method: 'POST'
        path: '/proxy/log-forwarding'
        headers:
          content-type: 'application/json'
        body:
          event:
            action: submit-order
            attributes:
              menu-item: coleslaw
              size: ${{ parameters.size }}
              sauces: ${{ parameters.sauces }}
              extras: ${{ parameters.extras }}

  output:
    orderResponse: '{{ steps["submit-order"].output.body }}'
    orderStatusCode: '{{ steps["submit-order"].output.code }}'
    orderHeaders: '{{ steps["submit-order"].output.headers }}'