apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: order-hamburger
  title: Order Hamburger
  description: Create an order for a hamburger with customizable size, sauces, and toppings.
spec:
  owner: kitchen-team
  type: main
  parameters:
    - title: Hamburger Order Configuration
      required:
        - size
      properties:
        size:
          type: string
          title: Size
          description: Choose the size of the hamburger.
          enum:
            - small
            - medium
            - large
        sauces:
          type: array
          title: Sauces
          description: Choose sauces for the hamburger.
          items:
            type: string
            enum:
              - ketchup
              - mustard
              - mayonnaise
            enumNames:
              - Ketchup
              - Mustard
              - Mayonnaise
          uniqueItems: true
          ui:widget: checkboxes
        toppings:
          type: array
          title: Toppings
          description: Choose toppings for the hamburger.
          items:
            type: string
            enum:
              - lettuce
              - tomato
              - onion
              - pickle
            enumNames:
              - Lettuce
              - Tomato
              - Onion
              - Pickle
          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: hamburger
              size: ${{ parameters.size }}
              sauces: ${{ parameters.sauces }}
              extras: ${{ parameters.toppings }}

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