---
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    funktion.fabric8.io/kind: Connector
  name: hipchat
data:
  deployment.yml: |
    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      labels:
        funktion.fabric8.io/kind: Subscription
        connector: hipchat
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            funktion.fabric8.io/kind: Subscription
            connector: hipchat
        spec:
          containers:
          - image: funktion/connector-hipchat:${project.version}
            name: connector
  schema.yml: |
    ---
    component:
      kind: component
      scheme: hipchat
      syntax: hipchat:protocol:host:port
      title: Hipchat
      description: The hipchat component supports producing and consuming messages from/to Hipchat service.
      label: api,cloud
      deprecated: false
      async: false
      javaType: org.apache.camel.component.hipchat.HipchatComponent
      groupId: org.apache.camel
      artifactId: camel-hipchat
      version: 2.18.3
    componentProperties: {}
    properties:
      protocol:
        kind: path
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: The protocol for the hipchat server such as http.
        order: 0
      host:
        kind: path
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: The host for the hipchat server such as api.hipchat.com
        order: 1
      port:
        kind: path
        group: common
        type: integer
        javaType: java.lang.Integer
        deprecated: false
        secret: false
        defaultValue: "80"
        description: The port for the hipchat server. Is by default 80.
        order: 2
      authToken:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: OAuth 2 auth token
        order: 3
      consumeUsers:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Username(s) when consuming messages from the hiptchat server. Multiple user names can be separated by comma.
        order: 4
      bridgeErrorHandler:
        kind: parameter
        group: consumer
        label: consumer
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: false
        description: Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.
        order: 5
      sendEmptyMessageWhenIdle:
        kind: parameter
        group: consumer
        label: consumer
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: false
        description: If the polling consumer did not poll any files you can enable this option to send an empty message (no body) instead.
        order: 6
      exceptionHandler:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: object
        javaType: org.apache.camel.spi.ExceptionHandler
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
        order: 7
      exchangePattern:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: string
        javaType: org.apache.camel.ExchangePattern
        enum:
        - InOnly
        - RobustInOnly
        - InOut
        - InOptionalOut
        - OutOnly
        - RobustOutOnly
        - OutIn
        - OutOptionalIn
        deprecated: false
        secret: false
        description: Sets the exchange pattern when the consumer creates an exchange.
        order: 8
      pollStrategy:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: object
        javaType: org.apache.camel.spi.PollingConsumerPollStrategy
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel.
        order: 9
      synchronous:
        kind: parameter
        group: advanced
        label: advanced
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
        order: 10
      backoffErrorThreshold:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: integer
        javaType: int
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in.
        order: 11
      backoffIdleThreshold:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: integer
        javaType: int
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: The number of subsequent idle polls that should happen before the backoffMultipler should kick-in.
        order: 12
      backoffMultiplier:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: integer
        javaType: int
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured.
        order: 13
      delay:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: integer
        javaType: long
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: "500"
        description: Milliseconds before the next poll. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour).
        order: 14
      greedy:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: false
        description: If greedy is enabled then the ScheduledPollConsumer will run immediately again if the previous run polled 1 or more messages.
        order: 15
      initialDelay:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: integer
        javaType: long
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: "1000"
        description: Milliseconds before the first poll starts. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour).
        order: 16
      runLoggingLevel:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: string
        javaType: org.apache.camel.LoggingLevel
        enum:
        - TRACE
        - DEBUG
        - INFO
        - WARN
        - ERROR
        - OFF
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: TRACE
        description: The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that.
        order: 17
      scheduledExecutorService:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: object
        javaType: java.util.concurrent.ScheduledExecutorService
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool.
        order: 18
      scheduler:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: string
        javaType: org.apache.camel.spi.ScheduledPollConsumerScheduler
        enum:
        - none
        - spring
        - quartz2
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: none
        description: To use a cron scheduler from either camel-spring or camel-quartz2 component
        order: 19
      schedulerProperties:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: object
        javaType: java.util.Map<java.lang.String,java.lang.Object>
        prefix: scheduler.
        multiValue: true
        deprecated: false
        secret: false
        description: To configure additional properties when using a custom scheduler or any of the Quartz2 Spring based scheduler.
        order: 20
      startScheduler:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: true
        description: Whether the scheduler should be auto started.
        order: 21
      timeUnit:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: string
        javaType: java.util.concurrent.TimeUnit
        enum:
        - NANOSECONDS
        - MICROSECONDS
        - MILLISECONDS
        - SECONDS
        - MINUTES
        - HOURS
        - DAYS
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: MILLISECONDS
        description: Time unit for initialDelay and delay options.
        order: 22
      useFixedDelay:
        kind: parameter
        group: scheduler
        label: consumer,scheduler
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: true
        description: Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details.
        order: 23
  documentation.adoc: |
    [[Hipchat-HipchatComponent]]
    Hipchat Component
    ~~~~~~~~~~~~~~~~~

    *Available as of Camel 2.15.0*

    The Hipchat component supports producing and consuming messages from/to
    https://www.hipchat.com[Hipchat] service.

    *Prerequisites*

    You must have a valid Hipchat user account and get a
    https://www.hipchat.com/account/api[personal access token] that you can
    use to produce/consume messages.


    [[Hipchat-URIFormat]]
    URI Format
    ^^^^^^^^^^

    [source,java]
    -------------------------------
    hipchat://[host][:port]?options
    -------------------------------

    You can append query options to the URI in the following format,
    ?options=value&option2=value&...

    [[Hipchat-URIOptions]]
    URI Options
    ^^^^^^^^^^^


    // component options: START
    The Hipchat component has no options.
    // component options: END






    // endpoint options: START
    The Hipchat component supports 24 endpoint options which are listed below:

    {% raw %}
    [width="100%",cols="2,1,1m,1m,5",options="header"]
    |=======================================================================
    | Name | Group | Default | Java Type | Description
    | protocol | common |  | String | *Required* The protocol for the hipchat server such as http.
    | host | common |  | String | *Required* The host for the hipchat server such as api.hipchat.com
    | port | common | 80 | Integer | The port for the hipchat server. Is by default 80.
    | authToken | common |  | String | OAuth 2 auth token
    | consumeUsers | common |  | String | Username(s) when consuming messages from the hiptchat server. Multiple user names can be separated by comma.
    | bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.
    | sendEmptyMessageWhenIdle | consumer | false | boolean | If the polling consumer did not poll any files you can enable this option to send an empty message (no body) instead.
    | exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
    | exchangePattern | consumer (advanced) |  | ExchangePattern | Sets the exchange pattern when the consumer creates an exchange.
    | pollStrategy | consumer (advanced) |  | PollingConsumerPollStrategy | A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel.
    | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
    | backoffErrorThreshold | scheduler |  | int | The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in.
    | backoffIdleThreshold | scheduler |  | int | The number of subsequent idle polls that should happen before the backoffMultipler should kick-in.
    | backoffMultiplier | scheduler |  | int | To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured.
    | delay | scheduler | 500 | long | Milliseconds before the next poll. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour).
    | greedy | scheduler | false | boolean | If greedy is enabled then the ScheduledPollConsumer will run immediately again if the previous run polled 1 or more messages.
    | initialDelay | scheduler | 1000 | long | Milliseconds before the first poll starts. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour).
    | runLoggingLevel | scheduler | TRACE | LoggingLevel | The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that.
    | scheduledExecutorService | scheduler |  | ScheduledExecutorService | Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool.
    | scheduler | scheduler | none | ScheduledPollConsumerScheduler | To use a cron scheduler from either camel-spring or camel-quartz2 component
    | schedulerProperties | scheduler |  | Map | To configure additional properties when using a custom scheduler or any of the Quartz2 Spring based scheduler.
    | startScheduler | scheduler | true | boolean | Whether the scheduler should be auto started.
    | timeUnit | scheduler | MILLISECONDS | TimeUnit | Time unit for initialDelay and delay options.
    | useFixedDelay | scheduler | true | boolean | Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details.
    |=======================================================================
    {% endraw %}
    // endpoint options: END






    [[Hipchat-ScheduledPollConsumer]]
    Scheduled Poll Consumer
    ^^^^^^^^^^^^^^^^^^^^^^^

    This component implements the
    link:polling-consumer.html[ScheduledPollConsumer]. Only the last message
    from the provided 'consumeUsers' are retrieved and sent as Exchange
    body. If you do not want the same message to be retrieved again when
    there are no new messages on next poll then you can add the
    link:idempotent-consumer.html[idempotent consumer] as shown below. All
    the options on the link:polling-consumer.html[ScheduledPollConsumer] can
    also be used for more control on the consumer.

    [source,java]
    ---------------------------------------------------------------------------------
    @Override
    public void configure() throws Exception {
     String hipchatEndpointUri = "hipchat://?authToken=XXXX&consumeUsers=@Joe,@John";
     from(hipchatEndpointUri)
      .idempotentConsumer(
        simple("${in.header.HipchatMessageDate} ${in.header.HipchatFromUser}"),
        MemoryIdempotentRepository.memoryIdempotentRepository(200)
      )
      .to("mock:result");
    }
    ---------------------------------------------------------------------------------

    [[Hipchat-MessageheaderssetbytheHipchatconsumer]]
    Message headers set by the Hipchat consumer
    +++++++++++++++++++++++++++++++++++++++++++

    [width="100%",cols="10%,10%,10%,70%",options="header",]
    |=======================================================================

    |*Header* |*Constant* |*Type* |*Description*

    |HipchatFromUser |HipchatConstants.FROM_USER |_String_ |The body has the message that was sent from this user to the owner of
    authToken

    |HipchatMessageDate |HipchatConstants.MESSAGE_DATE |_String_ |The date message was sent. The format is ISO-8601 as present in the
    Hipchat https://www.hipchat.com/docs/apiv2/method/view_recent_privatechat_history[response].

    |HipchatFromUserResponseStatus |HipchatConstants.FROM_USER_RESPONSE_STATUS  |_http://hc.apache.org/httpcomponents-core-4.2.x/httpcore/apidocs/org/apache/http/StatusLine.html[StatusLine]_
    The status of the API response received.
    |=======================================================================

    [[Hipchat-HipchatProducer]]
    Hipchat Producer
    ^^^^^^^^^^^^^^^^

    Producer can send messages to both Room's and User's simultaneously. The
    body of the exchange is sent as message. Sample usage is shown below.
    Appropriate headers needs to be set.

    [source,java]
    ----------------------------------------------------------
    @Override
     public void configure() throws Exception {
      String hipchatEndpointUri = "hipchat://?authToken=XXXX";
      from("direct:start")
       .to(hipchatEndpointUri)
       .to("mock:result");
     }
    ----------------------------------------------------------

    [[Hipchat-MessageheadersevaluatedbytheHipchatproducer]]
    Message headers evaluated by the Hipchat producer
    +++++++++++++++++++++++++++++++++++++++++++++++++

    [width="100%",cols="10%,10%,10%,70%",options="header",]
    |=======================================================================

    |*Header* |*Constant* |*Type* |*Description*

    |HipchatToUser |HipchatConstants.TO_USER |_String_ |The Hipchat user to which the message needs to be sent.

    |HipchatToRoom |HipchatConstants.TO_ROOM |_String_ |The Hipchat room to which the message needs to be sent.

    |HipchatMessageFormat |HipchatConstants.MESSAGE_FORMAT |String |Valid formats are 'text' or 'html'. *Default: 'text'*

    |HipchatMessageBackgroundColor |HipchatConstants.MESSAGE_BACKGROUND_COLOR |_String_ |Valid color values are 'yellow', 'green', 'red', 'purple', 'gray',
    'random'. *Default: 'yellow' (Room Only)* 

    |HipchatTriggerNotification |HipchatConstants.TRIGGER_NOTIFY |_String_ |Valid values are 'true' or 'false'. Whether this message should trigger
    a user notification (change the tab color, play a sound, notify mobile
    phones, etc). *Default: 'false' (Room Only)*
    |=======================================================================

    [[Hipchat-MessageheaderssetbytheHipchatproducer]]
    Message headers set by the Hipchat producer
    +++++++++++++++++++++++++++++++++++++++++++

    [width="100%",cols="10%,10%,10%,70%",options="header",]
    |=======================================================================

    |*Header* |*Constant* |*Type* |*Description*

    |HipchatToUserResponseStatus |HipchatConstants.TO_USER_RESPONSE_STATUS |_http://hc.apache.org/httpcomponents-core-4.2.x/httpcore/apidocs/org/apache/http/StatusLine.html[StatusLine]_
    The status of the API response received when message sent to the user.

    |HipchatFromUserResponseStatus |HipchatConstants.TO_ROOM_RESPONSE_STATUS |_http://hc.apache.org/httpcomponents-core-4.2.x/httpcore/apidocs/org/apache/http/StatusLine.html[StatusLine]_ |The status of the API response received when message sent to the room.
    |=======================================================================

    [[Hipchat-Dependencies]]
    Dependencies
    ++++++++++++

    Maven users will need to add the following dependency to their pom.xml.

    *pom.xml*

    [source,xml]
    ------------------------------------------
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-hipchat</artifactId>
        <version>${camel-version}</version>
    </dependency>
    ------------------------------------------

    where `${camel-version}` must be replaced by the actual version of Camel
    (2.15.0 or higher)
