asyncapi: 3.0.0
id: 'https://ch.kochse/educ/plantit/common/api'
info:
  title: Plantit-Common
  version: '2.1.3'
  description: API of event channel
  contact:
    email: plantit@kochse.ch
    name: Andres Koch
    url: 'https://www.kochse.ch'
  license:
    name: Apache 2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0'
defaultContentType: application/json
servers:
  production:
    host: 'masse-mq.dynu.net:62616'
    protocol: amqp
    description: message broker for MAS/SE ADS exercise
channels:
  common/events:
    address: common/events
    messages:
      PlantingStatusEvent:
        $ref: '#/components/messages/PlantingStatusEvent'
      TransportStatusEvent:
        $ref: '#/components/messages/TransportStatusEvent'
      WarehouseStatusEvent:
        $ref: '#/components/messages/WarehouseStatusEvent'
      PlanningStatusEvent:
        $ref: '#/components/messages/PlanningStatusEvent'
    bindings:
      amqp:
        is: routingKey
        exchange:
          name: T.plantit.common.events
          type: topic
          durable: false
          autoDelete: false
operations:
  updateState:
    action: send
    channel:
      $ref: '#/channels/common~1events'
    messages:
      - $ref: '#/channels/common~1events/messages/PlantingStatusEvent'
      - $ref: '#/channels/common~1events/messages/TransportStatusEvent'
      - $ref: '#/channels/common~1events/messages/WarehouseStatusEvent'
      - $ref: '#/channels/common~1events/messages/PlanningStatusEvent'
components:
  messages:
    GeneralErrorMsg:
      name: GeneralError
      title: General Error Message
      summary: General error response which can be emitted by all services alike
      contentType: application/json
      payload:
        $ref: '#/components/schemas/GeneralErrorRspDTO'
    PlantingStatusEvent:
      name: PlantingStatusEvent
      title: Greenhouse emitted status events
      summary: Status changes emitted by the greenhouse
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PlantingStatusEvtDTO'
    TransportStatusEvent:
      name: TransportStatusEvent
      title: Transport Status Event
      summary: a status and location of the refered transport
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TransportStatusEventDTO'
    WarehouseStatusEvent:
      name: WarehouseStatusEvent
      title: Warehouse Status Event
      summary: a status and location of the refered stock place
      contentType: application/json
      payload:
        $ref: '#/components/schemas/WarehouseStatusEventDTO'
    PlanningStatusEvent:
      name: PlanningStatusEvent
      title: Planning emitted status events
      summary: Status changes emitted by the planning
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PlanningStatusEvtDTO'
  schemas:
    GeneralErrorRspDTO:
      type: object
      properties:
        code:
          type: integer
          description: 'Error code 0 = ok, <0 error code. ranges -xx001..-xx99'
          examples:
            - '-0001..-0999 plantit-common'
            - '-1001..-1099 plantit-planning'
            - '-1101..-1199 plantit-greenhouse'
            - '-1201..-1299 plantit-transport'
            - '-1301..-1399 plantit-warehouse'
        message:
          type: string
          description: Error message describing the error situation
        source:
          type: string
          description: name of the emitting system
          examples:
            - plantit-planning
            - plantit-greenhouse
            - plantit-transport
            - plantit-warehouse
    PlantingStatusEvtDTO:
      type: object
      properties:
        eventId:
          type: string
          description: unique id of event typically UUID
        eventType:
          type: string
          description: unique name built as <DOMAIN>_<NAME>
        eventTime:
          type: string
          format: date-time
          description: date/time the event was issued
        reference:
          type: string
          description: planting id of the reservation or order
        externalRef:
          type: string
          description: uuid to correlate to the to corresponding reservation or order
        siteName:
          type: string
          description: Name of the greenhouse location
        deliveryStatus:
          $ref: '#/components/schemas/PlantingStatus'
          description: defines the current state of the delivery
        estimatedDelivery:
          type: string
          description: date and time when goods are expected to be delivered
          format: date-time
        latestInfo:
          type: string
          description: latest information to the reservation or order
    TransportStatusEventDTO:
      type: object
      properties:
        eventId:
          type: string
          description: unique id of event typically UUID
        eventType:
          type: string
          description: unique name built as TRANSPORT_<NAME>
        eventTime:
          type: string
          format: date-time
          description: date/time the event was issued
        transportId:
          type: string
          description: transport id of the order
        transportStatus:
          $ref: '#/components/schemas/TransportStatus'
        externalRef:
          type: string
          description: uuid to correlate to the to corresponding customer order
        currentLocation:
          $ref: '#/components/schemas/TransportLocation'
    WarehouseStatusEventDTO:
      type: object
      properties:
        eventId:
          type: string
          description: unique id of event typically UUID
        eventType:
          type: string
          description: unique name built as STOCK_<NAME>
        eventTime:
          type: string
          format: date-time
          description: date/time the event was issued
        stockId:
          type: string
          description: stock id of the order
        stockStatus:
          $ref: '#/components/schemas/WarehouseStatus'
        externalRef:
          type: string
          description: uuid to correlate to the to corresponding customer order
    PlanningStatusEvtDTO:
      type: object
      properties:
        eventId:
          type: string
          description: unique id of event typically UUID
        eventType:
          type: string
          description: unique name built as <DOMAIN>_<NAME>
        eventTime:
          type: string
          format: date-time
          description: date/time the event was issued
        reference:
          type: string
          description: planting id of the reservation or order
        externalRef:
          type: string
          description: uuid to correlate to the to corresponding reservation or order
        deliveryStatus:
          $ref: '#/components/schemas/PlanningStatus'
          description: defines the current state of the delivery
        estimatedDelivery:
          type: string
          description: date and time when goods are expected to be delivered
          format: date-time
        latestInfo:
          type: string
          description: latest information to the reservation or order
    TransportLocation:
      type: object
      properties:
        longitude:
          type: number
          description: longitude of location
        latitude:
          type: number
          description: latitude of location
        siteSpecifics:
          type: string
          description: specific instruction at site
    PlantingStatus:
      type: string
      enum:
        - unavailable
        - reserved
        - ordered
        - cancelled
        - planted
        - growing
        - harvested
        - depraved
        - delivered
        - complete
        - undefined
      default: undefined
    TransportStatus:
      type: string
      enum:
        - unavailable
        - ordered
        - cancelled
        - loaded
        - driving
        - holding
        - unloaded
        - complete
        - undefined
      default: undefined
    WarehouseStatus:
      type: string
      enum:
        - unavailable
        - reserved
        - cancelled
        - occupied
        - checkout
        - complete
        - undefined
      default: undefined
    PlanningStatus:
      type: string
      enum:
        - unavailable
        - reserved
        - ordered
        - cancelled
        - planted
        - growing
        - harvested
        - depraved
        - loaded
        - moving
        - unloaded
        - delivered
        - undefined
      default: undefined
