apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: websocket-source
  labels:
    camel.apache.org/kamelet.type: "source"
  annotations:
    camel.apache.org/kamelet.support.level: "Stable"
    camel.apache.org/catalog.version: "3.21.0"
    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjUwMCIgaGVpZ2h0PSIxODg1IiB2aWV3Qm94PSIwIDAgMjU2IDE5MyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCI+PHBhdGggZD0iTTE5Mi40NCAxNDQuNjQ1aDMxLjc4VjY4LjMzOWwtMzUuODA1LTM1LjgwNC0yMi40NzIgMjIuNDcyIDI2LjQ5NyAyNi40OTd2NjMuMTR6bTMxLjg2NCAxNS45MzFIMTEzLjQ1Mkw4Ni45NTQgMTM0LjA4bDExLjIzNy0xMS4yMzYgMjEuODg1IDIxLjg4NWg0NS4wMjhsLTQ0LjM1Ny00NC40NDEgMTEuMzItMTEuMzIgNDQuMzU3IDQ0LjM1OFY4OC4yOTZsLTIxLjgwMS0yMS44MDEgMTEuMTUyLTExLjE1M0wxMTAuNjg1IDBIMGwzMS42OTYgMzEuNjk2di4wODRIOTcuNDM2bDIzLjIyNyAyMy4yMjctMzMuOTYgMzMuOTZMNjMuNDc2IDY1Ljc0VjQ3LjcxMmgtMzEuNzh2MzEuMTkzbDU1LjAwNyA1NS4wMDdMNjQuMzE0IDE1Ni4zbDM1LjgwNSAzNS44MDVIMjU2bC0zMS42OTYtMzEuNTI5eiIgZmlsbD0iIzIzMUYyMCIvPjwvc3ZnPg=="
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "Websocket"
    camel.apache.org/kamelet.namespace: "Websocket"
spec:
  definition:
    title: "Websocket Source"
    description: "Websocket endpoints for communicating with clients"
    type: object
    required:
    - resourceUri
    properties:
      websocketHost:
        title: Host
        description: The hostname
        type: string
        default: "0.0.0.0"
      websocketPort:
        title: Port
        description: The port number
        type: integer
        default: 9292
      resourceUri:
        title: Resource Uri
        description: The name of the websocket channel to use.
        type: string
      maxBinaryMessageSize:
        title: Max Binary Message Size
        description: Can be used to set the size in bytes that the websocket created by the websocketServlet may be accept before closing. (Default is -1 - or unlimited).
        type: integer
        default: -1
      bridgeErrorHandler: 
        title: Bridge Rrror Handler
        description: Allows for bridging the consumer to the Camel routing Error Handler
        type: boolean
        x-descriptors:
        - urn:alm:descriptor:com.tectonic.ui:checkbox
        default: false
      sessionSupport: 
        title: Session Support
        description: Whether to enable session support which enables HttpSession for each http request.
        type: boolean
        x-descriptors:
        - urn:alm:descriptor:com.tectonic.ui:checkbox
        default: false
      subprotocol:
        title: Subprotocol
        description: Comma-separated list of subprotocols that are supported by the application.
        type: string
        default: any
      lazyStartProducer:
        title: Lazy Start Producer
        description: Whether the producer should be started lazy (on the first message).
        type: boolean
        x-descriptors:
        - urn:alm:descriptor:com.tectonic.ui:checkbox
        default: false
      sendTimeout:
        title: Send Timeout
        description: Timeout in millis when sending to a websocket channel. The default timeout is 30000 (30 seconds).
        type: integer
        default: 30000
      bufferSize:
        title: Buffer Size
        description: Set the buffer size of the websocketServlet
        type: integer
        default: 8192
      maxIdleTime:
        title: Max Idle Time
        description: SetSet the time in ms that the websocket created by the websocketServlet may be idle before closing.
        type: integer
        default: 300000
      allowedOrigins:
        title: Allowed Origins
        description: The CORS allowed origins. Use to allow all.
        type: string
        default: ""
      crossOriginFilterOn:
        title: Cross Origin Filter
        description: Whether to enable CORS.
        type: boolean
        x-descriptors:
        - urn:alm:descriptor:com.tectonic.ui:checkbox
        default: false
      filterPath:
        title: Filter Path
        description: Context path for filtering CORS.
        type: string
        default: ""
      enableJmx:
        title: Filter Path
        description: Enable JMX support.
        type: boolean
        x-descriptors:
        - urn:alm:descriptor:com.tectonic.ui:checkbox
        default: false
  dependencies:
    - "camel:kamelet"
    - "camel:core"
    - "camel:websocket"
  template:
    from:
      uri: "websocket://{{websocketHost}}:{{websocketPort}}/{{resourceUri}}"
      parameters:
        maxBinaryMessageSize: "{{maxBinaryMessageSize}}"
        bridgeErrorHandler: "{{bridgeErrorHandler}}"
        sessionSupport: "{{sessionSupport}}"
        subprotocol: "{{subprotocol}}"
        lazyStartProducer: "{{lazyStartProducer}}"
        sendTimeout: "{{sendTimeout}}"
        bufferSize: "{{bufferSize}}"
        maxIdleTime: "{{maxIdleTime}}"
        allowedOrigins: "{{allowedOrigins}}"
        crossOriginFilterOn: "{{crossOriginFilterOn}}"
        filterPath: "{{filterPath}}"
        enableJmx: "{{enableJmx}}"
      steps:
      - to: kamelet:sink