---
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    funktion.fabric8.io/kind: Connector
  name: openshift
data:
  deployment.yml: |
    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      labels:
        funktion.fabric8.io/kind: Subscription
        connector: openshift
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            funktion.fabric8.io/kind: Subscription
            connector: openshift
        spec:
          containers:
          - image: funktion/connector-openshift:${project.version}
            name: connector
  schema.yml: |
    ---
    component:
      kind: component
      scheme: openshift
      syntax: openshift:clientId
      title: OpenShift
      description: To manage your Openshift 2.x applications.
      label: cloud,paas
      deprecated: true
      async: false
      javaType: org.apache.camel.component.openshift.OpenShiftComponent
      groupId: org.apache.camel
      artifactId: camel-openshift
      version: 2.18.3
    componentProperties:
      username:
        kind: property
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: The username to login to openshift server.
        order: 0
      password:
        kind: property
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: The password for login to openshift server.
        order: 1
      domain:
        kind: property
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Domain name. If not specified then the default domain is used.
        order: 2
      server:
        kind: property
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Url to the openshift server. If not specified then the default value from the local openshift configuration file /.openshift/express.conf is used. And if that fails as well then openshift.redhat.com is used.
        order: 3
    properties:
      clientId:
        kind: path
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: The client id
        order: 0
      domain:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Domain name. If not specified then the default domain is used.
        order: 1
      password:
        kind: parameter
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: The password for login to openshift server.
        order: 2
      server:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Url to the openshift server. If not specified then the default value from the local openshift configuration file /.openshift/express.conf is used. And if that fails as well then openshift.redhat.com is used.
        order: 3
      username:
        kind: parameter
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: The username to login to openshift server.
        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
      application:
        kind: parameter
        group: producer
        label: producer
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: The application name to start stop restart or get the state.
        order: 10
      mode:
        kind: parameter
        group: producer
        label: producer
        type: string
        javaType: java.lang.String
        enum:
        - pojo
        - json
        deprecated: false
        secret: false
        description: Whether to output the message body as a pojo or json. For pojo the message is a List type.
        order: 11
      operation:
        kind: parameter
        group: producer
        label: producer
        type: string
        javaType: java.lang.String
        enum:
        - list
        - start
        - stop
        - restart
        - state
        - getStandaloneCartridge
        - getEmbeddedCartridges
        - addEmbeddedCartridge
        - removeEmbeddedCartridge
        - scaleUp
        - scaleDown
        - getGitUrl
        - getDeploymentType
        - setDeploymentType
        - getAllEnvironmentVariables
        - addEnvironmentVariable
        - addMultipleEnvironmentVariables
        - updateEnvironmentVariable
        - getEnvironmentVariableValue
        - removeEnvironmentVariable
        - getGearProfile
        - addAlias
        - removeAlias
        - getAliases
        deprecated: false
        secret: false
        description: 'The operation to perform which can be: list start stop restart and
          state. The list operation returns information about all the applications in
          json format. The state operation returns the state such as: started stopped
          etc. The other operations does not return any value.'
        order: 12
      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: 13
      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: 14
      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: 15
      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: 16
      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: 17
      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: 18
      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: 19
      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: 20
      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: 21
      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: 22
      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: 23
      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: 24
      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: 25
      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: 26
  documentation.adoc: |+
    [[Openshift-OpenshiftComponent]]
    Openshift Component
    ~~~~~~~~~~~~~~~~~~~

    *Available as of Camel 2.14*

    The *openshift* component is a component for managing your
    https://www.openshift.com/[OpenShift] applications. 

    Maven users will need to add the following dependency to their `pom.xml`
    for this component:

    [source,xml]
    ------------------------------------------------------------
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-openshift</artifactId>
        <version>x.x.x</version>
        <!-- use the same version as your Camel core version -->
    </dependency>
    ------------------------------------------------------------

    [[Openshift-URIformat]]
    URI format
    ^^^^^^^^^^

    [source,java]
    ----------------------------
    openshift:clientId[?options]
    ----------------------------

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

    [[Openshift-Options]]
    Options
    ^^^^^^^



    // component options: START
    The OpenShift component supports 4 options which are listed below.



    {% raw %}
    [width="100%",cols="2,1m,7",options="header"]
    |=======================================================================
    | Name | Java Type | Description
    | username | String | The username to login to openshift server.
    | password | String | The password for login to openshift server.
    | domain | String | Domain name. If not specified then the default domain is used.
    | server | String | Url to the openshift server. If not specified then the default value from the local openshift configuration file /.openshift/express.conf is used. And if that fails as well then openshift.redhat.com is used.
    |=======================================================================
    {% endraw %}
    // component options: END




    // endpoint options: START
    The OpenShift component supports 27 endpoint options which are listed below:

    {% raw %}
    [width="100%",cols="2,1,1m,1m,5",options="header"]
    |=======================================================================
    | Name | Group | Default | Java Type | Description
    | clientId | common |  | String | *Required* The client id
    | domain | common |  | String | Domain name. If not specified then the default domain is used.
    | password | common |  | String | *Required* The password for login to openshift server.
    | server | common |  | String | Url to the openshift server. If not specified then the default value from the local openshift configuration file /.openshift/express.conf is used. And if that fails as well then openshift.redhat.com is used.
    | username | common |  | String | *Required* The username to login to openshift server.
    | 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.
    | application | producer |  | String | The application name to start stop restart or get the state.
    | mode | producer |  | String | Whether to output the message body as a pojo or json. For pojo the message is a List type.
    | operation | producer |  | String | The operation to perform which can be: list start stop restart and state. The list operation returns information about all the applications in json format. The state operation returns the state such as: started stopped etc. The other operations does not return any value.
    | 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


    [[Openshift-Examples]]
    Examples
    ^^^^^^^^

    [[Openshift-Listingallapplications]]
    Listing all applications
    ++++++++++++++++++++++++

    [source,java]
    --------------------------------------------------------------------------
    // sending route
    from("direct:apps")
        .to("openshift:myClient?username=foo&password=secret&operation=list");
        .to("log:apps");
    --------------------------------------------------------------------------

    In this case the information about all the applications is returned as
    pojo. If you want a json response, then set mode=json.

    [[Openshift-Stoppinganapplication]]
    Stopping an application
    +++++++++++++++++++++++

    [source,java]
    ---------------------------------------------------------------------------------------------
    // stopping the foobar application
    from("direct:control")
        .to("openshift:myClient?username=foo&password=secret&operation=stop&application=foobar");
     
    ---------------------------------------------------------------------------------------------

    In the example above we stop the application named foobar.

     

    Polling for gear state changes

    The consumer is used for polling state changes in gears. Such as when a
    new gear is added/removed/ or its lifecycle is changed, eg started, or
    stopped etc.

    [source,java]
    ---------------------------------------------------------------------------------------------------------------------------------------
    // trigger when state changes on our gears
    from("openshift:myClient?username=foo&password=secret&delay=30s")
        .log("Event ${header.CamelOpenShiftEventType} on application ${body.name} changed state to ${header.CamelOpenShiftEventNewState}");
    ---------------------------------------------------------------------------------------------------------------------------------------

     

    When the consumer emits an Exchange then the body contains
    the `com.openshift.client.IApplication` as the message body. And the
    following headers is included.

    [width="100%",cols="10%,10%,80%",options="header",]
    |=======================================================================
    |Header |May be null |Description

    |CamelOpenShiftEventType |No |The type of the event which can be one of: added, removed or changed.

    |CamelOpenShiftEventOldState |Yes |The old state, when the event type is changed.

    |CamelOpenShiftEventNewState |No |The new state, for any of the event types
    |=======================================================================

    [[Openshift-SeeAlso]]
    See Also
    ^^^^^^^^

    * link:configuring-camel.html[Configuring Camel]
    * link:component.html[Component]
    * link:endpoint.html[Endpoint]
    * link:getting-started.html[Getting Started]

