apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: order-salad
  title: Order Salad
  description: Create an order for salad with customizable ingredients, dressings, and size.
spec:
  owner: kitchen-team
  type: side
  parameters:
    - title: Salad Order Configuration
      required:
        - base
      properties:
        base:
          type: string
          title: Salad Base
          description: Choose the base for the salad.
          items:
            enum:
              - lettuce
              - spinach
              - kale
            enumNames:
              - Lettuce
              - Spinach
              - Kale
        dressings:
          type: string
          title: Dressings
          description: Choose dressings for the salad.
          items:
            type: string
            enum:
              - ranch
              - vinaigrette
              - caesar
            enumNames:
              - Ranch
              - Vinaigrette
              - Caesar
        toppings:
          type: array
          title: Toppings
          description: Choose toppings for the salad.
          items:
            type: string
            enum:
              - cheese
              - croutons
              - chicken
            enumNames:
              - Cheese
              - Croutons
              - Chicken
          uniqueItems: true
          ui:widget: checkboxes
        size:
          type: string
          title: Size
          description: Choose the salad size.
          enum:
            - small
            - medium
            - large
  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: salads
              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 }}'