apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: order-chicken-nuggets
  title: Order Chicken Nuggets
  description: Create an order for chicken nuggets with customizable quantity and sauces.
spec:
  owner: kitchen-team
  type: side
  parameters:
    - title: Chicken Nuggets Order Configuration
      required:
        - quantity
      properties:
        quantity:
          type: integer
          title: Quantity
          description: Number of chicken nuggets.
          minimum: 4
          maximum: 20
        sauces:
          type: array
          title: Sauces
          description: Choose sauces to accompany the chicken nuggets.
          items:
            type: string
            enum:
              - ketchup
              - barbecue
              - sweet and sour
              - honey mustard
            enumNames:
              - Ketchup
              - Barbecue
              - Sweet and Sour
              - Honey Mustard
          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: chickennuggets
              quantity: ${{ parameters.quantity }}
              sauces: ${{ parameters.sauces }}

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