包含 Kamelet 和其他信息的 ID 的元数据部分,如 Kamelet 的类型(源、sink 或 action)。
包含可用于配置 Kamelet 的一组参数的定义(JSON-schema 规格)。
可选的 type 部分,其中包含 Kamelet 预期的输入和输出的信息。
YAML DSL 中的 Camel 模板,用于定义 Kamelet 的实现。
下图显示了 Kamelet 及其部分的示例。
Kamelet 结构示例
telegram-text-source.kamelet.yaml
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
name: telegram-source
annotations:
camel.apache.org/catalog.version: "master-SNAPSHOT"
camel.apache.org/kamelet.icon: "data:image/..."
camel.apache.org/provider: "Red Hat"
camel.apache.org/kamelet.group: "Telegram"
labels:
camel.apache.org/kamelet.type: "source"
spec:
definition:
title: "Telegram Source"
description: |-
Receive all messages that people send to your telegram bot.
To create a bot, contact the @botfather account using the
Telegram app.
The source attaches the following headers to the messages:
- chat-id / ce-chatid: the ID of the chat where the
message comes from
required:
- authorizationToken
type: object
properties:
authorizationToken:
title: Token
description: The token to access your bot on Telegram, that you
can obtain from the Telegram "Bot Father".
type: string
format: password
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:password
types:
out:
mediaType: application/json
dependencies:
- "camel:jackson"
- "camel:kamelet"
- "camel:telegram"
template:
from:
uri: telegram:bots
parameters:
authorizationToken: "{{authorizationToken}}"
steps:
- set-header:
name: chat-id
simple: "${header[CamelTelegramChatId]}"
- set-header:
name: ce-chatid
simple: "${header[CamelTelegramChatId]}"
- marshal:
json: {}
- to: "kamelet:sink"
title: "Telegram Source"
description: |-
Receive all messages that people send to your telegram bot.
To create a bot, contact the @botfather account using the
Telegram app.
The source attaches the following headers to the messages:
- chat-id / ce-chatid: the ID of the chat where the
message comes from
required:
- authorizationToken
type: object
properties:
authorizationToken:
title: Token
description: The token to access your bot on Telegram, that you
can obtain from the Telegram "Bot Father".
type: string
format: password
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:password
types: