# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
  name: salesforce-source
  annotations:
    camel.apache.org/kamelet.support.level: "Stable"
    camel.apache.org/catalog.version: "4.10.2"
    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,[encoded data, 10488 characters]"
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "Salesforce"
    camel.apache.org/kamelet.namespace: "Salesforce"
  labels:
    camel.apache.org/kamelet.type: "source"
spec:
  definition:
    title: "Salesforce Source"
    description: |-
      Receive updates from Salesforce.
    required:
      - query
      - topicName
      - clientId
      - clientSecret
      - userName
      - password
    type: object
    properties:
      query:
        title: Query
        description: The query to execute on Salesforce.
        type: string
        example: SELECT Id, Name, Email, Phone FROM Contact
      topicName:
        title: Topic Name
        description: The name of the topic or channel.
        type: string
        example: ContactTopic
      loginUrl:
        title: Login URL
        description: The Salesforce instance login URL.
        type: string
        default: https://login.salesforce.com
      notifyForFields:
        title: Notify For Fields
        description: Notify for fields.
        type: string
        default: ALL
        enum: [ "ALL", "REFERENCED", "SELECT", "WHERE"]
      clientId:
        title: Consumer Key
        description: The Salesforce application consumer key.
        type: string
        x-descriptors:
        - urn:camel:group:credentials
      clientSecret:
        title: Consumer Secret
        description: The Salesforce application consumer secret.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      userName:
        title: Username
        description: The Salesforce username.
        type: string
        x-descriptors:
        - urn:camel:group:credentials
      password:
        title: Password
        description: The Salesforce user password.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      notifyForOperationCreate:
        title: Notify Operation Create
        description: Notify for create operation.
        type: boolean
        default: true
      notifyForOperationUpdate:
        title: Notify Operation Update
        description: Notify for update operation.
        type: boolean
        default: false
      notifyForOperationDelete:
        title: Notify Operation Delete
        description: Notify for delete operation.
        type: boolean
        default: false
      notifyForOperationUndelete:
        title: Notify Operation Undelete
        description: Notify for undelete operation.
        type: boolean
        default: false
      operation:
        title: Operation
        description: The operation to use
        type: string
        default: subscribe
      rawPayload:
        title: Raw Payload
        description: Use raw payload String for request and response (either JSON or XML depending on format), instead of DTOs, false by default.
        type: boolean
        default: false
      replayId:
        title: Replay Id
        description: The replayId value to use when subscribing to the Streaming API.
        type: long
  types:
    out:
      mediaType: application/json
  dependencies:
  - "camel:jackson"
  - "camel:salesforce"
  - "camel:kamelet"
  template:
    beans:
      - name: local-salesforce
        type: "#class:org.apache.camel.component.salesforce.SalesforceComponent"
        properties:
          clientId: "{{clientId}}"
          clientSecret: "{{clientSecret}}"
          userName: "{{userName}}"
          password: "{{password}}"
          loginUrl: "{{loginUrl}}"
    from:
      uri: "{{local-salesforce}}:{{operation}}:{{topicName}}"
      parameters:
        notifyForFields: "{{notifyForFields}}"
        updateTopic: "true"
        notifyForOperationCreate: "{{notifyForOperationCreate}}"
        notifyForOperationUpdate: "{{notifyForOperationUpdate}}"
        notifyForOperationDelete: "{{notifyForOperationDelete}}"
        notifyForOperationUndelete: "{{notifyForOperationUndelete}}"
        sObjectQuery: "{{query}}"
        rawPayload: "{{rawPayload}}"
        replayId: "{{?replayId}}"
      steps:
      - marshal:
          json: {}
      - to: "kamelet:sink"