asyncapi: 3.0.0
info:
  title: Baggage Logistics API
  version: 1.0.0
  description: |-
    The Baggage Logistics API allows you to handle baggage for the airline
    ### Check out its awesome features:

    * Receive instructions on each bag
    * Report on bags, carts and ULD as used in the process
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
defaultContentType: application/xml
servers:
  test-kafka-baggage:
    host: test.mykafkacluster.org:28092
    protocol: kafka-secure
    pathname: /baggage-logistics/v1.000
    description: Test broker secured with X509
    security:
      - $ref: '#/components/securitySchemes/certs'
    tags:
      - name: env:test-kafka
        description: >-
          This environment is meant for running integration tests with baggage
          partners
      - name: kind:remote
        description: This server is a remote server. Not exposed by the application
      - name: visibility:private
        description: This resource is private and only available to certain users
  prod-kafka-baggage:
    host: mykafkacluster.org:28092
    protocol: kafka-secure
    pathname: /baggage-logistics/v1.000
    description: Prod broker secured with X509
    security:
      - $ref: '#/components/securitySchemes/certs'
    tags:
      - name: env:prod-kafka
        description: >-
          This environment is meant for production integration with baggage
          partners
      - name: kind:remote
        description: This server is a remote server. Not exposed by the application
      - name: visibility:private
        description: This resource is private and only available to certain users
channels:
  bagInstructions:
    address: bag.instructions.{airport}.{handler}
    messages:
      bagInstruction:
        $ref: '#/components/messages/lightMeasured'
    description: (updated) instruction to handle a bag.
    parameters:
      airport:
        $ref: '#/components/parameters/airport'
      handler:
        $ref: '#/components/parameters/handler'
  bagResults:
    address: bag.results.{airport}.{handler}
    messages:
      bagResult:
        $ref: '#/components/messages/lightMeasured'
    description: (partial) result of handling a bag.
    parameters:
      airport:
        $ref: '#/components/parameters/airport'
      handler:
        $ref: '#/components/parameters/handler'
  cartResults:
    address: cart.results.{airport}.{handler}
    messages:
      cartResult:
        $ref: '#/components/messages/lightMeasured'
    description: (partial) result of handling a bag.
    parameters:
      airport:
        $ref: '#/components/parameters/airport'
      handler:
        $ref: '#/components/parameters/handler'
  uldResults:
    address: uld.results.{airport}.{handler}
    messages:
      uldResult:
        $ref: '#/components/messages/lightMeasured'
    description: (partial) result of handling a bag.
    parameters:
      airport:
        $ref: '#/components/parameters/airport'
      handler:
        $ref: '#/components/parameters/handler'
operations:
  receiveBagResult:
    action: receive
    channel:
      $ref: '#/channels/bagResults'
    summary: Inform airline on progress in handling the bag.
    traits:
      - $ref: '#/components/operationTraits/kafka'
    messages:
      - $ref: '#/channels/bagResults/messages/bagResult'
  receiveCartResult:
    action: receive
    channel:
      $ref: '#/channels/cartResults'
    summary: Inform airline on progress in handling the cart.
    traits:
      - $ref: '#/components/operationTraits/kafka'
    messages:
      - $ref: '#/channels/cartResults/messages/cartResult'
  receiveULDResult:
    action: receive
    channel:
      $ref: '#/channels/uldResults'
    summary: Inform airline on progress in handling the ULD.
    traits:
      - $ref: '#/components/operationTraits/kafka'
    messages:
      - $ref: '#/channels/uldResults/messages/uldResult'
  sendBagInstruction:
    action: send
    channel:
      $ref: '#/channels/bagInstructions'
    summary: Instruct handler on bag.
    traits:
      - $ref: '#/components/operationTraits/kafka'
    messages:
      - $ref: '#/channels/bagInstructions/messages/bagInstruction'
components:
  messages:
    lightMeasured:
      name: lightMeasured
      title: Bag in progress
      summary: to be advised.
      contentType: application/json
      traits:
        - $ref: '#/components/messageTraits/commonHeaders'
      payload:
        $ref: '#/components/schemas/lightMeasuredPayload'
    turnOnOff:
      name: turnOnOff
      title: Turn on/off
      summary: Command a particular streetlight to turn the lights on or off.
      traits:
        - $ref: '#/components/messageTraits/commonHeaders'
      payload:
        $ref: '#/components/schemas/turnOnOffPayload'
    dimLight:
      name: dimLight
      title: Dim light
      summary: Command a particular streetlight to dim the lights.
      traits:
        - $ref: '#/components/messageTraits/commonHeaders'
      payload:
        $ref: '#/components/schemas/dimLightPayload'
  schemas:
    lightMeasuredPayload:
      type: object
      properties:
        lumens:
          type: integer
          minimum: 0
          description: Light intensity measured in lumens.
        sentAt:
          $ref: '#/components/schemas/sentAt'
    turnOnOffPayload:
      type: object
      properties:
        command:
          type: string
          enum:
            - 'on'
            - 'off'
          description: Whether to turn on or off the light.
        sentAt:
          $ref: '#/components/schemas/sentAt'
    dimLightPayload:
      type: object
      properties:
        percentage:
          type: integer
          description: Percentage to which the light should be dimmed to.
          minimum: 0
          maximum: 100
        sentAt:
          $ref: '#/components/schemas/sentAt'
    sentAt:
      type: string
      format: date-time
      description: Date and time when the message was sent.
  securitySchemes:
    certs:
      type: X509
      description: Download the certificate files from service provider
  parameters:
    airport:
      description: The IATA Airport location code.
    handler:
      description: Identifier of the handler.
  messageTraits:
    commonHeaders:
      headers:
        type: object
        properties:
          my-app-header:
            type: integer
            minimum: 0
            maximum: 100
  operationTraits:
    kafka:
      bindings:
        kafka:
          clientId:
            type: string
            enum:
              - my-app-id
