apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: order-onion-rings
  title: Order Onion Rings
  description: Create an order for onion rings with customizable size and sauces.
spec:
  owner: kitchen-team
  type: side
  parameters:
    - title: Onion Rings Order Configuration
      required:
        - size
      properties:
        size:
          type: string
          title: Size
          description: Choose the size of the onion rings.
          enum:
            - small
            - medium
            - large
        sauces:
          type: array
          title: Sauces
          description: Choose sauces to accompany the onion rings.
          items:
            type: string
            enum:
              - ketchup
              - barbecue
              - sweet and sour
            enumNames:
              - Ketchup
              - Barbecue
              - Sweet and Sour
          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: onionrings
              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 }}'