diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml index 5cacaac528582..7d15c992e805e 100644 --- a/bom/camel-bom/pom.xml +++ b/bom/camel-bom/pom.xml @@ -106,6 +106,16 @@ camel-alibaba-oss 4.23.0-SNAPSHOT + + org.apache.camel + camel-alibaba-ots + 4.23.0-SNAPSHOT + + + org.apache.camel + camel-alibaba-sls + 4.23.0-SNAPSHOT + org.apache.camel camel-alibaba-sms diff --git a/catalog/camel-allcomponents/pom.xml b/catalog/camel-allcomponents/pom.xml index eb2ab055416e2..031d7a092972b 100644 --- a/catalog/camel-allcomponents/pom.xml +++ b/catalog/camel-allcomponents/pom.xml @@ -112,6 +112,16 @@ camel-alibaba-oss ${project.version} + + org.apache.camel + camel-alibaba-ots + ${project.version} + + + org.apache.camel + camel-alibaba-sls + ${project.version} + org.apache.camel camel-alibaba-sms diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties index 6b481121cb525..eb2f0cb47a420 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties @@ -7,6 +7,8 @@ alibaba-fc alibaba-kms alibaba-mns alibaba-oss +alibaba-ots +alibaba-sls alibaba-sms amqp arangodb diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/alibaba-ots.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/alibaba-ots.json new file mode 100644 index 0000000000000..4942723cda505 --- /dev/null +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/alibaba-ots.json @@ -0,0 +1,46 @@ +{ + "component": { + "kind": "component", + "name": "alibaba-ots", + "title": "Alibaba Tablestore (OTS)", + "description": "Perform row operations on Alibaba Cloud Tablestore (OTS).", + "deprecated": false, + "firstVersion": "4.23.0", + "label": "cloud,database", + "javaType": "org.apache.camel.component.alibaba.ots.AlibabaOtsComponent", + "supportLevel": "Preview", + "groupId": "org.apache.camel", + "artifactId": "camel-alibaba-ots", + "version": "4.23.0-SNAPSHOT", + "scheme": "alibaba-ots", + "extendsScheme": "", + "syntax": "alibaba-ots:operation", + "async": false, + "api": false, + "consumerOnly": false, + "producerOnly": true, + "lenientProperties": false, + "browsable": false, + "remote": true + }, + "componentProperties": { + "lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, + "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }, + "healthCheckConsumerEnabled": { "index": 2, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" }, + "healthCheckProducerEnabled": { "index": 3, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true." } + }, + "headers": { + "CamelAlibabaOtsOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Operation override", "constantName": "org.apache.camel.component.alibaba.ots.constants.AlibabaOtsHeaders#OPERATION" }, + "CamelAlibabaOtsRequestId": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Tablestore request id", "constantName": "org.apache.camel.component.alibaba.ots.constants.AlibabaOtsHeaders#REQUEST_ID" } + }, + "properties": { + "operation": { "index": 0, "kind": "path", "displayName": "Operation", "group": "producer", "label": "producer", "required": true, "type": "enum", "javaType": "java.lang.String", "enum": [ "putRow", "getRow", "updateRow", "deleteRow", "listTables" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Operation to perform" }, + "endpoint": { "index": 1, "kind": "parameter", "displayName": "Endpoint", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Tablestore endpoint URL" }, + "instanceName": { "index": 2, "kind": "parameter", "displayName": "Instance Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Tablestore instance name" }, + "lazyStartProducer": { "index": 3, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, + "otsClient": { "index": 4, "kind": "parameter", "displayName": "OTS Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.alicloud.openservices.tablestore.SyncClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "description": "Autowire an existing Tablestore client instance" }, + "accessKey": { "index": 5, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Access key for the cloud user" }, + "secretKey": { "index": 6, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Secret key for the cloud user" }, + "serviceKeys": { "index": 7, "kind": "parameter", "displayName": "Service Keys", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.component.alibaba.common.models.ServiceKeys", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Configuration object for cloud service authentication" } + } +} diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/alibaba-sls.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/alibaba-sls.json new file mode 100644 index 0000000000000..b4da0b72d0261 --- /dev/null +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/alibaba-sls.json @@ -0,0 +1,68 @@ +{ + "component": { + "kind": "component", + "name": "alibaba-sls", + "title": "Alibaba Simple Log Service (SLS)", + "description": "Manage logs on Alibaba Cloud Simple Log Service (SLS).", + "deprecated": false, + "firstVersion": "4.23.0", + "label": "cloud,monitoring", + "javaType": "org.apache.camel.component.alibaba.sls.AlibabaSlsComponent", + "supportLevel": "Preview", + "groupId": "org.apache.camel", + "artifactId": "camel-alibaba-sls", + "version": "4.23.0-SNAPSHOT", + "scheme": "alibaba-sls", + "extendsScheme": "", + "syntax": "alibaba-sls:operation", + "async": false, + "api": false, + "consumerOnly": false, + "producerOnly": true, + "lenientProperties": false, + "browsable": false, + "remote": true + }, + "componentProperties": { + "lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, + "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }, + "healthCheckConsumerEnabled": { "index": 2, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" }, + "healthCheckProducerEnabled": { "index": 3, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true." } + }, + "headers": { + "CamelAlibabaSlsProject": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "SLS project name override", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#PROJECT" }, + "CamelAlibabaSlsLogStoreName": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "SLS log store name override", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#LOG_STORE_NAME" }, + "CamelAlibabaSlsQuery": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Log query string override", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#QUERY" }, + "CamelAlibabaSlsFrom": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Query start time override (Unix timestamp in seconds)", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#FROM" }, + "CamelAlibabaSlsTo": { "index": 4, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Query end time override (Unix timestamp in seconds)", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#TO" }, + "CamelAlibabaSlsLine": { "index": 5, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Maximum number of log lines to return", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#LINE" }, + "CamelAlibabaSlsOffset": { "index": 6, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Log query offset", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#OFFSET" }, + "CamelAlibabaSlsTopic": { "index": 7, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Log topic filter override", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#TOPIC" }, + "CamelAlibabaSlsReverse": { "index": 8, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether to return logs in reverse order", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#REVERSE" }, + "CamelAlibabaSlsLogstoreName": { "index": 9, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Log store name prefix filter for listLogStores", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#LOGSTORE_NAME" }, + "CamelAlibabaSlsMode": { "index": 10, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "List mode for listLogStores", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#MODE" }, + "CamelAlibabaSlsSize": { "index": 11, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Page size for listLogStores", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#SIZE" }, + "CamelAlibabaSlsTelemetryType": { "index": 12, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Telemetry type filter for listLogStores", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#TELEMETRY_TYPE" }, + "CamelAlibabaSlsRequestId": { "index": 13, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Alibaba Cloud request id", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#REQUEST_ID" }, + "CamelAlibabaSlsStatusCode": { "index": 14, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "HTTP status code from SLS response", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#STATUS_CODE" } + }, + "properties": { + "operation": { "index": 0, "kind": "path", "displayName": "Operation", "group": "producer", "label": "producer", "required": true, "type": "enum", "javaType": "java.lang.String", "enum": [ "putLogs", "getLogs", "listLogStores" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Operation to perform" }, + "endpoint": { "index": 1, "kind": "parameter", "displayName": "Endpoint", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "SLS endpoint URL (e.g. cn-hangzhou.log.aliyuncs.com). Carries higher precedence than region based client initialization" }, + "logStoreName": { "index": 2, "kind": "parameter", "displayName": "Log Store Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "SLS log store name" }, + "project": { "index": 3, "kind": "parameter", "displayName": "Project", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "SLS project name" }, + "region": { "index": 4, "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Alibaba Cloud region" }, + "lazyStartProducer": { "index": 5, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, + "slsClient": { "index": 6, "kind": "parameter", "displayName": "SLS Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.aliyun.sls20201230.Client", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "description": "Autowire an existing SLS client instance" }, + "from": { "index": 7, "kind": "parameter", "displayName": "From", "group": "getLogs", "label": "getLogs", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Query start time for getLogs (Unix timestamp in seconds)" }, + "line": { "index": 8, "kind": "parameter", "displayName": "Line", "group": "getLogs", "label": "getLogs", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "autowired": false, "secret": false, "description": "Maximum number of log lines to return for getLogs" }, + "offset": { "index": 9, "kind": "parameter", "displayName": "Offset", "group": "getLogs", "label": "getLogs", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "autowired": false, "secret": false, "description": "Log query offset for getLogs" }, + "query": { "index": 10, "kind": "parameter", "displayName": "Query", "group": "getLogs", "label": "getLogs", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Log query string for getLogs" }, + "reverse": { "index": 11, "kind": "parameter", "displayName": "Reverse", "group": "getLogs", "label": "getLogs", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to return logs in reverse order for getLogs" }, + "to": { "index": 12, "kind": "parameter", "displayName": "To", "group": "getLogs", "label": "getLogs", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Query end time for getLogs (Unix timestamp in seconds)" }, + "topic": { "index": 13, "kind": "parameter", "displayName": "Topic", "group": "getLogs", "label": "getLogs", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Log topic filter for getLogs" }, + "accessKey": { "index": 14, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Access key for the cloud user" }, + "secretKey": { "index": 15, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Secret key for the cloud user" }, + "serviceKeys": { "index": 16, "kind": "parameter", "displayName": "Service Keys", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.component.alibaba.common.models.ServiceKeys", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Configuration object for cloud service authentication" } + } +} diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties index 8cd11c4a37add..b724bb81e5f57 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties @@ -13,6 +13,8 @@ alibaba-fc-component alibaba-kms-component alibaba-mns-component alibaba-oss-component +alibaba-ots-component +alibaba-sls-component alibaba-sms-component amqp-component arangodb-component diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/alibaba-ots-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/alibaba-ots-component.adoc new file mode 100644 index 0000000000000..083d4e2558cca --- /dev/null +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/alibaba-ots-component.adoc @@ -0,0 +1,73 @@ += Alibaba Tablestore (OTS) Component +:doctitle: Alibaba Tablestore (OTS) +:shortname: alibaba-ots +:artifactid: camel-alibaba-ots +:description: Perform row operations on Alibaba Cloud Tablestore (OTS). +:since: 4.23 +:supportlevel: Preview +:tabs-sync-option: +:component-header: Only producer is supported +//Manually maintained attributes +:group: Alibaba Cloud + +*Since Camel {since}* + +*{component-header}* + +The Alibaba Cloud Tablestore (OTS) component allows you to perform row operations against a Tablestore instance using the native Tablestore SDK. + +Maven users will need to add the following dependency to their `pom.xml` +for this component: + +[source,xml] +---- + + org.apache.camel + camel-alibaba-ots + x.x.x + + +---- + +== URI format + +[source] +---- +alibaba-ots:operation[?options] +---- + +// component options: START +include::partial$component-configure-options.adoc[] +include::partial$component-endpoint-options.adoc[] +include::partial$component-endpoint-headers.adoc[] +// component options: END + +== Usage + +=== Operations + +The component supports the following operations: + +* `putRow` - insert a row (producer) +* `getRow` - read a row (producer) +* `updateRow` - update a row (producer) +* `deleteRow` - delete a row (producer) +* `listTables` - list tables in the instance (producer) + +For row operations, the exchange body must be the corresponding Tablestore SDK request type (`PutRowRequest`, `GetRowRequest`, `UpdateRowRequest`, or `DeleteRowRequest`). The `listTables` operation does not require a message body. + +=== Producer example + +[source,java] +---- +from("direct:start") + .process(exchange -> { + PutRowRequest request = new PutRowRequest(new RowPutChange("my-table", primaryKey)); + exchange.getMessage().setBody(request); + }) + .to("alibaba-ots:putRow?endpoint=https://my-instance.cn-hangzhou.ots.aliyuncs.com&instanceName=my-instance&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); +---- + +== Examples + +For more examples, see the unit tests in the `camel-alibaba-ots` module. diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/alibaba-sls-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/alibaba-sls-component.adoc new file mode 100644 index 0000000000000..267b8d77c1152 --- /dev/null +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/alibaba-sls-component.adoc @@ -0,0 +1,87 @@ += Alibaba Simple Log Service (SLS) Component +:doctitle: Alibaba Simple Log Service (SLS) +:shortname: alibaba-sls +:artifactid: camel-alibaba-sls +:description: Manage logs on Alibaba Cloud Simple Log Service (SLS). +:since: 4.23 +:supportlevel: Preview +:tabs-sync-option: +:component-header: Only producer is supported +//Manually maintained attributes +:group: Alibaba Cloud + +*Since Camel {since}* + +*{component-header}* + +The Alibaba Cloud Simple Log Service (SLS) component allows you to write logs, query logs and list log stores. + +Maven users will need to add the following dependency to their `pom.xml` +for this component: + +[source,xml] +---- + + org.apache.camel + camel-alibaba-sls + x.x.x + + +---- + +== URI format + +[source] +---- +alibaba-sls:operation[?options] +---- + +// component options: START +include::partial$component-configure-options.adoc[] +include::partial$component-endpoint-options.adoc[] +include::partial$component-endpoint-headers.adoc[] +// component options: END + +== Usage + +=== Operations + +The component supports the following operations: + +* `putLogs` - write a log group to a log store (producer) +* `getLogs` - query logs from a log store (producer) +* `listLogStores` - list log stores in a project (producer) + +=== Producer examples + +Put logs: + +[source,java] +---- +from("direct:start") + .setBody(simple("${body}")) + .to("alibaba-sls:putLogs?project=my-project&logStoreName=my-logstore®ion=cn-hangzhou&endpoint=cn-hangzhou.log.aliyuncs.com&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); +---- + +Query logs: + +[source,java] +---- +from("direct:start") + .setHeader("CamelAlibabaSlsQuery", constant("*")) + .setHeader("CamelAlibabaSlsFrom", constant(1700000000)) + .setHeader("CamelAlibabaSlsTo", constant(1700003600)) + .to("alibaba-sls:getLogs?project=my-project&logStoreName=my-logstore®ion=cn-hangzhou&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); +---- + +List log stores: + +[source,java] +---- +from("direct:start") + .to("alibaba-sls:listLogStores?project=my-project®ion=cn-hangzhou&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); +---- + +== Examples + +For more examples, see the unit tests in the `camel-alibaba-sls` module. diff --git a/components/camel-alibaba/camel-alibaba-ots/pom.xml b/components/camel-alibaba/camel-alibaba-ots/pom.xml new file mode 100644 index 0000000000000..f9f45430bb0c0 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/pom.xml @@ -0,0 +1,76 @@ + + + + + 4.0.0 + + + org.apache.camel + camel-alibaba-parent + 4.23.0-SNAPSHOT + + + + 4.23.0 + + + camel-alibaba-ots + jar + Camel :: Alibaba Cloud :: Tablestore (OTS) + Camel Alibaba Cloud Tablestore (OTS) component + + + + org.apache.camel + camel-support + + + + org.apache.camel + camel-alibaba-common + ${project.version} + + + + com.aliyun.openservices + tablestore + + + + org.apache.camel + camel-test-junit6 + test + + + + org.assertj + assertj-core + test + + + + org.mockito + mockito-core + ${mockito-version} + test + + + + diff --git a/components/camel-alibaba/camel-alibaba-ots/src/generated/java/org/apache/camel/component/alibaba/ots/AlibabaOtsComponentConfigurer.java b/components/camel-alibaba/camel-alibaba-ots/src/generated/java/org/apache/camel/component/alibaba/ots/AlibabaOtsComponentConfigurer.java new file mode 100644 index 0000000000000..89e5df97b3aff --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/generated/java/org/apache/camel/component/alibaba/ots/AlibabaOtsComponentConfigurer.java @@ -0,0 +1,69 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.alibaba.ots; + +import javax.annotation.processing.Generated; +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.spi.ConfigurerStrategy; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.support.component.PropertyConfigurerSupport; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo") +@SuppressWarnings("unchecked") +public class AlibabaOtsComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + AlibabaOtsComponent target = (AlibabaOtsComponent) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "autowiredenabled": + case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true; + case "healthcheckconsumerenabled": + case "healthCheckConsumerEnabled": target.setHealthCheckConsumerEnabled(property(camelContext, boolean.class, value)); return true; + case "healthcheckproducerenabled": + case "healthCheckProducerEnabled": target.setHealthCheckProducerEnabled(property(camelContext, boolean.class, value)); return true; + case "lazystartproducer": + case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; + default: return false; + } + } + + @Override + public Class getOptionType(String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "autowiredenabled": + case "autowiredEnabled": return boolean.class; + case "healthcheckconsumerenabled": + case "healthCheckConsumerEnabled": return boolean.class; + case "healthcheckproducerenabled": + case "healthCheckProducerEnabled": return boolean.class; + case "lazystartproducer": + case "lazyStartProducer": return boolean.class; + default: return null; + } + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + AlibabaOtsComponent target = (AlibabaOtsComponent) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "autowiredenabled": + case "autowiredEnabled": return target.isAutowiredEnabled(); + case "healthcheckconsumerenabled": + case "healthCheckConsumerEnabled": return target.isHealthCheckConsumerEnabled(); + case "healthcheckproducerenabled": + case "healthCheckProducerEnabled": return target.isHealthCheckProducerEnabled(); + case "lazystartproducer": + case "lazyStartProducer": return target.isLazyStartProducer(); + default: return null; + } + } +} + diff --git a/components/camel-alibaba/camel-alibaba-ots/src/generated/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpointConfigurer.java b/components/camel-alibaba/camel-alibaba-ots/src/generated/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpointConfigurer.java new file mode 100644 index 0000000000000..d799920d26f50 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/generated/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpointConfigurer.java @@ -0,0 +1,89 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.alibaba.ots; + +import javax.annotation.processing.Generated; +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.spi.ConfigurerStrategy; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.support.component.PropertyConfigurerSupport; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo") +@SuppressWarnings("unchecked") +public class AlibabaOtsEndpointConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + AlibabaOtsEndpoint target = (AlibabaOtsEndpoint) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "accesskey": + case "accessKey": target.setAccessKey(property(camelContext, java.lang.String.class, value)); return true; + case "endpoint": target.setEndpoint(property(camelContext, java.lang.String.class, value)); return true; + case "instancename": + case "instanceName": target.setInstanceName(property(camelContext, java.lang.String.class, value)); return true; + case "lazystartproducer": + case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; + case "otsclient": + case "otsClient": target.setOtsClient(property(camelContext, com.alicloud.openservices.tablestore.SyncClient.class, value)); return true; + case "secretkey": + case "secretKey": target.setSecretKey(property(camelContext, java.lang.String.class, value)); return true; + case "servicekeys": + case "serviceKeys": target.setServiceKeys(property(camelContext, org.apache.camel.component.alibaba.common.models.ServiceKeys.class, value)); return true; + default: return false; + } + } + + @Override + public String[] getAutowiredNames() { + return new String[]{"otsClient"}; + } + + @Override + public Class getOptionType(String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "accesskey": + case "accessKey": return java.lang.String.class; + case "endpoint": return java.lang.String.class; + case "instancename": + case "instanceName": return java.lang.String.class; + case "lazystartproducer": + case "lazyStartProducer": return boolean.class; + case "otsclient": + case "otsClient": return com.alicloud.openservices.tablestore.SyncClient.class; + case "secretkey": + case "secretKey": return java.lang.String.class; + case "servicekeys": + case "serviceKeys": return org.apache.camel.component.alibaba.common.models.ServiceKeys.class; + default: return null; + } + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + AlibabaOtsEndpoint target = (AlibabaOtsEndpoint) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "accesskey": + case "accessKey": return target.getAccessKey(); + case "endpoint": return target.getEndpoint(); + case "instancename": + case "instanceName": return target.getInstanceName(); + case "lazystartproducer": + case "lazyStartProducer": return target.isLazyStartProducer(); + case "otsclient": + case "otsClient": return target.getOtsClient(); + case "secretkey": + case "secretKey": return target.getSecretKey(); + case "servicekeys": + case "serviceKeys": return target.getServiceKeys(); + default: return null; + } + } +} + diff --git a/components/camel-alibaba/camel-alibaba-ots/src/generated/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpointUriFactory.java b/components/camel-alibaba/camel-alibaba-ots/src/generated/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpointUriFactory.java new file mode 100644 index 0000000000000..4fd264b7f9682 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/generated/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpointUriFactory.java @@ -0,0 +1,88 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.alibaba.ots; + +import javax.annotation.processing.Generated; +import java.net.URISyntaxException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.camel.spi.EndpointUriFactory; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.GenerateEndpointUriFactoryMojo") +public class AlibabaOtsEndpointUriFactory extends org.apache.camel.support.component.EndpointUriFactorySupport implements EndpointUriFactory { + + private static final String BASE = ":operation"; + + private static final Set PROPERTY_NAMES; + private static final Set SECRET_PROPERTY_NAMES; + private static final Set ENDPOINT_IDENTITY_PROPERTY_NAMES; + private static final Map MULTI_VALUE_PREFIXES; + static { + Set props = new HashSet<>(8); + props.add("accessKey"); + props.add("endpoint"); + props.add("instanceName"); + props.add("lazyStartProducer"); + props.add("operation"); + props.add("otsClient"); + props.add("secretKey"); + props.add("serviceKeys"); + PROPERTY_NAMES = Collections.unmodifiableSet(props); + Set secretProps = new HashSet<>(3); + secretProps.add("accessKey"); + secretProps.add("secretKey"); + secretProps.add("serviceKeys"); + SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps); + ENDPOINT_IDENTITY_PROPERTY_NAMES = Collections.emptySet(); + MULTI_VALUE_PREFIXES = Collections.emptyMap(); + } + + @Override + public boolean isEnabled(String scheme) { + return "alibaba-ots".equals(scheme); + } + + @Override + public String buildUri(String scheme, Map properties, boolean encode) throws URISyntaxException { + String syntax = scheme + BASE; + String uri = syntax; + + Map copy = new HashMap<>(properties); + + uri = buildPathParameter(syntax, uri, "operation", null, true, copy); + uri = buildQueryParameters(uri, copy, encode); + return uri; + } + + @Override + public Set propertyNames() { + return PROPERTY_NAMES; + } + + @Override + public Set secretPropertyNames() { + return SECRET_PROPERTY_NAMES; + } + + @Override + public Set endpointIdentityPropertyNames() { + return ENDPOINT_IDENTITY_PROPERTY_NAMES; + } + + @Override + public Map multiValuePrefixes() { + return MULTI_VALUE_PREFIXES; + } + + @Override + public boolean isLenientProperties() { + return false; + } +} + diff --git a/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/org/apache/camel/component/alibaba/ots/alibaba-ots.json b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/org/apache/camel/component/alibaba/ots/alibaba-ots.json new file mode 100644 index 0000000000000..4942723cda505 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/org/apache/camel/component/alibaba/ots/alibaba-ots.json @@ -0,0 +1,46 @@ +{ + "component": { + "kind": "component", + "name": "alibaba-ots", + "title": "Alibaba Tablestore (OTS)", + "description": "Perform row operations on Alibaba Cloud Tablestore (OTS).", + "deprecated": false, + "firstVersion": "4.23.0", + "label": "cloud,database", + "javaType": "org.apache.camel.component.alibaba.ots.AlibabaOtsComponent", + "supportLevel": "Preview", + "groupId": "org.apache.camel", + "artifactId": "camel-alibaba-ots", + "version": "4.23.0-SNAPSHOT", + "scheme": "alibaba-ots", + "extendsScheme": "", + "syntax": "alibaba-ots:operation", + "async": false, + "api": false, + "consumerOnly": false, + "producerOnly": true, + "lenientProperties": false, + "browsable": false, + "remote": true + }, + "componentProperties": { + "lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, + "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }, + "healthCheckConsumerEnabled": { "index": 2, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" }, + "healthCheckProducerEnabled": { "index": 3, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true." } + }, + "headers": { + "CamelAlibabaOtsOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Operation override", "constantName": "org.apache.camel.component.alibaba.ots.constants.AlibabaOtsHeaders#OPERATION" }, + "CamelAlibabaOtsRequestId": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Tablestore request id", "constantName": "org.apache.camel.component.alibaba.ots.constants.AlibabaOtsHeaders#REQUEST_ID" } + }, + "properties": { + "operation": { "index": 0, "kind": "path", "displayName": "Operation", "group": "producer", "label": "producer", "required": true, "type": "enum", "javaType": "java.lang.String", "enum": [ "putRow", "getRow", "updateRow", "deleteRow", "listTables" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Operation to perform" }, + "endpoint": { "index": 1, "kind": "parameter", "displayName": "Endpoint", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Tablestore endpoint URL" }, + "instanceName": { "index": 2, "kind": "parameter", "displayName": "Instance Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Tablestore instance name" }, + "lazyStartProducer": { "index": 3, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, + "otsClient": { "index": 4, "kind": "parameter", "displayName": "OTS Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.alicloud.openservices.tablestore.SyncClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "description": "Autowire an existing Tablestore client instance" }, + "accessKey": { "index": 5, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Access key for the cloud user" }, + "secretKey": { "index": 6, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Secret key for the cloud user" }, + "serviceKeys": { "index": 7, "kind": "parameter", "displayName": "Service Keys", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.component.alibaba.common.models.ServiceKeys", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Configuration object for cloud service authentication" } + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/component.properties b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/component.properties new file mode 100644 index 0000000000000..00c62b232eecf --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/component.properties @@ -0,0 +1,7 @@ +# Generated by camel build tools - do NOT edit this file! +components=alibaba-ots +groupId=org.apache.camel +artifactId=camel-alibaba-ots +version=4.23.0-SNAPSHOT +projectName=Camel :: Alibaba Cloud :: Tablestore (OTS) +projectDescription=Camel Alibaba Cloud Tablestore (OTS) component diff --git a/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/component/alibaba-ots b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/component/alibaba-ots new file mode 100644 index 0000000000000..7e209d1d751bb --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/component/alibaba-ots @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.alibaba.ots.AlibabaOtsComponent diff --git a/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-ots-component b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-ots-component new file mode 100644 index 0000000000000..5abe1bb3f501f --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-ots-component @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.alibaba.ots.AlibabaOtsComponentConfigurer diff --git a/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-ots-endpoint b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-ots-endpoint new file mode 100644 index 0000000000000..069fba5c93e30 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-ots-endpoint @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.alibaba.ots.AlibabaOtsEndpointConfigurer diff --git a/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/urifactory/alibaba-ots-endpoint b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/urifactory/alibaba-ots-endpoint new file mode 100644 index 0000000000000..416d98816211c --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/services/org/apache/camel/urifactory/alibaba-ots-endpoint @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.alibaba.ots.AlibabaOtsEndpointUriFactory diff --git a/components/camel-alibaba/camel-alibaba-ots/src/main/docs/alibaba-ots-component.adoc b/components/camel-alibaba/camel-alibaba-ots/src/main/docs/alibaba-ots-component.adoc new file mode 100644 index 0000000000000..083d4e2558cca --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/main/docs/alibaba-ots-component.adoc @@ -0,0 +1,73 @@ += Alibaba Tablestore (OTS) Component +:doctitle: Alibaba Tablestore (OTS) +:shortname: alibaba-ots +:artifactid: camel-alibaba-ots +:description: Perform row operations on Alibaba Cloud Tablestore (OTS). +:since: 4.23 +:supportlevel: Preview +:tabs-sync-option: +:component-header: Only producer is supported +//Manually maintained attributes +:group: Alibaba Cloud + +*Since Camel {since}* + +*{component-header}* + +The Alibaba Cloud Tablestore (OTS) component allows you to perform row operations against a Tablestore instance using the native Tablestore SDK. + +Maven users will need to add the following dependency to their `pom.xml` +for this component: + +[source,xml] +---- + + org.apache.camel + camel-alibaba-ots + x.x.x + + +---- + +== URI format + +[source] +---- +alibaba-ots:operation[?options] +---- + +// component options: START +include::partial$component-configure-options.adoc[] +include::partial$component-endpoint-options.adoc[] +include::partial$component-endpoint-headers.adoc[] +// component options: END + +== Usage + +=== Operations + +The component supports the following operations: + +* `putRow` - insert a row (producer) +* `getRow` - read a row (producer) +* `updateRow` - update a row (producer) +* `deleteRow` - delete a row (producer) +* `listTables` - list tables in the instance (producer) + +For row operations, the exchange body must be the corresponding Tablestore SDK request type (`PutRowRequest`, `GetRowRequest`, `UpdateRowRequest`, or `DeleteRowRequest`). The `listTables` operation does not require a message body. + +=== Producer example + +[source,java] +---- +from("direct:start") + .process(exchange -> { + PutRowRequest request = new PutRowRequest(new RowPutChange("my-table", primaryKey)); + exchange.getMessage().setBody(request); + }) + .to("alibaba-ots:putRow?endpoint=https://my-instance.cn-hangzhou.ots.aliyuncs.com&instanceName=my-instance&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); +---- + +== Examples + +For more examples, see the unit tests in the `camel-alibaba-ots` module. diff --git a/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsComponent.java b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsComponent.java new file mode 100644 index 0000000000000..ef4300d3320b0 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsComponent.java @@ -0,0 +1,34 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import java.util.Map; + +import org.apache.camel.Endpoint; +import org.apache.camel.spi.annotations.Component; +import org.apache.camel.support.HealthCheckComponent; + +@Component("alibaba-ots") +public class AlibabaOtsComponent extends HealthCheckComponent { + + @Override + protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { + AlibabaOtsEndpoint endpoint = new AlibabaOtsEndpoint(uri, remaining, this); + setProperties(endpoint, parameters); + return endpoint; + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpoint.java b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpoint.java new file mode 100644 index 0000000000000..73089a331dadc --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpoint.java @@ -0,0 +1,163 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import com.alicloud.openservices.tablestore.SyncClient; +import org.apache.camel.Category; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.alibaba.common.models.ServiceKeys; +import org.apache.camel.component.alibaba.ots.constants.AlibabaOtsHeaders; +import org.apache.camel.spi.Metadata; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriPath; +import org.apache.camel.support.DefaultEndpoint; + +/** + * Perform row operations on Alibaba Cloud Tablestore (OTS). + */ +@UriEndpoint(firstVersion = "4.23.0", scheme = "alibaba-ots", title = "Alibaba Tablestore (OTS)", + syntax = "alibaba-ots:operation", category = { Category.CLOUD, Category.DATABASE }, + headersClass = AlibabaOtsHeaders.class, producerOnly = true) +public class AlibabaOtsEndpoint extends DefaultEndpoint { + + @UriPath(description = "Operation to perform", displayName = "Operation", label = "producer", + enums = "putRow,getRow,updateRow,deleteRow,listTables") + @Metadata(required = true) + private String operation; + + @UriParam(description = "Tablestore endpoint URL", displayName = "Endpoint") + @Metadata(required = true) + private String endpoint; + + @UriParam(description = "Tablestore instance name", displayName = "Instance Name") + @Metadata(required = true) + private String instanceName; + + @UriParam(description = "Access key for the cloud user", displayName = "Access Key", + secret = true, security = "secret", label = "security") + private String accessKey; + + @UriParam(description = "Secret key for the cloud user", displayName = "Secret Key", + secret = true, security = "secret", label = "security") + private String secretKey; + + @UriParam(description = "Configuration object for cloud service authentication", displayName = "Service Keys", + secret = true, security = "secret", label = "security") + private ServiceKeys serviceKeys; + + @UriParam(description = "Autowire an existing Tablestore client instance", displayName = "OTS Client", + label = "advanced") + @Metadata(autowired = true) + private SyncClient otsClient; + + private boolean autowiredOtsClient; + + public AlibabaOtsEndpoint() { + } + + public AlibabaOtsEndpoint(String uri, String operation, AlibabaOtsComponent component) { + super(uri, component); + this.operation = operation; + } + + @Override + public Producer createProducer() throws Exception { + return new AlibabaOtsProducer(this); + } + + @Override + public Consumer createConsumer(Processor processor) throws Exception { + throw new UnsupportedOperationException("You cannot consume from this endpoint"); + } + + public SyncClient initClient() throws Exception { + if (otsClient != null) { + return otsClient; + } + otsClient = AlibabaOtsUtils.createClient(this); + return otsClient; + } + + @Override + protected void doStop() throws Exception { + if (otsClient != null && !autowiredOtsClient) { + otsClient.shutdown(); + otsClient = null; + } + super.doStop(); + } + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getAccessKey() { + return accessKey; + } + + public void setAccessKey(String accessKey) { + this.accessKey = accessKey; + } + + public String getSecretKey() { + return secretKey; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + + public ServiceKeys getServiceKeys() { + return serviceKeys; + } + + public void setServiceKeys(ServiceKeys serviceKeys) { + this.serviceKeys = serviceKeys; + } + + public SyncClient getOtsClient() { + return otsClient; + } + + public void setOtsClient(SyncClient otsClient) { + this.otsClient = otsClient; + this.autowiredOtsClient = otsClient != null; + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsProducer.java b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsProducer.java new file mode 100644 index 0000000000000..519dd4558aec6 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsProducer.java @@ -0,0 +1,102 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import com.alicloud.openservices.tablestore.SyncClient; +import com.alicloud.openservices.tablestore.model.DeleteRowRequest; +import com.alicloud.openservices.tablestore.model.GetRowRequest; +import com.alicloud.openservices.tablestore.model.PutRowRequest; +import com.alicloud.openservices.tablestore.model.UpdateRowRequest; +import org.apache.camel.Exchange; +import org.apache.camel.component.alibaba.ots.constants.AlibabaOtsHeaders; +import org.apache.camel.component.alibaba.ots.constants.AlibabaOtsOperations; +import org.apache.camel.component.alibaba.ots.models.ClientConfigurations; +import org.apache.camel.support.DefaultProducer; +import org.apache.camel.util.ObjectHelper; + +public class AlibabaOtsProducer extends DefaultProducer { + + public AlibabaOtsProducer(AlibabaOtsEndpoint endpoint) { + super(endpoint); + } + + @Override + public void process(Exchange exchange) throws Exception { + AlibabaOtsEndpoint endpoint = getEndpoint(); + ClientConfigurations configuration = AlibabaOtsUtils.createClientConfigurations(endpoint, exchange); + + if (ObjectHelper.isEmpty(configuration.getOperation())) { + throw new IllegalArgumentException("Operation name not found"); + } + + SyncClient otsClient = endpoint.initClient(); + + switch (configuration.getOperation()) { + case AlibabaOtsOperations.PUT_ROW -> putRow(exchange, otsClient); + case AlibabaOtsOperations.GET_ROW -> getRow(exchange, otsClient); + case AlibabaOtsOperations.UPDATE_ROW -> updateRow(exchange, otsClient); + case AlibabaOtsOperations.DELETE_ROW -> deleteRow(exchange, otsClient); + case AlibabaOtsOperations.LIST_TABLES -> listTables(exchange, otsClient); + default -> throw new UnsupportedOperationException("Unsupported operation: " + configuration.getOperation()); + } + } + + private void putRow(Exchange exchange, SyncClient otsClient) throws Exception { + PutRowRequest request = exchange.getMessage().getMandatoryBody(PutRowRequest.class); + var response = otsClient.putRow(request); + exchange.getMessage().setBody(AlibabaOtsUtils.toPutRowMap(response)); + setResponseHeaders(exchange, response.getRequestId()); + } + + private void getRow(Exchange exchange, SyncClient otsClient) throws Exception { + GetRowRequest request = exchange.getMessage().getMandatoryBody(GetRowRequest.class); + var response = otsClient.getRow(request); + exchange.getMessage().setBody(AlibabaOtsUtils.toGetRowMap(response)); + setResponseHeaders(exchange, response.getRequestId()); + } + + private void updateRow(Exchange exchange, SyncClient otsClient) throws Exception { + UpdateRowRequest request = exchange.getMessage().getMandatoryBody(UpdateRowRequest.class); + var response = otsClient.updateRow(request); + exchange.getMessage().setBody(AlibabaOtsUtils.toUpdateRowMap(response)); + setResponseHeaders(exchange, response.getRequestId()); + } + + private void deleteRow(Exchange exchange, SyncClient otsClient) throws Exception { + DeleteRowRequest request = exchange.getMessage().getMandatoryBody(DeleteRowRequest.class); + var response = otsClient.deleteRow(request); + exchange.getMessage().setBody(AlibabaOtsUtils.toDeleteRowMap(response)); + setResponseHeaders(exchange, response.getRequestId()); + } + + private void listTables(Exchange exchange, SyncClient otsClient) throws Exception { + var response = otsClient.listTable(); + exchange.getMessage().setBody(AlibabaOtsUtils.toListTablesBody(response)); + setResponseHeaders(exchange, response.getRequestId()); + } + + private void setResponseHeaders(Exchange exchange, String requestId) { + if (ObjectHelper.isNotEmpty(requestId)) { + exchange.getMessage().setHeader(AlibabaOtsHeaders.REQUEST_ID, requestId); + } + } + + @Override + public AlibabaOtsEndpoint getEndpoint() { + return (AlibabaOtsEndpoint) super.getEndpoint(); + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsUtils.java b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsUtils.java new file mode 100644 index 0000000000000..5b22737f1ab16 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/AlibabaOtsUtils.java @@ -0,0 +1,168 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import java.util.ArrayList; +import java.util.Base64; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.alicloud.openservices.tablestore.SyncClient; +import com.alicloud.openservices.tablestore.model.CapacityUnit; +import com.alicloud.openservices.tablestore.model.Column; +import com.alicloud.openservices.tablestore.model.ConsumedCapacity; +import com.alicloud.openservices.tablestore.model.DeleteRowResponse; +import com.alicloud.openservices.tablestore.model.GetRowResponse; +import com.alicloud.openservices.tablestore.model.ListTableResponse; +import com.alicloud.openservices.tablestore.model.PrimaryKey; +import com.alicloud.openservices.tablestore.model.PrimaryKeyColumn; +import com.alicloud.openservices.tablestore.model.PutRowResponse; +import com.alicloud.openservices.tablestore.model.Response; +import com.alicloud.openservices.tablestore.model.Row; +import com.alicloud.openservices.tablestore.model.UpdateRowResponse; +import org.apache.camel.Exchange; +import org.apache.camel.component.alibaba.common.OpenApiClientSupport; +import org.apache.camel.component.alibaba.ots.constants.AlibabaOtsProperties; +import org.apache.camel.component.alibaba.ots.models.ClientConfigurations; +import org.apache.camel.util.ObjectHelper; + +public final class AlibabaOtsUtils { + + private AlibabaOtsUtils() { + } + + public static SyncClient createClient(AlibabaOtsEndpoint endpoint) { + if (ObjectHelper.isEmpty(endpoint.getEndpoint())) { + throw new IllegalArgumentException("Endpoint is required"); + } + if (ObjectHelper.isEmpty(endpoint.getInstanceName())) { + throw new IllegalArgumentException("Instance name is required"); + } + + return new SyncClient( + endpoint.getEndpoint(), + OpenApiClientSupport.resolveAccessKey(endpoint.getAccessKey(), endpoint.getServiceKeys()), + OpenApiClientSupport.resolveSecretKey(endpoint.getSecretKey(), endpoint.getServiceKeys()), + endpoint.getInstanceName()); + } + + public static ClientConfigurations createClientConfigurations(AlibabaOtsEndpoint endpoint, Exchange exchange) { + ClientConfigurations configuration = new ClientConfigurations(); + configuration.setOperation( + OpenApiClientSupport.resolveString(exchange, AlibabaOtsProperties.OPERATION, endpoint.getOperation())); + return configuration; + } + + public static List toListTablesBody(ListTableResponse response) { + if (response.getTableNames() == null) { + return List.of(); + } + return new ArrayList<>(response.getTableNames()); + } + + public static Map toPutRowMap(PutRowResponse response) { + Map map = new HashMap<>(); + addCommonResponseFields(map, response); + addConsumedCapacity(map, response.getConsumedCapacity()); + addRow(map, response.getRow()); + return map; + } + + public static Map toGetRowMap(GetRowResponse response) { + Map map = new HashMap<>(); + addCommonResponseFields(map, response); + addConsumedCapacity(map, response.getConsumedCapacity()); + addRow(map, response.getRow()); + if (response.hasNextToken()) { + map.put("nextToken", Base64.getEncoder().encodeToString(response.getNextToken())); + } + return map; + } + + public static Map toUpdateRowMap(UpdateRowResponse response) { + Map map = new HashMap<>(); + addCommonResponseFields(map, response); + addConsumedCapacity(map, response.getConsumedCapacity()); + addRow(map, response.getRow()); + return map; + } + + public static Map toDeleteRowMap(DeleteRowResponse response) { + Map map = new HashMap<>(); + addCommonResponseFields(map, response); + addConsumedCapacity(map, response.getConsumedCapacity()); + addRow(map, response.getRow()); + return map; + } + + private static void addCommonResponseFields(Map map, Response response) { + map.put("requestId", response.getRequestId()); + map.put("traceId", response.getTraceId()); + } + + private static void addConsumedCapacity(Map map, ConsumedCapacity consumedCapacity) { + if (consumedCapacity == null) { + return; + } + Map capacityMap = new HashMap<>(); + CapacityUnit capacityUnit = consumedCapacity.getCapacityUnit(); + if (capacityUnit != null) { + capacityMap.put("readCapacityUnit", capacityUnit.getReadCapacityUnit()); + capacityMap.put("writeCapacityUnit", capacityUnit.getWriteCapacityUnit()); + } + map.put("consumedCapacity", capacityMap); + } + + private static void addRow(Map map, Row row) { + if (row == null) { + return; + } + Map rowMap = new HashMap<>(); + rowMap.put("primaryKey", toPrimaryKeyMap(row.getPrimaryKey())); + rowMap.put("columns", toColumnsList(row.getColumns())); + map.put("row", rowMap); + } + + private static Map toPrimaryKeyMap(PrimaryKey primaryKey) { + Map primaryKeyMap = new HashMap<>(); + if (primaryKey == null || primaryKey.isEmpty()) { + return primaryKeyMap; + } + for (PrimaryKeyColumn column : primaryKey.getPrimaryKeyColumns()) { + primaryKeyMap.put(column.getName(), column.getValue().toString()); + } + return primaryKeyMap; + } + + private static List> toColumnsList(Column[] columns) { + List> columnsList = new ArrayList<>(); + if (columns == null) { + return columnsList; + } + for (Column column : columns) { + Map columnMap = new HashMap<>(); + columnMap.put("name", column.getName()); + columnMap.put("value", column.getValue().toString()); + if (column.hasSetTimestamp()) { + columnMap.put("timestamp", column.getTimestamp()); + } + columnsList.add(columnMap); + } + return columnsList; + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsHeaders.java b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsHeaders.java new file mode 100644 index 0000000000000..c3ea1996ce96b --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsHeaders.java @@ -0,0 +1,31 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots.constants; + +import org.apache.camel.spi.Metadata; + +public final class AlibabaOtsHeaders { + + @Metadata(label = "producer", description = "Operation override", javaType = "String") + public static final String OPERATION = AlibabaOtsProperties.OPERATION; + + @Metadata(label = "producer", description = "Tablestore request id", javaType = "String") + public static final String REQUEST_ID = AlibabaOtsProperties.REQUEST_ID; + + private AlibabaOtsHeaders() { + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsOperations.java b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsOperations.java new file mode 100644 index 0000000000000..bd610fca6ac2d --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsOperations.java @@ -0,0 +1,29 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots.constants; + +public final class AlibabaOtsOperations { + + public static final String PUT_ROW = "putRow"; + public static final String GET_ROW = "getRow"; + public static final String UPDATE_ROW = "updateRow"; + public static final String DELETE_ROW = "deleteRow"; + public static final String LIST_TABLES = "listTables"; + + private AlibabaOtsOperations() { + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsProperties.java b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsProperties.java new file mode 100644 index 0000000000000..55ab325cf20a1 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsProperties.java @@ -0,0 +1,31 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots.constants; + +import org.apache.camel.spi.Metadata; + +public final class AlibabaOtsProperties { + + @Metadata(label = "producer", description = "Operation to perform", javaType = "String") + public static final String OPERATION = "CamelAlibabaOtsOperation"; + + @Metadata(label = "producer", description = "Request id returned by Tablestore", javaType = "String") + public static final String REQUEST_ID = "CamelAlibabaOtsRequestId"; + + private AlibabaOtsProperties() { + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/models/ClientConfigurations.java b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/models/ClientConfigurations.java new file mode 100644 index 0000000000000..ab33bd55df825 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/main/java/org/apache/camel/component/alibaba/ots/models/ClientConfigurations.java @@ -0,0 +1,30 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots.models; + +public class ClientConfigurations { + + private String operation; + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpointTest.java b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpointTest.java new file mode 100644 index 0000000000000..76a9ead32c03f --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/AlibabaOtsEndpointTest.java @@ -0,0 +1,70 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import com.alicloud.openservices.tablestore.SyncClient; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + +class AlibabaOtsEndpointTest { + + @Test + void initClientReturnsCachedInstance() throws Exception { + AlibabaOtsEndpoint endpoint = new AlibabaOtsEndpoint(); + SyncClient client = mock(SyncClient.class); + endpoint.setOtsClient(client); + + SyncClient first = endpoint.initClient(); + SyncClient second = endpoint.initClient(); + + assertThat(first).isSameAs(second).isSameAs(client); + } + + @Test + void doStopSkipsShutdownForAutowiredClient() throws Exception { + AlibabaOtsEndpoint endpoint = new AlibabaOtsEndpoint(); + SyncClient client = mock(SyncClient.class); + endpoint.setOtsClient(client); + + endpoint.doStop(); + + verify(client, never()).shutdown(); + } + + @Test + void doStopShutsDownOwnedClient() throws Exception { + AlibabaOtsEndpoint endpoint = new AlibabaOtsEndpoint(); + SyncClient client = mock(SyncClient.class); + + var clientField = AlibabaOtsEndpoint.class.getDeclaredField("otsClient"); + clientField.setAccessible(true); + clientField.set(endpoint, client); + + var autowiredField = AlibabaOtsEndpoint.class.getDeclaredField("autowiredOtsClient"); + autowiredField.setAccessible(true); + autowiredField.setBoolean(endpoint, false); + + endpoint.doStop(); + + verify(client).shutdown(); + assertThat(endpoint.getOtsClient()).isNull(); + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/AlibabaOtsProducerTest.java b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/AlibabaOtsProducerTest.java new file mode 100644 index 0000000000000..a55be7fff34e1 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/AlibabaOtsProducerTest.java @@ -0,0 +1,56 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import java.util.List; + +import com.alicloud.openservices.tablestore.SyncClient; +import com.alicloud.openservices.tablestore.model.ListTableResponse; +import com.alicloud.openservices.tablestore.model.Response; +import org.apache.camel.support.DefaultExchange; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class AlibabaOtsProducerTest extends CamelTestSupport { + + @Test + void processReinitializesClientFromEndpointOnEachExchange() throws Exception { + AlibabaOtsEndpoint endpoint = mock(AlibabaOtsEndpoint.class); + when(endpoint.getOperation()).thenReturn("listTables"); + when(endpoint.getCamelContext()).thenReturn(context); + + SyncClient firstClient = mock(SyncClient.class); + SyncClient secondClient = mock(SyncClient.class); + when(endpoint.initClient()).thenReturn(firstClient, secondClient); + + ListTableResponse response = new ListTableResponse(new Response("req-list")); + response.setTableNames(List.of("table-a")); + when(firstClient.listTable()).thenReturn(response); + when(secondClient.listTable()).thenReturn(response); + + AlibabaOtsProducer producer = new AlibabaOtsProducer(endpoint); + producer.process(new DefaultExchange(context)); + producer.process(new DefaultExchange(context)); + + verify(firstClient).listTable(); + verify(secondClient).listTable(); + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/DeleteRowTest.java b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/DeleteRowTest.java new file mode 100644 index 0000000000000..28b39e86f297e --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/DeleteRowTest.java @@ -0,0 +1,88 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import java.util.Map; + +import com.alicloud.openservices.tablestore.SyncClient; +import com.alicloud.openservices.tablestore.model.CapacityUnit; +import com.alicloud.openservices.tablestore.model.ConsumedCapacity; +import com.alicloud.openservices.tablestore.model.DeleteRowRequest; +import com.alicloud.openservices.tablestore.model.DeleteRowResponse; +import com.alicloud.openservices.tablestore.model.Response; +import org.apache.camel.BindToRegistry; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class DeleteRowTest extends CamelTestSupport { + + private final TestConfiguration testConfiguration = new TestConfiguration(); + + @BindToRegistry("otsClient") + SyncClient otsClient = mock(SyncClient.class); + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:deleteRow") + .to("alibaba-ots:deleteRow" + + "?endpoint=" + testConfiguration.getProperty("endpoint") + + "&instanceName=" + testConfiguration.getProperty("instanceName") + + "&accessKey=" + testConfiguration.getProperty("accessKey") + + "&secretKey=" + testConfiguration.getProperty("secretKey") + + "&otsClient=#otsClient") + .to("mock:result"); + } + }; + } + + @Test + void testDeleteRow() throws Exception { + DeleteRowResponse response = new DeleteRowResponse( + new Response("req-delete-row"), + null, + new ConsumedCapacity(new CapacityUnit(0, 1))); + + when(otsClient.deleteRow(any(DeleteRowRequest.class))).thenReturn(response); + + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + + DeleteRowRequest request = new DeleteRowRequest(); + template.sendBody("direct:deleteRow", request); + + mock.assertIsSatisfied(); + + Exchange exchange = mock.getExchanges().get(0); + assertThat(exchange.getMessage().getBody(Map.class)) + .containsEntry("requestId", "req-delete-row") + .containsKey("consumedCapacity"); + + verify(otsClient).deleteRow(any(DeleteRowRequest.class)); + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/GetRowTest.java b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/GetRowTest.java new file mode 100644 index 0000000000000..e07e365c758a6 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/GetRowTest.java @@ -0,0 +1,103 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import java.util.Map; + +import com.alicloud.openservices.tablestore.SyncClient; +import com.alicloud.openservices.tablestore.model.CapacityUnit; +import com.alicloud.openservices.tablestore.model.Column; +import com.alicloud.openservices.tablestore.model.ColumnValue; +import com.alicloud.openservices.tablestore.model.ConsumedCapacity; +import com.alicloud.openservices.tablestore.model.GetRowRequest; +import com.alicloud.openservices.tablestore.model.GetRowResponse; +import com.alicloud.openservices.tablestore.model.PrimaryKey; +import com.alicloud.openservices.tablestore.model.PrimaryKeyColumn; +import com.alicloud.openservices.tablestore.model.PrimaryKeyValue; +import com.alicloud.openservices.tablestore.model.Response; +import com.alicloud.openservices.tablestore.model.Row; +import org.apache.camel.BindToRegistry; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class GetRowTest extends CamelTestSupport { + + private final TestConfiguration testConfiguration = new TestConfiguration(); + + @BindToRegistry("otsClient") + SyncClient otsClient = mock(SyncClient.class); + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:getRow") + .to("alibaba-ots:getRow" + + "?endpoint=" + testConfiguration.getProperty("endpoint") + + "&instanceName=" + testConfiguration.getProperty("instanceName") + + "&accessKey=" + testConfiguration.getProperty("accessKey") + + "&secretKey=" + testConfiguration.getProperty("secretKey") + + "&otsClient=#otsClient") + .to("mock:result"); + } + }; + } + + @Test + void testGetRow() throws Exception { + PrimaryKey primaryKey = new PrimaryKey( + new PrimaryKeyColumn[] { + new PrimaryKeyColumn("pk", PrimaryKeyValue.fromString("id-1")) + }); + Column[] columns = new Column[] { + new Column("name", ColumnValue.fromString("camel")) + }; + Row row = new Row(primaryKey, columns); + GetRowResponse response = new GetRowResponse( + new Response("req-get-row"), + row, + new ConsumedCapacity(new CapacityUnit(1, 0))); + + when(otsClient.getRow(any(GetRowRequest.class))).thenReturn(response); + + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + + GetRowRequest request = new GetRowRequest(); + template.sendBody("direct:getRow", request); + + mock.assertIsSatisfied(); + + Exchange exchange = mock.getExchanges().get(0); + assertThat(exchange.getMessage().getBody(Map.class)) + .containsEntry("requestId", "req-get-row") + .containsKey("row") + .containsKey("consumedCapacity"); + + verify(otsClient).getRow(any(GetRowRequest.class)); + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/ListTablesTest.java b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/ListTablesTest.java new file mode 100644 index 0000000000000..a17d235bba0d8 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/ListTablesTest.java @@ -0,0 +1,80 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import java.util.List; + +import com.alicloud.openservices.tablestore.SyncClient; +import com.alicloud.openservices.tablestore.model.ListTableResponse; +import com.alicloud.openservices.tablestore.model.Response; +import org.apache.camel.BindToRegistry; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class ListTablesTest extends CamelTestSupport { + + private final TestConfiguration testConfiguration = new TestConfiguration(); + + @BindToRegistry("otsClient") + SyncClient otsClient = mock(SyncClient.class); + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:listTables") + .to("alibaba-ots:listTables" + + "?endpoint=" + testConfiguration.getProperty("endpoint") + + "&instanceName=" + testConfiguration.getProperty("instanceName") + + "&accessKey=" + testConfiguration.getProperty("accessKey") + + "&secretKey=" + testConfiguration.getProperty("secretKey") + + "&otsClient=#otsClient") + .to("mock:result"); + } + }; + } + + @Test + void testListTables() throws Exception { + ListTableResponse response = new ListTableResponse(new Response("req-list-tables")); + response.setTableNames(List.of("table-a", "table-b")); + + when(otsClient.listTable()).thenReturn(response); + + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + + template.sendBody("direct:listTables", null); + + mock.assertIsSatisfied(); + + Exchange exchange = mock.getExchanges().get(0); + assertThat(exchange.getMessage().getBody(List.class)) + .containsExactly("table-a", "table-b"); + + verify(otsClient).listTable(); + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/PutRowTest.java b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/PutRowTest.java new file mode 100644 index 0000000000000..625435008e0c9 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/PutRowTest.java @@ -0,0 +1,88 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import java.util.Map; + +import com.alicloud.openservices.tablestore.SyncClient; +import com.alicloud.openservices.tablestore.model.CapacityUnit; +import com.alicloud.openservices.tablestore.model.ConsumedCapacity; +import com.alicloud.openservices.tablestore.model.PutRowRequest; +import com.alicloud.openservices.tablestore.model.PutRowResponse; +import com.alicloud.openservices.tablestore.model.Response; +import org.apache.camel.BindToRegistry; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class PutRowTest extends CamelTestSupport { + + private final TestConfiguration testConfiguration = new TestConfiguration(); + + @BindToRegistry("otsClient") + SyncClient otsClient = mock(SyncClient.class); + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:putRow") + .to("alibaba-ots:putRow" + + "?endpoint=" + testConfiguration.getProperty("endpoint") + + "&instanceName=" + testConfiguration.getProperty("instanceName") + + "&accessKey=" + testConfiguration.getProperty("accessKey") + + "&secretKey=" + testConfiguration.getProperty("secretKey") + + "&otsClient=#otsClient") + .to("mock:result"); + } + }; + } + + @Test + void testPutRow() throws Exception { + PutRowResponse response = new PutRowResponse( + new Response("req-put-row"), + null, + new ConsumedCapacity(new CapacityUnit(0, 1))); + + when(otsClient.putRow(any(PutRowRequest.class))).thenReturn(response); + + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + + PutRowRequest request = new PutRowRequest(); + template.sendBody("direct:putRow", request); + + mock.assertIsSatisfied(); + + Exchange exchange = mock.getExchanges().get(0); + assertThat(exchange.getMessage().getBody(Map.class)) + .containsEntry("requestId", "req-put-row") + .containsKey("consumedCapacity"); + + verify(otsClient).putRow(any(PutRowRequest.class)); + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/TestConfiguration.java b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/TestConfiguration.java new file mode 100644 index 0000000000000..f06eaa142e93f --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/TestConfiguration.java @@ -0,0 +1,57 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.apache.camel.test.junit6.TestSupport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class TestConfiguration { + + private static final Logger LOGGER = LoggerFactory.getLogger(TestConfiguration.class); + private static Map propertyMap; + + TestConfiguration() { + initPropertyMap(); + } + + void initPropertyMap() { + if (propertyMap == null) { + propertyMap = new HashMap<>(); + String propertyFileName = "testconfiguration.properties"; + try { + Properties properties = TestSupport.loadExternalProperties(getClass().getClassLoader(), propertyFileName); + for (String key : properties.stringPropertyNames()) { + propertyMap.put(key, properties.getProperty(key)); + } + } catch (Exception e) { + LOGGER.error("Cannot load property file {}, reason {}", propertyFileName, e.getMessage()); + } + } + } + + String getProperty(String key) { + if (propertyMap == null) { + initPropertyMap(); + } + return propertyMap.get(key); + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/UpdateRowTest.java b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/UpdateRowTest.java new file mode 100644 index 0000000000000..b48966e3dcd30 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/UpdateRowTest.java @@ -0,0 +1,88 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots; + +import java.util.Map; + +import com.alicloud.openservices.tablestore.SyncClient; +import com.alicloud.openservices.tablestore.model.CapacityUnit; +import com.alicloud.openservices.tablestore.model.ConsumedCapacity; +import com.alicloud.openservices.tablestore.model.Response; +import com.alicloud.openservices.tablestore.model.UpdateRowRequest; +import com.alicloud.openservices.tablestore.model.UpdateRowResponse; +import org.apache.camel.BindToRegistry; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class UpdateRowTest extends CamelTestSupport { + + private final TestConfiguration testConfiguration = new TestConfiguration(); + + @BindToRegistry("otsClient") + SyncClient otsClient = mock(SyncClient.class); + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:updateRow") + .to("alibaba-ots:updateRow" + + "?endpoint=" + testConfiguration.getProperty("endpoint") + + "&instanceName=" + testConfiguration.getProperty("instanceName") + + "&accessKey=" + testConfiguration.getProperty("accessKey") + + "&secretKey=" + testConfiguration.getProperty("secretKey") + + "&otsClient=#otsClient") + .to("mock:result"); + } + }; + } + + @Test + void testUpdateRow() throws Exception { + UpdateRowResponse response = new UpdateRowResponse( + new Response("req-update-row"), + null, + new ConsumedCapacity(new CapacityUnit(0, 1))); + + when(otsClient.updateRow(any(UpdateRowRequest.class))).thenReturn(response); + + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + + UpdateRowRequest request = new UpdateRowRequest(); + template.sendBody("direct:updateRow", request); + + mock.assertIsSatisfied(); + + Exchange exchange = mock.getExchanges().get(0); + assertThat(exchange.getMessage().getBody(Map.class)) + .containsEntry("requestId", "req-update-row") + .containsKey("consumedCapacity"); + + verify(otsClient).updateRow(any(UpdateRowRequest.class)); + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsOperationsTest.java b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsOperationsTest.java new file mode 100644 index 0000000000000..55edc402cfe11 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/java/org/apache/camel/component/alibaba/ots/constants/AlibabaOtsOperationsTest.java @@ -0,0 +1,33 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.ots.constants; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class AlibabaOtsOperationsTest { + + @Test + void testOperations() { + assertThat(AlibabaOtsOperations.PUT_ROW).isEqualTo("putRow"); + assertThat(AlibabaOtsOperations.GET_ROW).isEqualTo("getRow"); + assertThat(AlibabaOtsOperations.UPDATE_ROW).isEqualTo("updateRow"); + assertThat(AlibabaOtsOperations.DELETE_ROW).isEqualTo("deleteRow"); + assertThat(AlibabaOtsOperations.LIST_TABLES).isEqualTo("listTables"); + } +} diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/resources/log4j2.properties b/components/camel-alibaba/camel-alibaba-ots/src/test/resources/log4j2.properties new file mode 100644 index 0000000000000..b7a3f221972a8 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +appender.file.type = File +appender.file.name = file +appender.file.fileName = target/camel-alibaba-ots-test.log +appender.file.layout.type = PatternLayout +appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.out.type = Console +appender.out.name = out +appender.out.layout.type = PatternLayout +appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n + +rootLogger.level = INFO +rootLogger.appenderRef.file.ref = file diff --git a/components/camel-alibaba/camel-alibaba-ots/src/test/resources/testconfiguration.properties b/components/camel-alibaba/camel-alibaba-ots/src/test/resources/testconfiguration.properties new file mode 100644 index 0000000000000..07cbdd08cd0b5 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-ots/src/test/resources/testconfiguration.properties @@ -0,0 +1,21 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +accessKey=dummy_access_key +secretKey=dummy_secret_key +endpoint=https://test-instance.cn-hangzhou.ots.aliyuncs.com +instanceName=test-instance diff --git a/components/camel-alibaba/camel-alibaba-sls/pom.xml b/components/camel-alibaba/camel-alibaba-sls/pom.xml new file mode 100644 index 0000000000000..391a6f38ef69d --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/pom.xml @@ -0,0 +1,86 @@ + + + + + 4.0.0 + + + org.apache.camel + camel-alibaba-parent + 4.23.0-SNAPSHOT + + + + 4.23.0 + + + camel-alibaba-sls + jar + Camel :: Alibaba Cloud :: Simple Log Service (SLS) + Camel Alibaba Cloud Simple Log Service (SLS) component + + + + org.apache.camel + camel-support + + + + org.apache.camel + camel-alibaba-common + ${project.version} + + + + com.aliyun + sls20201230 + + + com.sun.xml.bind + jaxb-core + + + com.sun.xml.bind + jaxb-impl + + + + + + org.apache.camel + camel-test-junit6 + test + + + + org.assertj + assertj-core + test + + + + org.mockito + mockito-core + ${mockito-version} + test + + + + diff --git a/components/camel-alibaba/camel-alibaba-sls/src/generated/java/org/apache/camel/component/alibaba/sls/AlibabaSlsComponentConfigurer.java b/components/camel-alibaba/camel-alibaba-sls/src/generated/java/org/apache/camel/component/alibaba/sls/AlibabaSlsComponentConfigurer.java new file mode 100644 index 0000000000000..93b14bd5e8795 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/generated/java/org/apache/camel/component/alibaba/sls/AlibabaSlsComponentConfigurer.java @@ -0,0 +1,69 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.alibaba.sls; + +import javax.annotation.processing.Generated; +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.spi.ConfigurerStrategy; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.support.component.PropertyConfigurerSupport; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo") +@SuppressWarnings("unchecked") +public class AlibabaSlsComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + AlibabaSlsComponent target = (AlibabaSlsComponent) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "autowiredenabled": + case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true; + case "healthcheckconsumerenabled": + case "healthCheckConsumerEnabled": target.setHealthCheckConsumerEnabled(property(camelContext, boolean.class, value)); return true; + case "healthcheckproducerenabled": + case "healthCheckProducerEnabled": target.setHealthCheckProducerEnabled(property(camelContext, boolean.class, value)); return true; + case "lazystartproducer": + case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; + default: return false; + } + } + + @Override + public Class getOptionType(String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "autowiredenabled": + case "autowiredEnabled": return boolean.class; + case "healthcheckconsumerenabled": + case "healthCheckConsumerEnabled": return boolean.class; + case "healthcheckproducerenabled": + case "healthCheckProducerEnabled": return boolean.class; + case "lazystartproducer": + case "lazyStartProducer": return boolean.class; + default: return null; + } + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + AlibabaSlsComponent target = (AlibabaSlsComponent) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "autowiredenabled": + case "autowiredEnabled": return target.isAutowiredEnabled(); + case "healthcheckconsumerenabled": + case "healthCheckConsumerEnabled": return target.isHealthCheckConsumerEnabled(); + case "healthcheckproducerenabled": + case "healthCheckProducerEnabled": return target.isHealthCheckProducerEnabled(); + case "lazystartproducer": + case "lazyStartProducer": return target.isLazyStartProducer(); + default: return null; + } + } +} + diff --git a/components/camel-alibaba/camel-alibaba-sls/src/generated/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpointConfigurer.java b/components/camel-alibaba/camel-alibaba-sls/src/generated/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpointConfigurer.java new file mode 100644 index 0000000000000..b55eb6c3f47b2 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/generated/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpointConfigurer.java @@ -0,0 +1,116 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.alibaba.sls; + +import javax.annotation.processing.Generated; +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.spi.ConfigurerStrategy; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.support.component.PropertyConfigurerSupport; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo") +@SuppressWarnings("unchecked") +public class AlibabaSlsEndpointConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + AlibabaSlsEndpoint target = (AlibabaSlsEndpoint) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "accesskey": + case "accessKey": target.setAccessKey(property(camelContext, java.lang.String.class, value)); return true; + case "endpoint": target.setEndpoint(property(camelContext, java.lang.String.class, value)); return true; + case "from": target.setFrom(property(camelContext, java.lang.Integer.class, value)); return true; + case "lazystartproducer": + case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; + case "line": target.setLine(property(camelContext, java.lang.Long.class, value)); return true; + case "logstorename": + case "logStoreName": target.setLogStoreName(property(camelContext, java.lang.String.class, value)); return true; + case "offset": target.setOffset(property(camelContext, java.lang.Long.class, value)); return true; + case "project": target.setProject(property(camelContext, java.lang.String.class, value)); return true; + case "query": target.setQuery(property(camelContext, java.lang.String.class, value)); return true; + case "region": target.setRegion(property(camelContext, java.lang.String.class, value)); return true; + case "reverse": target.setReverse(property(camelContext, java.lang.Boolean.class, value)); return true; + case "secretkey": + case "secretKey": target.setSecretKey(property(camelContext, java.lang.String.class, value)); return true; + case "servicekeys": + case "serviceKeys": target.setServiceKeys(property(camelContext, org.apache.camel.component.alibaba.common.models.ServiceKeys.class, value)); return true; + case "slsclient": + case "slsClient": target.setSlsClient(property(camelContext, com.aliyun.sls20201230.Client.class, value)); return true; + case "to": target.setTo(property(camelContext, java.lang.Integer.class, value)); return true; + case "topic": target.setTopic(property(camelContext, java.lang.String.class, value)); return true; + default: return false; + } + } + + @Override + public String[] getAutowiredNames() { + return new String[]{"slsClient"}; + } + + @Override + public Class getOptionType(String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "accesskey": + case "accessKey": return java.lang.String.class; + case "endpoint": return java.lang.String.class; + case "from": return java.lang.Integer.class; + case "lazystartproducer": + case "lazyStartProducer": return boolean.class; + case "line": return java.lang.Long.class; + case "logstorename": + case "logStoreName": return java.lang.String.class; + case "offset": return java.lang.Long.class; + case "project": return java.lang.String.class; + case "query": return java.lang.String.class; + case "region": return java.lang.String.class; + case "reverse": return java.lang.Boolean.class; + case "secretkey": + case "secretKey": return java.lang.String.class; + case "servicekeys": + case "serviceKeys": return org.apache.camel.component.alibaba.common.models.ServiceKeys.class; + case "slsclient": + case "slsClient": return com.aliyun.sls20201230.Client.class; + case "to": return java.lang.Integer.class; + case "topic": return java.lang.String.class; + default: return null; + } + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + AlibabaSlsEndpoint target = (AlibabaSlsEndpoint) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "accesskey": + case "accessKey": return target.getAccessKey(); + case "endpoint": return target.getEndpoint(); + case "from": return target.getFrom(); + case "lazystartproducer": + case "lazyStartProducer": return target.isLazyStartProducer(); + case "line": return target.getLine(); + case "logstorename": + case "logStoreName": return target.getLogStoreName(); + case "offset": return target.getOffset(); + case "project": return target.getProject(); + case "query": return target.getQuery(); + case "region": return target.getRegion(); + case "reverse": return target.getReverse(); + case "secretkey": + case "secretKey": return target.getSecretKey(); + case "servicekeys": + case "serviceKeys": return target.getServiceKeys(); + case "slsclient": + case "slsClient": return target.getSlsClient(); + case "to": return target.getTo(); + case "topic": return target.getTopic(); + default: return null; + } + } +} + diff --git a/components/camel-alibaba/camel-alibaba-sls/src/generated/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpointUriFactory.java b/components/camel-alibaba/camel-alibaba-sls/src/generated/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpointUriFactory.java new file mode 100644 index 0000000000000..7840d24150d8b --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/generated/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpointUriFactory.java @@ -0,0 +1,97 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.alibaba.sls; + +import javax.annotation.processing.Generated; +import java.net.URISyntaxException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.camel.spi.EndpointUriFactory; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.GenerateEndpointUriFactoryMojo") +public class AlibabaSlsEndpointUriFactory extends org.apache.camel.support.component.EndpointUriFactorySupport implements EndpointUriFactory { + + private static final String BASE = ":operation"; + + private static final Set PROPERTY_NAMES; + private static final Set SECRET_PROPERTY_NAMES; + private static final Set ENDPOINT_IDENTITY_PROPERTY_NAMES; + private static final Map MULTI_VALUE_PREFIXES; + static { + Set props = new HashSet<>(17); + props.add("accessKey"); + props.add("endpoint"); + props.add("from"); + props.add("lazyStartProducer"); + props.add("line"); + props.add("logStoreName"); + props.add("offset"); + props.add("operation"); + props.add("project"); + props.add("query"); + props.add("region"); + props.add("reverse"); + props.add("secretKey"); + props.add("serviceKeys"); + props.add("slsClient"); + props.add("to"); + props.add("topic"); + PROPERTY_NAMES = Collections.unmodifiableSet(props); + Set secretProps = new HashSet<>(3); + secretProps.add("accessKey"); + secretProps.add("secretKey"); + secretProps.add("serviceKeys"); + SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps); + ENDPOINT_IDENTITY_PROPERTY_NAMES = Collections.emptySet(); + MULTI_VALUE_PREFIXES = Collections.emptyMap(); + } + + @Override + public boolean isEnabled(String scheme) { + return "alibaba-sls".equals(scheme); + } + + @Override + public String buildUri(String scheme, Map properties, boolean encode) throws URISyntaxException { + String syntax = scheme + BASE; + String uri = syntax; + + Map copy = new HashMap<>(properties); + + uri = buildPathParameter(syntax, uri, "operation", null, true, copy); + uri = buildQueryParameters(uri, copy, encode); + return uri; + } + + @Override + public Set propertyNames() { + return PROPERTY_NAMES; + } + + @Override + public Set secretPropertyNames() { + return SECRET_PROPERTY_NAMES; + } + + @Override + public Set endpointIdentityPropertyNames() { + return ENDPOINT_IDENTITY_PROPERTY_NAMES; + } + + @Override + public Map multiValuePrefixes() { + return MULTI_VALUE_PREFIXES; + } + + @Override + public boolean isLenientProperties() { + return false; + } +} + diff --git a/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/org/apache/camel/component/alibaba/sls/alibaba-sls.json b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/org/apache/camel/component/alibaba/sls/alibaba-sls.json new file mode 100644 index 0000000000000..b09c9b2635198 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/org/apache/camel/component/alibaba/sls/alibaba-sls.json @@ -0,0 +1,68 @@ +{ + "component": { + "kind": "component", + "name": "alibaba-sls", + "title": "Alibaba Simple Log Service (SLS)", + "description": "Manage logs on Alibaba Cloud Simple Log Service (SLS).", + "deprecated": false, + "firstVersion": "4.23.0", + "label": "cloud,monitoring", + "javaType": "org.apache.camel.component.alibaba.sls.AlibabaSlsComponent", + "supportLevel": "Preview", + "groupId": "org.apache.camel", + "artifactId": "camel-alibaba-sls", + "version": "4.23.0-SNAPSHOT", + "scheme": "alibaba-sls", + "extendsScheme": "", + "syntax": "alibaba-sls:operation", + "async": false, + "api": false, + "consumerOnly": false, + "producerOnly": true, + "lenientProperties": false, + "browsable": false, + "remote": true + }, + "componentProperties": { + "lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, + "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }, + "healthCheckConsumerEnabled": { "index": 2, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" }, + "healthCheckProducerEnabled": { "index": 3, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true." } + }, + "headers": { + "CamelAlibabaSlsProject": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "SLS project name override", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#PROJECT" }, + "CamelAlibabaSlsLogStoreName": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "SLS log store name override", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#LOG_STORE_NAME" }, + "CamelAlibabaSlsQuery": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Log query string override", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#QUERY" }, + "CamelAlibabaSlsFrom": { "index": 3, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Query start time override (Unix timestamp in seconds)", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#FROM" }, + "CamelAlibabaSlsTo": { "index": 4, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Query end time override (Unix timestamp in seconds)", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#TO" }, + "CamelAlibabaSlsLine": { "index": 5, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Maximum number of log lines to return", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#LINE" }, + "CamelAlibabaSlsOffset": { "index": 6, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Log query offset", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#OFFSET" }, + "CamelAlibabaSlsTopic": { "index": 7, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Log topic filter override", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#TOPIC" }, + "CamelAlibabaSlsReverse": { "index": 8, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether to return logs in reverse order", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#REVERSE" }, + "CamelAlibabaSlsLogstoreName": { "index": 9, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Log store name prefix filter for listLogStores", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#LOGSTORE_NAME" }, + "CamelAlibabaSlsMode": { "index": 10, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "List mode for listLogStores", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#MODE" }, + "CamelAlibabaSlsSize": { "index": 11, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Page size for listLogStores", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#SIZE" }, + "CamelAlibabaSlsTelemetryType": { "index": 12, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Telemetry type filter for listLogStores", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#TELEMETRY_TYPE" }, + "CamelAlibabaSlsRequestId": { "index": 13, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Alibaba Cloud request id", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#REQUEST_ID" }, + "CamelAlibabaSlsStatusCode": { "index": 14, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "HTTP status code from SLS response", "constantName": "org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders#STATUS_CODE" } + }, + "properties": { + "operation": { "index": 0, "kind": "path", "displayName": "Operation", "group": "producer", "label": "producer", "required": true, "type": "enum", "javaType": "java.lang.String", "enum": [ "putLogs", "getLogs", "listLogStores" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Operation to perform" }, + "endpoint": { "index": 1, "kind": "parameter", "displayName": "Endpoint", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "SLS endpoint URL (e.g. cn-hangzhou.log.aliyuncs.com). Carries higher precedence than region based client initialization" }, + "logStoreName": { "index": 2, "kind": "parameter", "displayName": "Log Store Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "SLS log store name" }, + "project": { "index": 3, "kind": "parameter", "displayName": "Project", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "SLS project name" }, + "region": { "index": 4, "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Alibaba Cloud region" }, + "lazyStartProducer": { "index": 5, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, + "slsClient": { "index": 6, "kind": "parameter", "displayName": "SLS Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.aliyun.sls20201230.Client", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "description": "Autowire an existing SLS client instance" }, + "from": { "index": 7, "kind": "parameter", "displayName": "From", "group": "getLogs", "label": "getLogs", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Query start time for getLogs (Unix timestamp in seconds)" }, + "line": { "index": 8, "kind": "parameter", "displayName": "Line", "group": "getLogs", "label": "getLogs", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "autowired": false, "secret": false, "description": "Maximum number of log lines to return for getLogs" }, + "offset": { "index": 9, "kind": "parameter", "displayName": "Offset", "group": "getLogs", "label": "getLogs", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "autowired": false, "secret": false, "description": "Log query offset for getLogs" }, + "query": { "index": 10, "kind": "parameter", "displayName": "Query", "group": "getLogs", "label": "getLogs", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Log query string for getLogs" }, + "reverse": { "index": 11, "kind": "parameter", "displayName": "Reverse", "group": "getLogs", "label": "getLogs", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to return logs in reverse order for getLogs" }, + "to": { "index": 12, "kind": "parameter", "displayName": "To", "group": "getLogs", "label": "getLogs", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Query end time for getLogs (Unix timestamp in seconds)" }, + "topic": { "index": 13, "kind": "parameter", "displayName": "Topic", "group": "getLogs", "label": "getLogs", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Log topic filter for getLogs" }, + "accessKey": { "index": 14, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Access key for the cloud user" }, + "secretKey": { "index": 15, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Secret key for the cloud user" }, + "serviceKeys": { "index": 16, "kind": "parameter", "displayName": "Service Keys", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.component.alibaba.common.models.ServiceKeys", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "Configuration object for cloud service authentication" } + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/component.properties b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/component.properties new file mode 100644 index 0000000000000..25e09c13ee1f6 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/component.properties @@ -0,0 +1,7 @@ +# Generated by camel build tools - do NOT edit this file! +components=alibaba-sls +groupId=org.apache.camel +artifactId=camel-alibaba-sls +version=4.23.0-SNAPSHOT +projectName=Camel :: Alibaba Cloud :: Simple Log Service (SLS) +projectDescription=Camel Alibaba Cloud Simple Log Service (SLS) component diff --git a/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/component/alibaba-sls b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/component/alibaba-sls new file mode 100644 index 0000000000000..e8db4ae4bc60a --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/component/alibaba-sls @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.alibaba.sls.AlibabaSlsComponent diff --git a/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-sls-component b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-sls-component new file mode 100644 index 0000000000000..0d2a69c7af7d9 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-sls-component @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.alibaba.sls.AlibabaSlsComponentConfigurer diff --git a/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-sls-endpoint b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-sls-endpoint new file mode 100644 index 0000000000000..2b8e7fe257f6b --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/configurer/alibaba-sls-endpoint @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.alibaba.sls.AlibabaSlsEndpointConfigurer diff --git a/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/urifactory/alibaba-sls-endpoint b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/urifactory/alibaba-sls-endpoint new file mode 100644 index 0000000000000..9ae2d3a33cfdb --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/services/org/apache/camel/urifactory/alibaba-sls-endpoint @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.alibaba.sls.AlibabaSlsEndpointUriFactory diff --git a/components/camel-alibaba/camel-alibaba-sls/src/main/docs/alibaba-sls-component.adoc b/components/camel-alibaba/camel-alibaba-sls/src/main/docs/alibaba-sls-component.adoc new file mode 100644 index 0000000000000..267b8d77c1152 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/main/docs/alibaba-sls-component.adoc @@ -0,0 +1,87 @@ += Alibaba Simple Log Service (SLS) Component +:doctitle: Alibaba Simple Log Service (SLS) +:shortname: alibaba-sls +:artifactid: camel-alibaba-sls +:description: Manage logs on Alibaba Cloud Simple Log Service (SLS). +:since: 4.23 +:supportlevel: Preview +:tabs-sync-option: +:component-header: Only producer is supported +//Manually maintained attributes +:group: Alibaba Cloud + +*Since Camel {since}* + +*{component-header}* + +The Alibaba Cloud Simple Log Service (SLS) component allows you to write logs, query logs and list log stores. + +Maven users will need to add the following dependency to their `pom.xml` +for this component: + +[source,xml] +---- + + org.apache.camel + camel-alibaba-sls + x.x.x + + +---- + +== URI format + +[source] +---- +alibaba-sls:operation[?options] +---- + +// component options: START +include::partial$component-configure-options.adoc[] +include::partial$component-endpoint-options.adoc[] +include::partial$component-endpoint-headers.adoc[] +// component options: END + +== Usage + +=== Operations + +The component supports the following operations: + +* `putLogs` - write a log group to a log store (producer) +* `getLogs` - query logs from a log store (producer) +* `listLogStores` - list log stores in a project (producer) + +=== Producer examples + +Put logs: + +[source,java] +---- +from("direct:start") + .setBody(simple("${body}")) + .to("alibaba-sls:putLogs?project=my-project&logStoreName=my-logstore®ion=cn-hangzhou&endpoint=cn-hangzhou.log.aliyuncs.com&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); +---- + +Query logs: + +[source,java] +---- +from("direct:start") + .setHeader("CamelAlibabaSlsQuery", constant("*")) + .setHeader("CamelAlibabaSlsFrom", constant(1700000000)) + .setHeader("CamelAlibabaSlsTo", constant(1700003600)) + .to("alibaba-sls:getLogs?project=my-project&logStoreName=my-logstore®ion=cn-hangzhou&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); +---- + +List log stores: + +[source,java] +---- +from("direct:start") + .to("alibaba-sls:listLogStores?project=my-project®ion=cn-hangzhou&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); +---- + +== Examples + +For more examples, see the unit tests in the `camel-alibaba-sls` module. diff --git a/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsComponent.java b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsComponent.java new file mode 100644 index 0000000000000..4534e8cb70c80 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsComponent.java @@ -0,0 +1,34 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls; + +import java.util.Map; + +import org.apache.camel.Endpoint; +import org.apache.camel.spi.annotations.Component; +import org.apache.camel.support.HealthCheckComponent; + +@Component("alibaba-sls") +public class AlibabaSlsComponent extends HealthCheckComponent { + + @Override + protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { + AlibabaSlsEndpoint endpoint = new AlibabaSlsEndpoint(uri, remaining, this); + setProperties(endpoint, parameters); + return endpoint; + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpoint.java b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpoint.java new file mode 100644 index 0000000000000..bd5ef1d9c844a --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpoint.java @@ -0,0 +1,264 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls; + +import com.aliyun.sls20201230.Client; +import org.apache.camel.Category; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.alibaba.common.models.ServiceKeys; +import org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders; +import org.apache.camel.spi.Metadata; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriPath; +import org.apache.camel.support.DefaultEndpoint; + +/** + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + */ +@UriEndpoint(firstVersion = "4.23.0", scheme = "alibaba-sls", title = "Alibaba Simple Log Service (SLS)", + syntax = "alibaba-sls:operation", category = { Category.CLOUD, Category.MONITORING }, + headersClass = AlibabaSlsHeaders.class, producerOnly = true) +public class AlibabaSlsEndpoint extends DefaultEndpoint { + + @UriPath(description = "Operation to perform", displayName = "Operation", label = "producer", + enums = "putLogs,getLogs,listLogStores") + @Metadata(required = true) + private String operation; + + @UriParam(description = "Alibaba Cloud region", displayName = "Region") + private String region; + + @UriParam(description = "SLS endpoint URL (e.g. cn-hangzhou.log.aliyuncs.com). " + + "Carries higher precedence than region based client initialization", + displayName = "Endpoint") + private String endpoint; + + @UriParam(description = "Access key for the cloud user", displayName = "Access Key", + secret = true, security = "secret", label = "security") + private String accessKey; + + @UriParam(description = "Secret key for the cloud user", displayName = "Secret Key", + secret = true, security = "secret", label = "security") + private String secretKey; + + @UriParam(description = "Configuration object for cloud service authentication", displayName = "Service Keys", + secret = true, security = "secret", label = "security") + private ServiceKeys serviceKeys; + + @UriParam(description = "SLS project name", displayName = "Project") + private String project; + + @UriParam(description = "SLS log store name", displayName = "Log Store Name") + private String logStoreName; + + @UriParam(description = "Log query string for getLogs", displayName = "Query", label = "getLogs") + private String query; + + @UriParam(description = "Query start time for getLogs (Unix timestamp in seconds)", displayName = "From", + label = "getLogs") + private Integer from; + + @UriParam(description = "Query end time for getLogs (Unix timestamp in seconds)", displayName = "To", + label = "getLogs") + private Integer to; + + @UriParam(description = "Maximum number of log lines to return for getLogs", displayName = "Line", + label = "getLogs") + private Long line; + + @UriParam(description = "Log query offset for getLogs", displayName = "Offset", label = "getLogs") + private Long offset; + + @UriParam(description = "Log topic filter for getLogs", displayName = "Topic", label = "getLogs") + private String topic; + + @UriParam(description = "Whether to return logs in reverse order for getLogs", displayName = "Reverse", + label = "getLogs") + private Boolean reverse; + + @UriParam(description = "Autowire an existing SLS client instance", displayName = "SLS Client", label = "advanced") + @Metadata(autowired = true) + private Client slsClient; + + private boolean autowiredSlsClient; + + public AlibabaSlsEndpoint() { + } + + public AlibabaSlsEndpoint(String uri, String operation, AlibabaSlsComponent component) { + super(uri, component); + this.operation = operation; + } + + @Override + public Producer createProducer() throws Exception { + return new AlibabaSlsProducer(this); + } + + @Override + public Consumer createConsumer(Processor processor) throws Exception { + throw new UnsupportedOperationException("You cannot consume from this endpoint"); + } + + public Client initClient() throws Exception { + if (slsClient != null) { + return slsClient; + } + slsClient = AlibabaSlsUtils.createClient(this); + return slsClient; + } + + @Override + protected void doStop() throws Exception { + if (slsClient != null && !autowiredSlsClient) { + slsClient = null; + } + super.doStop(); + } + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getAccessKey() { + return accessKey; + } + + public void setAccessKey(String accessKey) { + this.accessKey = accessKey; + } + + public String getSecretKey() { + return secretKey; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + + public ServiceKeys getServiceKeys() { + return serviceKeys; + } + + public void setServiceKeys(ServiceKeys serviceKeys) { + this.serviceKeys = serviceKeys; + } + + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public String getLogStoreName() { + return logStoreName; + } + + public void setLogStoreName(String logStoreName) { + this.logStoreName = logStoreName; + } + + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public Integer getFrom() { + return from; + } + + public void setFrom(Integer from) { + this.from = from; + } + + public Integer getTo() { + return to; + } + + public void setTo(Integer to) { + this.to = to; + } + + public Long getLine() { + return line; + } + + public void setLine(Long line) { + this.line = line; + } + + public Long getOffset() { + return offset; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public Boolean getReverse() { + return reverse; + } + + public void setReverse(Boolean reverse) { + this.reverse = reverse; + } + + public Client getSlsClient() { + return slsClient; + } + + public void setSlsClient(Client slsClient) { + this.slsClient = slsClient; + this.autowiredSlsClient = slsClient != null; + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsProducer.java b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsProducer.java new file mode 100644 index 0000000000000..c7b154a2d76c0 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsProducer.java @@ -0,0 +1,122 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls; + +import java.util.Map; + +import com.aliyun.sls20201230.Client; +import com.aliyun.sls20201230.models.GetLogsRequest; +import com.aliyun.sls20201230.models.GetLogsResponse; +import com.aliyun.sls20201230.models.ListLogStoresRequest; +import com.aliyun.sls20201230.models.ListLogStoresResponse; +import com.aliyun.sls20201230.models.PutLogsRequest; +import com.aliyun.sls20201230.models.PutLogsResponse; +import org.apache.camel.Exchange; +import org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders; +import org.apache.camel.component.alibaba.sls.constants.AlibabaSlsOperations; +import org.apache.camel.component.alibaba.sls.models.ClientConfigurations; +import org.apache.camel.support.DefaultProducer; +import org.apache.camel.util.ObjectHelper; + +public class AlibabaSlsProducer extends DefaultProducer { + + public AlibabaSlsProducer(AlibabaSlsEndpoint endpoint) { + super(endpoint); + } + + @Override + public void process(Exchange exchange) throws Exception { + AlibabaSlsEndpoint endpoint = getEndpoint(); + ClientConfigurations configuration = AlibabaSlsUtils.createClientConfigurations(endpoint, exchange); + + if (ObjectHelper.isEmpty(configuration.getOperation())) { + throw new IllegalArgumentException("Operation name not found"); + } + + Client slsClient = endpoint.initClient(); + + switch (configuration.getOperation()) { + case AlibabaSlsOperations.PUT_LOGS -> putLogs(exchange, configuration, slsClient); + case AlibabaSlsOperations.GET_LOGS -> getLogs(exchange, configuration, slsClient); + case AlibabaSlsOperations.LIST_LOG_STORES -> listLogStores(exchange, configuration, slsClient); + default -> throw new UnsupportedOperationException("Unsupported operation: " + configuration.getOperation()); + } + } + + private void putLogs(Exchange exchange, ClientConfigurations configuration, Client slsClient) throws Exception { + validateProjectAndLogStore(configuration); + + PutLogsRequest request = AlibabaSlsUtils.resolvePutLogsRequest(exchange); + PutLogsResponse response = slsClient.putLogs( + configuration.getProject(), + configuration.getLogStoreName(), + request); + + exchange.getMessage().setBody(AlibabaSlsUtils.toPutLogsMap(response)); + setResponseHeaders(exchange, response.getStatusCode(), response.getHeaders()); + } + + private void getLogs(Exchange exchange, ClientConfigurations configuration, Client slsClient) throws Exception { + validateProjectAndLogStore(configuration); + + GetLogsRequest request = AlibabaSlsUtils.buildGetLogsRequest(configuration); + GetLogsResponse response = slsClient.getLogs( + configuration.getProject(), + configuration.getLogStoreName(), + request); + + exchange.getMessage().setBody(AlibabaSlsUtils.toGetLogsMap(response)); + setResponseHeaders(exchange, response.getStatusCode(), response.getHeaders()); + } + + private void listLogStores(Exchange exchange, ClientConfigurations configuration, Client slsClient) throws Exception { + validateProject(configuration); + + ListLogStoresRequest request = AlibabaSlsUtils.buildListLogStoresRequest(configuration); + ListLogStoresResponse response = slsClient.listLogStores(configuration.getProject(), request); + + exchange.getMessage().setBody(AlibabaSlsUtils.toListLogStoresMap(response)); + setResponseHeaders(exchange, response.getStatusCode(), response.getHeaders()); + } + + private void validateProjectAndLogStore(ClientConfigurations configuration) { + if (ObjectHelper.isEmpty(configuration.getProject()) || ObjectHelper.isEmpty(configuration.getLogStoreName())) { + throw new IllegalArgumentException("Project and log store name are required"); + } + } + + private void validateProject(ClientConfigurations configuration) { + if (ObjectHelper.isEmpty(configuration.getProject())) { + throw new IllegalArgumentException("Project is required"); + } + } + + private void setResponseHeaders(Exchange exchange, Integer statusCode, Map headers) { + if (statusCode != null) { + exchange.getMessage().setHeader(AlibabaSlsHeaders.STATUS_CODE, statusCode); + } + String requestId = AlibabaSlsUtils.extractRequestId(headers); + if (ObjectHelper.isNotEmpty(requestId)) { + exchange.getMessage().setHeader(AlibabaSlsHeaders.REQUEST_ID, requestId); + } + } + + @Override + public AlibabaSlsEndpoint getEndpoint() { + return (AlibabaSlsEndpoint) super.getEndpoint(); + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsUtils.java b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsUtils.java new file mode 100644 index 0000000000000..27bc2dd07a2ba --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsUtils.java @@ -0,0 +1,215 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls; + +import java.util.HashMap; +import java.util.Map; + +import com.aliyun.sls20201230.Client; +import com.aliyun.sls20201230.models.GetLogsRequest; +import com.aliyun.sls20201230.models.GetLogsResponse; +import com.aliyun.sls20201230.models.ListLogStoresRequest; +import com.aliyun.sls20201230.models.ListLogStoresResponse; +import com.aliyun.sls20201230.models.ListLogStoresResponseBody; +import com.aliyun.sls20201230.models.LogGroup; +import com.aliyun.sls20201230.models.PutLogsRequest; +import com.aliyun.sls20201230.models.PutLogsResponse; +import com.aliyun.teaopenapi.models.Config; +import org.apache.camel.Exchange; +import org.apache.camel.component.alibaba.common.OpenApiClientSupport; +import org.apache.camel.component.alibaba.common.models.ServiceKeys; +import org.apache.camel.component.alibaba.sls.constants.AlibabaSlsProperties; +import org.apache.camel.component.alibaba.sls.models.ClientConfigurations; +import org.apache.camel.util.ObjectHelper; + +public final class AlibabaSlsUtils { + + private AlibabaSlsUtils() { + } + + public static Client createClient(AlibabaSlsEndpoint endpoint) throws Exception { + if (ObjectHelper.isEmpty(endpoint.getRegion()) && ObjectHelper.isEmpty(endpoint.getEndpoint())) { + throw new IllegalArgumentException("Region or endpoint is required"); + } + + return new Client( + createTeaConfig( + endpoint.getAccessKey(), + endpoint.getSecretKey(), + endpoint.getServiceKeys(), + endpoint.getRegion(), + endpoint.getEndpoint())); + } + + private static Config createTeaConfig( + String accessKey, String secretKey, ServiceKeys serviceKeys, String region, String endpoint) { + Config config = new Config(); + config.setAccessKeyId(OpenApiClientSupport.resolveAccessKey(accessKey, serviceKeys)); + config.setAccessKeySecret(OpenApiClientSupport.resolveSecretKey(secretKey, serviceKeys)); + if (ObjectHelper.isNotEmpty(region)) { + config.setRegionId(region); + } + if (ObjectHelper.isNotEmpty(endpoint)) { + config.setEndpoint(endpoint); + } + return config; + } + + public static ClientConfigurations createClientConfigurations(AlibabaSlsEndpoint endpoint, Exchange exchange) { + ClientConfigurations configuration = new ClientConfigurations(); + configuration + .setOperation( + OpenApiClientSupport.resolveString(exchange, AlibabaSlsProperties.OPERATION, endpoint.getOperation())); + configuration.setProject( + OpenApiClientSupport.resolveString(exchange, AlibabaSlsProperties.PROJECT, endpoint.getProject())); + configuration.setLogStoreName( + OpenApiClientSupport.resolveString(exchange, AlibabaSlsProperties.LOG_STORE_NAME, endpoint.getLogStoreName())); + configuration.setQuery(OpenApiClientSupport.resolveString(exchange, AlibabaSlsProperties.QUERY, endpoint.getQuery())); + configuration.setFrom(OpenApiClientSupport.resolveInteger(exchange, AlibabaSlsProperties.FROM, endpoint.getFrom())); + configuration.setTo(OpenApiClientSupport.resolveInteger(exchange, AlibabaSlsProperties.TO, endpoint.getTo())); + configuration.setLine(resolveLong(exchange, AlibabaSlsProperties.LINE, endpoint.getLine())); + configuration.setOffset(resolveLong(exchange, AlibabaSlsProperties.OFFSET, endpoint.getOffset())); + configuration.setTopic(OpenApiClientSupport.resolveString(exchange, AlibabaSlsProperties.TOPIC, endpoint.getTopic())); + configuration.setReverse(resolveBoolean(exchange, AlibabaSlsProperties.REVERSE, endpoint.getReverse())); + configuration.setLogstoreName( + OpenApiClientSupport.resolveString(exchange, AlibabaSlsProperties.LOGSTORE_NAME, null)); + configuration.setMode(OpenApiClientSupport.resolveString(exchange, AlibabaSlsProperties.MODE, null)); + configuration.setListOffset(OpenApiClientSupport.resolveInteger(exchange, AlibabaSlsProperties.OFFSET, null)); + configuration.setSize(OpenApiClientSupport.resolveInteger(exchange, AlibabaSlsProperties.SIZE, null)); + configuration.setTelemetryType( + OpenApiClientSupport.resolveString(exchange, AlibabaSlsProperties.TELEMETRY_TYPE, null)); + return configuration; + } + + public static PutLogsRequest resolvePutLogsRequest(Exchange exchange) { + Object body = exchange.getMessage().getBody(); + if (body instanceof PutLogsRequest putLogsRequest) { + return putLogsRequest; + } + if (body instanceof LogGroup logGroup) { + return new PutLogsRequest().setBody(logGroup); + } + throw new IllegalArgumentException("Body must be LogGroup or PutLogsRequest for putLogs"); + } + + public static GetLogsRequest buildGetLogsRequest(ClientConfigurations configuration) { + GetLogsRequest request = new GetLogsRequest(); + if (ObjectHelper.isNotEmpty(configuration.getQuery())) { + request.setQuery(configuration.getQuery()); + } + if (configuration.getFrom() != null) { + request.setFrom(configuration.getFrom()); + } + if (configuration.getTo() != null) { + request.setTo(configuration.getTo()); + } + if (configuration.getLine() != null) { + request.setLine(configuration.getLine()); + } + if (configuration.getOffset() != null) { + request.setOffset(configuration.getOffset()); + } + if (ObjectHelper.isNotEmpty(configuration.getTopic())) { + request.setTopic(configuration.getTopic()); + } + if (configuration.getReverse() != null) { + request.setReverse(configuration.getReverse()); + } + return request; + } + + public static ListLogStoresRequest buildListLogStoresRequest(ClientConfigurations configuration) { + ListLogStoresRequest request = new ListLogStoresRequest(); + if (ObjectHelper.isNotEmpty(configuration.getLogstoreName())) { + request.setLogstoreName(configuration.getLogstoreName()); + } + if (ObjectHelper.isNotEmpty(configuration.getMode())) { + request.setMode(configuration.getMode()); + } + if (configuration.getListOffset() != null) { + request.setOffset(configuration.getListOffset()); + } + if (configuration.getSize() != null) { + request.setSize(configuration.getSize()); + } + if (ObjectHelper.isNotEmpty(configuration.getTelemetryType())) { + request.setTelemetryType(configuration.getTelemetryType()); + } + return request; + } + + public static Map toPutLogsMap(PutLogsResponse response) { + Map map = new HashMap<>(); + map.put("statusCode", response.getStatusCode()); + map.put("headers", response.getHeaders()); + return map; + } + + public static Map toGetLogsMap(GetLogsResponse response) { + Map map = new HashMap<>(); + map.put("statusCode", response.getStatusCode()); + map.put("headers", response.getHeaders()); + map.put("body", response.getBody()); + return map; + } + + public static Map toListLogStoresMap(ListLogStoresResponse response) { + Map map = new HashMap<>(); + map.put("statusCode", response.getStatusCode()); + map.put("headers", response.getHeaders()); + ListLogStoresResponseBody body = response.getBody(); + if (body != null) { + map.put("count", body.getCount()); + map.put("logstores", body.getLogstores()); + map.put("total", body.getTotal()); + } + return map; + } + + public static String extractRequestId(Map headers) { + if (headers == null) { + return null; + } + String requestId = headers.get("x-log-requestid"); + if (ObjectHelper.isEmpty(requestId)) { + requestId = headers.get("x-log-requestId"); + } + return requestId; + } + + private static Long resolveLong(Exchange exchange, String name, Long endpointValue) { + Long value = exchange.getIn().getHeader(name, Long.class); + if (value == null) { + value = exchange.getProperty(name, Long.class); + } + if (value == null) { + value = endpointValue; + } + return value; + } + + private static Boolean resolveBoolean(Exchange exchange, String name, Boolean endpointValue) { + Boolean value = exchange.getIn().getHeader(name, Boolean.class); + if (value == null) { + value = exchange.getProperty(name, Boolean.class); + } + if (value == null) { + value = endpointValue; + } + return value; + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsHeaders.java b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsHeaders.java new file mode 100644 index 0000000000000..d79826d4d8fe5 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsHeaders.java @@ -0,0 +1,70 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls.constants; + +import org.apache.camel.spi.Metadata; + +public final class AlibabaSlsHeaders { + + @Metadata(label = "producer", description = "SLS project name override", javaType = "String") + public static final String PROJECT = AlibabaSlsProperties.PROJECT; + + @Metadata(label = "producer", description = "SLS log store name override", javaType = "String") + public static final String LOG_STORE_NAME = AlibabaSlsProperties.LOG_STORE_NAME; + + @Metadata(label = "producer", description = "Log query string override", javaType = "String") + public static final String QUERY = AlibabaSlsProperties.QUERY; + + @Metadata(label = "producer", description = "Query start time override (Unix timestamp in seconds)", javaType = "Integer") + public static final String FROM = AlibabaSlsProperties.FROM; + + @Metadata(label = "producer", description = "Query end time override (Unix timestamp in seconds)", javaType = "Integer") + public static final String TO = AlibabaSlsProperties.TO; + + @Metadata(label = "producer", description = "Maximum number of log lines to return", javaType = "Long") + public static final String LINE = AlibabaSlsProperties.LINE; + + @Metadata(label = "producer", description = "Log query offset", javaType = "Long") + public static final String OFFSET = AlibabaSlsProperties.OFFSET; + + @Metadata(label = "producer", description = "Log topic filter override", javaType = "String") + public static final String TOPIC = AlibabaSlsProperties.TOPIC; + + @Metadata(label = "producer", description = "Whether to return logs in reverse order", javaType = "Boolean") + public static final String REVERSE = AlibabaSlsProperties.REVERSE; + + @Metadata(label = "producer", description = "Log store name prefix filter for listLogStores", javaType = "String") + public static final String LOGSTORE_NAME = AlibabaSlsProperties.LOGSTORE_NAME; + + @Metadata(label = "producer", description = "List mode for listLogStores", javaType = "String") + public static final String MODE = AlibabaSlsProperties.MODE; + + @Metadata(label = "producer", description = "Page size for listLogStores", javaType = "Integer") + public static final String SIZE = AlibabaSlsProperties.SIZE; + + @Metadata(label = "producer", description = "Telemetry type filter for listLogStores", javaType = "String") + public static final String TELEMETRY_TYPE = AlibabaSlsProperties.TELEMETRY_TYPE; + + @Metadata(label = "producer", description = "Alibaba Cloud request id", javaType = "String") + public static final String REQUEST_ID = AlibabaSlsProperties.REQUEST_ID; + + @Metadata(label = "producer", description = "HTTP status code from SLS response", javaType = "Integer") + public static final String STATUS_CODE = AlibabaSlsProperties.STATUS_CODE; + + private AlibabaSlsHeaders() { + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsOperations.java b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsOperations.java new file mode 100644 index 0000000000000..9db9e0697005c --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsOperations.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls.constants; + +public final class AlibabaSlsOperations { + + public static final String PUT_LOGS = "putLogs"; + public static final String GET_LOGS = "getLogs"; + public static final String LIST_LOG_STORES = "listLogStores"; + + private AlibabaSlsOperations() { + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsProperties.java b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsProperties.java new file mode 100644 index 0000000000000..fc72a04ca421a --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsProperties.java @@ -0,0 +1,73 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls.constants; + +import org.apache.camel.spi.Metadata; + +public final class AlibabaSlsProperties { + + @Metadata(label = "producer", description = "Operation to perform", javaType = "String") + public static final String OPERATION = "CamelAlibabaSlsOperation"; + + @Metadata(label = "producer", description = "SLS project name override", javaType = "String") + public static final String PROJECT = "CamelAlibabaSlsProject"; + + @Metadata(label = "producer", description = "SLS log store name override", javaType = "String") + public static final String LOG_STORE_NAME = "CamelAlibabaSlsLogStoreName"; + + @Metadata(label = "producer", description = "Log query string override", javaType = "String") + public static final String QUERY = "CamelAlibabaSlsQuery"; + + @Metadata(label = "producer", description = "Query start time override (Unix timestamp in seconds)", javaType = "Integer") + public static final String FROM = "CamelAlibabaSlsFrom"; + + @Metadata(label = "producer", description = "Query end time override (Unix timestamp in seconds)", javaType = "Integer") + public static final String TO = "CamelAlibabaSlsTo"; + + @Metadata(label = "producer", description = "Maximum number of log lines to return", javaType = "Long") + public static final String LINE = "CamelAlibabaSlsLine"; + + @Metadata(label = "producer", description = "Log query offset", javaType = "Long") + public static final String OFFSET = "CamelAlibabaSlsOffset"; + + @Metadata(label = "producer", description = "Log topic filter override", javaType = "String") + public static final String TOPIC = "CamelAlibabaSlsTopic"; + + @Metadata(label = "producer", description = "Whether to return logs in reverse order", javaType = "Boolean") + public static final String REVERSE = "CamelAlibabaSlsReverse"; + + @Metadata(label = "producer", description = "Log store name prefix filter for listLogStores", javaType = "String") + public static final String LOGSTORE_NAME = "CamelAlibabaSlsLogstoreName"; + + @Metadata(label = "producer", description = "List mode for listLogStores", javaType = "String") + public static final String MODE = "CamelAlibabaSlsMode"; + + @Metadata(label = "producer", description = "Page size for listLogStores", javaType = "Integer") + public static final String SIZE = "CamelAlibabaSlsSize"; + + @Metadata(label = "producer", description = "Telemetry type filter for listLogStores", javaType = "String") + public static final String TELEMETRY_TYPE = "CamelAlibabaSlsTelemetryType"; + + @Metadata(label = "producer", description = "Request id returned by SLS", javaType = "String") + public static final String REQUEST_ID = "CamelAlibabaSlsRequestId"; + + @Metadata(label = "producer", description = "HTTP status code from SLS response", javaType = "Integer") + public static final String STATUS_CODE = "CamelAlibabaSlsStatusCode"; + + private AlibabaSlsProperties() { + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/models/ClientConfigurations.java b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/models/ClientConfigurations.java new file mode 100644 index 0000000000000..4353002a1ee48 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/models/ClientConfigurations.java @@ -0,0 +1,156 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls.models; + +public class ClientConfigurations { + + private String operation; + private String project; + private String logStoreName; + private String query; + private Integer from; + private Integer to; + private Long line; + private Long offset; + private String topic; + private Boolean reverse; + private String logstoreName; + private String mode; + private Integer listOffset; + private Integer size; + private String telemetryType; + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public String getLogStoreName() { + return logStoreName; + } + + public void setLogStoreName(String logStoreName) { + this.logStoreName = logStoreName; + } + + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public Integer getFrom() { + return from; + } + + public void setFrom(Integer from) { + this.from = from; + } + + public Integer getTo() { + return to; + } + + public void setTo(Integer to) { + this.to = to; + } + + public Long getLine() { + return line; + } + + public void setLine(Long line) { + this.line = line; + } + + public Long getOffset() { + return offset; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public Boolean getReverse() { + return reverse; + } + + public void setReverse(Boolean reverse) { + this.reverse = reverse; + } + + public String getLogstoreName() { + return logstoreName; + } + + public void setLogstoreName(String logstoreName) { + this.logstoreName = logstoreName; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public Integer getListOffset() { + return listOffset; + } + + public void setListOffset(Integer listOffset) { + this.listOffset = listOffset; + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } + + public String getTelemetryType() { + return telemetryType; + } + + public void setTelemetryType(String telemetryType) { + this.telemetryType = telemetryType; + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpointTest.java b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpointTest.java new file mode 100644 index 0000000000000..09a60440f3dbd --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpointTest.java @@ -0,0 +1,55 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls; + +import com.aliyun.sls20201230.Client; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +class AlibabaSlsEndpointTest { + + @Test + void doStopKeepsAutowiredClient() throws Exception { + AlibabaSlsEndpoint endpoint = new AlibabaSlsEndpoint(); + Client client = mock(Client.class); + endpoint.setSlsClient(client); + + endpoint.doStop(); + + assertThat(endpoint.getSlsClient()).isSameAs(client); + } + + @Test + void doStopClearsOwnedClient() throws Exception { + AlibabaSlsEndpoint endpoint = new AlibabaSlsEndpoint(); + Client client = mock(Client.class); + + var clientField = AlibabaSlsEndpoint.class.getDeclaredField("slsClient"); + clientField.setAccessible(true); + clientField.set(endpoint, client); + + var autowiredField = AlibabaSlsEndpoint.class.getDeclaredField("autowiredSlsClient"); + autowiredField.setAccessible(true); + autowiredField.setBoolean(endpoint, false); + + endpoint.doStop(); + + assertThat(endpoint.getSlsClient()).isNull(); + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/AlibabaSlsProducerTest.java b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/AlibabaSlsProducerTest.java new file mode 100644 index 0000000000000..16df06c057baa --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/AlibabaSlsProducerTest.java @@ -0,0 +1,56 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls; + +import com.aliyun.sls20201230.Client; +import com.aliyun.sls20201230.models.ListLogStoresRequest; +import com.aliyun.sls20201230.models.ListLogStoresResponse; +import org.apache.camel.support.DefaultExchange; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class AlibabaSlsProducerTest extends CamelTestSupport { + + @Test + void processReinitializesClientFromEndpointOnEachExchange() throws Exception { + AlibabaSlsEndpoint endpoint = mock(AlibabaSlsEndpoint.class); + when(endpoint.getOperation()).thenReturn("listLogStores"); + when(endpoint.getProject()).thenReturn("demo-project"); + when(endpoint.getCamelContext()).thenReturn(context); + + Client firstClient = mock(Client.class); + Client secondClient = mock(Client.class); + when(endpoint.initClient()).thenReturn(firstClient, secondClient); + + ListLogStoresResponse response = new ListLogStoresResponse(); + when(firstClient.listLogStores(eq("demo-project"), any(ListLogStoresRequest.class))).thenReturn(response); + when(secondClient.listLogStores(eq("demo-project"), any(ListLogStoresRequest.class))).thenReturn(response); + + AlibabaSlsProducer producer = new AlibabaSlsProducer(endpoint); + producer.process(new DefaultExchange(context)); + producer.process(new DefaultExchange(context)); + + verify(firstClient).listLogStores(eq("demo-project"), any(ListLogStoresRequest.class)); + verify(secondClient).listLogStores(eq("demo-project"), any(ListLogStoresRequest.class)); + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/GetLogsTest.java b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/GetLogsTest.java new file mode 100644 index 0000000000000..c9d2e8d30ece4 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/GetLogsTest.java @@ -0,0 +1,102 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import com.aliyun.sls20201230.Client; +import com.aliyun.sls20201230.models.GetLogsRequest; +import com.aliyun.sls20201230.models.GetLogsResponse; +import org.apache.camel.BindToRegistry; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class GetLogsTest extends CamelTestSupport { + + private final TestConfiguration testConfiguration = new TestConfiguration(); + + @BindToRegistry("slsClient") + Client slsClient = mock(Client.class); + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:getLogs") + .to("alibaba-sls:getLogs" + + "?project=" + testConfiguration.getProperty("project") + + "&logStoreName=" + testConfiguration.getProperty("logStoreName") + + "®ion=" + testConfiguration.getProperty("region") + + "&endpoint=" + testConfiguration.getProperty("endpoint") + + "&accessKey=" + testConfiguration.getProperty("accessKey") + + "&secretKey=" + testConfiguration.getProperty("secretKey") + + "&query=*" + + "&from=1700000000" + + "&to=1700003600" + + "&line=100" + + "&slsClient=#slsClient") + .to("mock:result"); + } + }; + } + + @Test + void testGetLogs() throws Exception { + GetLogsResponse response = new GetLogsResponse(); + response.setStatusCode(200); + response.setHeaders(Collections.singletonMap("x-log-requestid", "req-456")); + response.setBody(List.of(Map.of("message", "log line"))); + + when(slsClient.getLogs( + eq(testConfiguration.getProperty("project")), + eq(testConfiguration.getProperty("logStoreName")), + any(GetLogsRequest.class))).thenReturn(response); + + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + + template.sendBody("direct:getLogs", null); + + mock.assertIsSatisfied(); + + Exchange exchange = mock.getExchanges().get(0); + assertThat(exchange.getMessage().getBody(Map.class)) + .containsEntry("statusCode", 200) + .containsEntry("body", List.of(Map.of("message", "log line"))); + assertThat(exchange.getMessage().getHeader(AlibabaSlsHeaders.STATUS_CODE)).isEqualTo(200); + assertThat(exchange.getMessage().getHeader(AlibabaSlsHeaders.REQUEST_ID)).isEqualTo("req-456"); + + verify(slsClient).getLogs( + eq(testConfiguration.getProperty("project")), + eq(testConfiguration.getProperty("logStoreName")), + any(GetLogsRequest.class)); + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/ListLogStoresTest.java b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/ListLogStoresTest.java new file mode 100644 index 0000000000000..aab77404044fa --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/ListLogStoresTest.java @@ -0,0 +1,101 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import com.aliyun.sls20201230.Client; +import com.aliyun.sls20201230.models.ListLogStoresRequest; +import com.aliyun.sls20201230.models.ListLogStoresResponse; +import com.aliyun.sls20201230.models.ListLogStoresResponseBody; +import org.apache.camel.BindToRegistry; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class ListLogStoresTest extends CamelTestSupport { + + private final TestConfiguration testConfiguration = new TestConfiguration(); + + @BindToRegistry("slsClient") + Client slsClient = mock(Client.class); + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:listLogStores") + .to("alibaba-sls:listLogStores" + + "?project=" + testConfiguration.getProperty("project") + + "®ion=" + testConfiguration.getProperty("region") + + "&endpoint=" + testConfiguration.getProperty("endpoint") + + "&accessKey=" + testConfiguration.getProperty("accessKey") + + "&secretKey=" + testConfiguration.getProperty("secretKey") + + "&slsClient=#slsClient") + .to("mock:result"); + } + }; + } + + @Test + void testListLogStores() throws Exception { + ListLogStoresResponse response = new ListLogStoresResponse(); + response.setStatusCode(200); + response.setHeaders(Collections.singletonMap("x-log-requestid", "req-789")); + response.setBody(new ListLogStoresResponseBody() + .setCount(2) + .setTotal(2) + .setLogstores(List.of("logstore-a", "logstore-b"))); + + when(slsClient.listLogStores( + eq(testConfiguration.getProperty("project")), + any(ListLogStoresRequest.class))).thenReturn(response); + + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + + template.sendBody("direct:listLogStores", null); + + mock.assertIsSatisfied(); + + Exchange exchange = mock.getExchanges().get(0); + assertThat(exchange.getMessage().getBody(Map.class)) + .containsEntry("statusCode", 200) + .containsEntry("count", 2) + .containsEntry("total", 2) + .containsEntry("logstores", List.of("logstore-a", "logstore-b")); + assertThat(exchange.getMessage().getHeader(AlibabaSlsHeaders.STATUS_CODE)).isEqualTo(200); + assertThat(exchange.getMessage().getHeader(AlibabaSlsHeaders.REQUEST_ID)).isEqualTo("req-789"); + + verify(slsClient).listLogStores( + eq(testConfiguration.getProperty("project")), + any(ListLogStoresRequest.class)); + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/PutLogsTest.java b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/PutLogsTest.java new file mode 100644 index 0000000000000..4929ca6826049 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/PutLogsTest.java @@ -0,0 +1,104 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import com.aliyun.sls20201230.Client; +import com.aliyun.sls20201230.models.LogContent; +import com.aliyun.sls20201230.models.LogGroup; +import com.aliyun.sls20201230.models.LogItem; +import com.aliyun.sls20201230.models.PutLogsRequest; +import com.aliyun.sls20201230.models.PutLogsResponse; +import org.apache.camel.BindToRegistry; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class PutLogsTest extends CamelTestSupport { + + private final TestConfiguration testConfiguration = new TestConfiguration(); + + @BindToRegistry("slsClient") + Client slsClient = mock(Client.class); + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:putLogs") + .to("alibaba-sls:putLogs" + + "?project=" + testConfiguration.getProperty("project") + + "&logStoreName=" + testConfiguration.getProperty("logStoreName") + + "®ion=" + testConfiguration.getProperty("region") + + "&endpoint=" + testConfiguration.getProperty("endpoint") + + "&accessKey=" + testConfiguration.getProperty("accessKey") + + "&secretKey=" + testConfiguration.getProperty("secretKey") + + "&slsClient=#slsClient") + .to("mock:result"); + } + }; + } + + @Test + void testPutLogsWithLogGroup() throws Exception { + PutLogsResponse response = new PutLogsResponse(); + response.setStatusCode(200); + response.setHeaders(Collections.singletonMap("x-log-requestid", "req-123")); + + when(slsClient.putLogs( + eq(testConfiguration.getProperty("project")), + eq(testConfiguration.getProperty("logStoreName")), + any(PutLogsRequest.class))).thenReturn(response); + + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + + LogGroup logGroup = new LogGroup() + .setTopic("test-topic") + .setLogItems(List.of(new LogItem() + .setTime(1700000000) + .setContents(List.of(new LogContent().setKey("message").setValue("hello sls"))))); + template.sendBody("direct:putLogs", logGroup); + + mock.assertIsSatisfied(); + + Exchange exchange = mock.getExchanges().get(0); + assertThat(exchange.getMessage().getBody(Map.class)) + .containsEntry("statusCode", 200); + assertThat(exchange.getMessage().getHeader(AlibabaSlsHeaders.STATUS_CODE)).isEqualTo(200); + assertThat(exchange.getMessage().getHeader(AlibabaSlsHeaders.REQUEST_ID)).isEqualTo("req-123"); + + verify(slsClient).putLogs( + eq(testConfiguration.getProperty("project")), + eq(testConfiguration.getProperty("logStoreName")), + any(PutLogsRequest.class)); + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/TestConfiguration.java b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/TestConfiguration.java new file mode 100644 index 0000000000000..8e553e707f829 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/TestConfiguration.java @@ -0,0 +1,57 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.apache.camel.test.junit6.TestSupport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class TestConfiguration { + + private static final Logger LOGGER = LoggerFactory.getLogger(TestConfiguration.class); + private static Map propertyMap; + + TestConfiguration() { + initPropertyMap(); + } + + void initPropertyMap() { + if (propertyMap == null) { + propertyMap = new HashMap<>(); + String propertyFileName = "testconfiguration.properties"; + try { + Properties properties = TestSupport.loadExternalProperties(getClass().getClassLoader(), propertyFileName); + for (String key : properties.stringPropertyNames()) { + propertyMap.put(key, properties.getProperty(key)); + } + } catch (Exception e) { + LOGGER.error("Cannot load property file {}, reason {}", propertyFileName, e.getMessage()); + } + } + } + + String getProperty(String key) { + if (propertyMap == null) { + initPropertyMap(); + } + return propertyMap.get(key); + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsOperationsTest.java b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsOperationsTest.java new file mode 100644 index 0000000000000..c6d60d68065f8 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/test/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsOperationsTest.java @@ -0,0 +1,31 @@ +/* + * 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. + */ +package org.apache.camel.component.alibaba.sls.constants; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class AlibabaSlsOperationsTest { + + @Test + void testOperationNames() { + assertThat(AlibabaSlsOperations.PUT_LOGS).isEqualTo("putLogs"); + assertThat(AlibabaSlsOperations.GET_LOGS).isEqualTo("getLogs"); + assertThat(AlibabaSlsOperations.LIST_LOG_STORES).isEqualTo("listLogStores"); + } +} diff --git a/components/camel-alibaba/camel-alibaba-sls/src/test/resources/log4j2.properties b/components/camel-alibaba/camel-alibaba-sls/src/test/resources/log4j2.properties new file mode 100644 index 0000000000000..47e9930b6978a --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +appender.file.type = File +appender.file.name = file +appender.file.fileName = target/camel-alibaba-sls-test.log +appender.file.layout.type = PatternLayout +appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.out.type = Console +appender.out.name = out +appender.out.layout.type = PatternLayout +appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n + +rootLogger.level = INFO +rootLogger.appenderRef.file.ref = file diff --git a/components/camel-alibaba/camel-alibaba-sls/src/test/resources/testconfiguration.properties b/components/camel-alibaba/camel-alibaba-sls/src/test/resources/testconfiguration.properties new file mode 100644 index 0000000000000..b275df612f150 --- /dev/null +++ b/components/camel-alibaba/camel-alibaba-sls/src/test/resources/testconfiguration.properties @@ -0,0 +1,23 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +accessKey=dummy_access_key +secretKey=dummy_secret_key +region=cn-hangzhou +endpoint=cn-hangzhou.log.aliyuncs.com +project=test-project +logStoreName=test-logstore diff --git a/components/camel-alibaba/pom.xml b/components/camel-alibaba/pom.xml index a29e2459fc41e..147c44c66c3dc 100644 --- a/components/camel-alibaba/pom.xml +++ b/components/camel-alibaba/pom.xml @@ -39,7 +39,9 @@ camel-alibaba-fc camel-alibaba-sms camel-alibaba-kms + camel-alibaba-sls camel-alibaba-eventbridge + camel-alibaba-ots diff --git a/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties b/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties index 6b481121cb525..eb2f0cb47a420 100644 --- a/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties +++ b/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties @@ -7,6 +7,8 @@ alibaba-fc alibaba-kms alibaba-mns alibaba-oss +alibaba-ots +alibaba-sls alibaba-sms amqp arangodb diff --git a/coverage/pom.xml b/coverage/pom.xml index 4c258f5b1653f..198495acce49c 100644 --- a/coverage/pom.xml +++ b/coverage/pom.xml @@ -251,6 +251,16 @@ camel-alibaba-oss ${project.version} + + org.apache.camel + camel-alibaba-ots + ${project.version} + + + org.apache.camel + camel-alibaba-sls + ${project.version} + org.apache.camel camel-alibaba-sms diff --git a/docs/components/modules/ROOT/examples/json/alibaba-ots.json b/docs/components/modules/ROOT/examples/json/alibaba-ots.json new file mode 120000 index 0000000000000..3a81b0bd71579 --- /dev/null +++ b/docs/components/modules/ROOT/examples/json/alibaba-ots.json @@ -0,0 +1 @@ +../../../../../../components/camel-alibaba/camel-alibaba-ots/src/generated/resources/META-INF/org/apache/camel/component/alibaba/ots/alibaba-ots.json \ No newline at end of file diff --git a/docs/components/modules/ROOT/examples/json/alibaba-sls.json b/docs/components/modules/ROOT/examples/json/alibaba-sls.json new file mode 120000 index 0000000000000..c448c257d4fac --- /dev/null +++ b/docs/components/modules/ROOT/examples/json/alibaba-sls.json @@ -0,0 +1 @@ +../../../../../../components/camel-alibaba/camel-alibaba-sls/src/generated/resources/META-INF/org/apache/camel/component/alibaba/sls/alibaba-sls.json \ No newline at end of file diff --git a/docs/components/modules/ROOT/nav.adoc b/docs/components/modules/ROOT/nav.adoc index 0d37ea8a53d96..6d4ad09db8c0a 100644 --- a/docs/components/modules/ROOT/nav.adoc +++ b/docs/components/modules/ROOT/nav.adoc @@ -37,6 +37,8 @@ *** xref:alibaba-mns-component.adoc[Alibaba Message Service (MNS)] *** xref:alibaba-oss-component.adoc[Alibaba Object Storage Service (OSS)] *** xref:alibaba-sms-component.adoc[Alibaba Short Message Service (SMS)] +*** xref:alibaba-sls-component.adoc[Alibaba Simple Log Service (SLS)] +*** xref:alibaba-ots-component.adoc[Alibaba Tablestore (OTS)] ** xref:amqp-component.adoc[AMQP] ** xref:arangodb-component.adoc[ArangoDb] ** xref:as2-component.adoc[AS2] diff --git a/docs/components/modules/ROOT/pages/alibaba-ots-component.adoc b/docs/components/modules/ROOT/pages/alibaba-ots-component.adoc new file mode 120000 index 0000000000000..34d6bef2933b2 --- /dev/null +++ b/docs/components/modules/ROOT/pages/alibaba-ots-component.adoc @@ -0,0 +1 @@ +../../../../../components/camel-alibaba/camel-alibaba-ots/src/main/docs/alibaba-ots-component.adoc \ No newline at end of file diff --git a/docs/components/modules/ROOT/pages/alibaba-sls-component.adoc b/docs/components/modules/ROOT/pages/alibaba-sls-component.adoc new file mode 120000 index 0000000000000..cb32a4e227a73 --- /dev/null +++ b/docs/components/modules/ROOT/pages/alibaba-sls-component.adoc @@ -0,0 +1 @@ +../../../../../components/camel-alibaba/camel-alibaba-sls/src/main/docs/alibaba-sls-component.adoc \ No newline at end of file diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java index 8b70341543930..e461b69cdf0ac 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java @@ -166,6 +166,32 @@ static AlibabaMnsComponentBuilderFactory.AlibabaMnsComponentBuilder alibabaMns() static AlibabaOssComponentBuilderFactory.AlibabaOssComponentBuilder alibabaOss() { return AlibabaOssComponentBuilderFactory.alibabaOss(); } + /** + * Alibaba Tablestore (OTS) (camel-alibaba-ots) + * Perform row operations on Alibaba Cloud Tablestore (OTS). + * + * Category: cloud,database + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-ots + * + * @return the dsl builder + */ + static AlibabaOtsComponentBuilderFactory.AlibabaOtsComponentBuilder alibabaOts() { + return AlibabaOtsComponentBuilderFactory.alibabaOts(); + } + /** + * Alibaba Simple Log Service (SLS) (camel-alibaba-sls) + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + * + * Category: cloud,monitoring + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-sls + * + * @return the dsl builder + */ + static AlibabaSlsComponentBuilderFactory.AlibabaSlsComponentBuilder alibabaSls() { + return AlibabaSlsComponentBuilderFactory.alibabaSls(); + } /** * Alibaba Short Message Service (SMS) (camel-alibaba-sms) * Send SMS messages using Alibaba Cloud Short Message Service (SMS). diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AlibabaOtsComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AlibabaOtsComponentBuilderFactory.java new file mode 100644 index 0000000000000..6bc2d4b848a91 --- /dev/null +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AlibabaOtsComponentBuilderFactory.java @@ -0,0 +1,160 @@ +/* Generated by camel build tools - do NOT edit this file! */ +/* + * 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. + */ +package org.apache.camel.builder.component.dsl; + +import javax.annotation.processing.Generated; +import org.apache.camel.Component; +import org.apache.camel.builder.component.AbstractComponentBuilder; +import org.apache.camel.builder.component.ComponentBuilder; +import org.apache.camel.component.alibaba.ots.AlibabaOtsComponent; + +/** + * Perform row operations on Alibaba Cloud Tablestore (OTS). + * + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.ComponentDslMojo") +public interface AlibabaOtsComponentBuilderFactory { + + /** + * Alibaba Tablestore (OTS) (camel-alibaba-ots) + * Perform row operations on Alibaba Cloud Tablestore (OTS). + * + * Category: cloud,database + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-ots + * + * @return the dsl builder + */ + static AlibabaOtsComponentBuilder alibabaOts() { + return new AlibabaOtsComponentBuilderImpl(); + } + + /** + * Builder for the Alibaba Tablestore (OTS) component. + */ + interface AlibabaOtsComponentBuilder extends ComponentBuilder { + + + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: producer + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AlibabaOtsComponentBuilder lazyStartProducer(boolean lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + + + /** + * Whether autowiring is enabled. This is used for automatic autowiring + * options (the option must be marked as autowired) by looking up in the + * registry to find if there is a single instance of matching type, + * which then gets configured on the component. This can be used for + * automatic configuring JDBC data sources, JMS connection factories, + * AWS Clients, etc. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: advanced + * + * @param autowiredEnabled the value to set + * @return the dsl builder + */ + default AlibabaOtsComponentBuilder autowiredEnabled(boolean autowiredEnabled) { + doSetProperty("autowiredEnabled", autowiredEnabled); + return this; + } + + + /** + * Used for enabling or disabling all consumer based health checks from + * this component. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: health + * + * @param healthCheckConsumerEnabled the value to set + * @return the dsl builder + */ + default AlibabaOtsComponentBuilder healthCheckConsumerEnabled(boolean healthCheckConsumerEnabled) { + doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled); + return this; + } + + + /** + * Used for enabling or disabling all producer based health checks from + * this component. Notice: Camel has by default disabled all producer + * based health-checks. You can turn on producer checks globally by + * setting camel.health.producersEnabled=true. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: health + * + * @param healthCheckProducerEnabled the value to set + * @return the dsl builder + */ + default AlibabaOtsComponentBuilder healthCheckProducerEnabled(boolean healthCheckProducerEnabled) { + doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled); + return this; + } + } + + class AlibabaOtsComponentBuilderImpl + extends AbstractComponentBuilder + implements AlibabaOtsComponentBuilder { + @Override + protected AlibabaOtsComponent buildConcreteComponent() { + return new AlibabaOtsComponent(); + } + @Override + protected boolean setPropertyOnComponent( + Component component, + String name, + Object value) { + switch (name) { + case "lazyStartProducer": ((AlibabaOtsComponent) component).setLazyStartProducer((boolean) value); return true; + case "autowiredEnabled": ((AlibabaOtsComponent) component).setAutowiredEnabled((boolean) value); return true; + case "healthCheckConsumerEnabled": ((AlibabaOtsComponent) component).setHealthCheckConsumerEnabled((boolean) value); return true; + case "healthCheckProducerEnabled": ((AlibabaOtsComponent) component).setHealthCheckProducerEnabled((boolean) value); return true; + default: return false; + } + } + } +} \ No newline at end of file diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AlibabaSlsComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AlibabaSlsComponentBuilderFactory.java new file mode 100644 index 0000000000000..ebaa93021f064 --- /dev/null +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AlibabaSlsComponentBuilderFactory.java @@ -0,0 +1,160 @@ +/* Generated by camel build tools - do NOT edit this file! */ +/* + * 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. + */ +package org.apache.camel.builder.component.dsl; + +import javax.annotation.processing.Generated; +import org.apache.camel.Component; +import org.apache.camel.builder.component.AbstractComponentBuilder; +import org.apache.camel.builder.component.ComponentBuilder; +import org.apache.camel.component.alibaba.sls.AlibabaSlsComponent; + +/** + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + * + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.ComponentDslMojo") +public interface AlibabaSlsComponentBuilderFactory { + + /** + * Alibaba Simple Log Service (SLS) (camel-alibaba-sls) + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + * + * Category: cloud,monitoring + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-sls + * + * @return the dsl builder + */ + static AlibabaSlsComponentBuilder alibabaSls() { + return new AlibabaSlsComponentBuilderImpl(); + } + + /** + * Builder for the Alibaba Simple Log Service (SLS) component. + */ + interface AlibabaSlsComponentBuilder extends ComponentBuilder { + + + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: producer + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AlibabaSlsComponentBuilder lazyStartProducer(boolean lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + + + /** + * Whether autowiring is enabled. This is used for automatic autowiring + * options (the option must be marked as autowired) by looking up in the + * registry to find if there is a single instance of matching type, + * which then gets configured on the component. This can be used for + * automatic configuring JDBC data sources, JMS connection factories, + * AWS Clients, etc. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: advanced + * + * @param autowiredEnabled the value to set + * @return the dsl builder + */ + default AlibabaSlsComponentBuilder autowiredEnabled(boolean autowiredEnabled) { + doSetProperty("autowiredEnabled", autowiredEnabled); + return this; + } + + + /** + * Used for enabling or disabling all consumer based health checks from + * this component. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: health + * + * @param healthCheckConsumerEnabled the value to set + * @return the dsl builder + */ + default AlibabaSlsComponentBuilder healthCheckConsumerEnabled(boolean healthCheckConsumerEnabled) { + doSetProperty("healthCheckConsumerEnabled", healthCheckConsumerEnabled); + return this; + } + + + /** + * Used for enabling or disabling all producer based health checks from + * this component. Notice: Camel has by default disabled all producer + * based health-checks. You can turn on producer checks globally by + * setting camel.health.producersEnabled=true. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: health + * + * @param healthCheckProducerEnabled the value to set + * @return the dsl builder + */ + default AlibabaSlsComponentBuilder healthCheckProducerEnabled(boolean healthCheckProducerEnabled) { + doSetProperty("healthCheckProducerEnabled", healthCheckProducerEnabled); + return this; + } + } + + class AlibabaSlsComponentBuilderImpl + extends AbstractComponentBuilder + implements AlibabaSlsComponentBuilder { + @Override + protected AlibabaSlsComponent buildConcreteComponent() { + return new AlibabaSlsComponent(); + } + @Override + protected boolean setPropertyOnComponent( + Component component, + String name, + Object value) { + switch (name) { + case "lazyStartProducer": ((AlibabaSlsComponent) component).setLazyStartProducer((boolean) value); return true; + case "autowiredEnabled": ((AlibabaSlsComponent) component).setAutowiredEnabled((boolean) value); return true; + case "healthCheckConsumerEnabled": ((AlibabaSlsComponent) component).setHealthCheckConsumerEnabled((boolean) value); return true; + case "healthCheckProducerEnabled": ((AlibabaSlsComponent) component).setHealthCheckProducerEnabled((boolean) value); return true; + default: return false; + } + } + } +} \ No newline at end of file diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java index edc7c01f4c844..4a9a1dc834244 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java @@ -39,6 +39,8 @@ public interface EndpointBuilderFactory org.apache.camel.builder.endpoint.dsl.ActiveMQEndpointBuilderFactory.ActiveMQBuilders, org.apache.camel.builder.endpoint.dsl.AiToolEndpointBuilderFactory.AiToolBuilders, org.apache.camel.builder.endpoint.dsl.AlibabaEventBridgeEndpointBuilderFactory.AlibabaEventBridgeBuilders, + org.apache.camel.builder.endpoint.dsl.AlibabaOtsEndpointBuilderFactory.AlibabaOtsBuilders, + org.apache.camel.builder.endpoint.dsl.AlibabaSlsEndpointBuilderFactory.AlibabaSlsBuilders, org.apache.camel.builder.endpoint.dsl.ArangoDbEndpointBuilderFactory.ArangoDbBuilders, org.apache.camel.builder.endpoint.dsl.AsteriskEndpointBuilderFactory.AsteriskBuilders, org.apache.camel.builder.endpoint.dsl.Athena2EndpointBuilderFactory.Athena2Builders, diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java index b3a69be4660ea..7df3e98d43845 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java @@ -36,6 +36,8 @@ public interface EndpointBuilders org.apache.camel.builder.endpoint.dsl.ActiveMQEndpointBuilderFactory, org.apache.camel.builder.endpoint.dsl.AiToolEndpointBuilderFactory, org.apache.camel.builder.endpoint.dsl.AlibabaEventBridgeEndpointBuilderFactory, + org.apache.camel.builder.endpoint.dsl.AlibabaOtsEndpointBuilderFactory, + org.apache.camel.builder.endpoint.dsl.AlibabaSlsEndpointBuilderFactory, org.apache.camel.builder.endpoint.dsl.ArangoDbEndpointBuilderFactory, org.apache.camel.builder.endpoint.dsl.AsteriskEndpointBuilderFactory, org.apache.camel.builder.endpoint.dsl.Athena2EndpointBuilderFactory, diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointHeaderBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointHeaderBuilders.java index ce9deaf4731e4..0816f4b65053c 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointHeaderBuilders.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointHeaderBuilders.java @@ -145,6 +145,32 @@ public static MNSEndpointBuilderFactory.MNSHeaderNameBuilder alibabaMns() { public static OSSEndpointBuilderFactory.OSSHeaderNameBuilder alibabaOss() { return OSSEndpointBuilderFactory.OSSHeaderNameBuilder.INSTANCE; } + /** + * Alibaba Tablestore (OTS) (camel-alibaba-ots) + * Perform row operations on Alibaba Cloud Tablestore (OTS). + * + * Category: cloud,database + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-ots + * + * @return the dsl builder for the headers' name. + */ + public static AlibabaOtsEndpointBuilderFactory.AlibabaOtsHeaderNameBuilder alibabaOts() { + return AlibabaOtsEndpointBuilderFactory.AlibabaOtsHeaderNameBuilder.INSTANCE; + } + /** + * Alibaba Simple Log Service (SLS) (camel-alibaba-sls) + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + * + * Category: cloud,monitoring + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-sls + * + * @return the dsl builder for the headers' name. + */ + public static AlibabaSlsEndpointBuilderFactory.AlibabaSlsHeaderNameBuilder alibabaSls() { + return AlibabaSlsEndpointBuilderFactory.AlibabaSlsHeaderNameBuilder.INSTANCE; + } /** * Alibaba Short Message Service (SMS) (camel-alibaba-sms) * Send SMS messages using Alibaba Cloud Short Message Service (SMS). diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java index 1de2236fc4628..fdbd3d03db9e4 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java @@ -430,6 +430,94 @@ public static OSSEndpointBuilderFactory.OSSEndpointBuilder alibabaOss(String pat public static OSSEndpointBuilderFactory.OSSEndpointBuilder alibabaOss(String componentName, String path) { return OSSEndpointBuilderFactory.endpointBuilder(componentName, path); } + /** + * Alibaba Tablestore (OTS) (camel-alibaba-ots) + * Perform row operations on Alibaba Cloud Tablestore (OTS). + * + * Category: cloud,database + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-ots + * + * Syntax: alibaba-ots:operation + * + * Path parameter: operation (required) + * Operation to perform + * There are 5 enums and the value can be one of: putRow, getRow, updateRow, + * deleteRow, listTables + * + * @param path operation + * @return the dsl builder + */ + public static AlibabaOtsEndpointBuilderFactory.AlibabaOtsEndpointBuilder alibabaOts(String path) { + return alibabaOts("alibaba-ots", path); + } + /** + * Alibaba Tablestore (OTS) (camel-alibaba-ots) + * Perform row operations on Alibaba Cloud Tablestore (OTS). + * + * Category: cloud,database + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-ots + * + * Syntax: alibaba-ots:operation + * + * Path parameter: operation (required) + * Operation to perform + * There are 5 enums and the value can be one of: putRow, getRow, updateRow, + * deleteRow, listTables + * + * @param componentName to use a custom component name for the endpoint + * instead of the default name + * @param path operation + * @return the dsl builder + */ + public static AlibabaOtsEndpointBuilderFactory.AlibabaOtsEndpointBuilder alibabaOts(String componentName, String path) { + return AlibabaOtsEndpointBuilderFactory.endpointBuilder(componentName, path); + } + /** + * Alibaba Simple Log Service (SLS) (camel-alibaba-sls) + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + * + * Category: cloud,monitoring + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-sls + * + * Syntax: alibaba-sls:operation + * + * Path parameter: operation (required) + * Operation to perform + * There are 3 enums and the value can be one of: putLogs, getLogs, + * listLogStores + * + * @param path operation + * @return the dsl builder + */ + public static AlibabaSlsEndpointBuilderFactory.AlibabaSlsEndpointBuilder alibabaSls(String path) { + return alibabaSls("alibaba-sls", path); + } + /** + * Alibaba Simple Log Service (SLS) (camel-alibaba-sls) + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + * + * Category: cloud,monitoring + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-sls + * + * Syntax: alibaba-sls:operation + * + * Path parameter: operation (required) + * Operation to perform + * There are 3 enums and the value can be one of: putLogs, getLogs, + * listLogStores + * + * @param componentName to use a custom component name for the endpoint + * instead of the default name + * @param path operation + * @return the dsl builder + */ + public static AlibabaSlsEndpointBuilderFactory.AlibabaSlsEndpointBuilder alibabaSls(String componentName, String path) { + return AlibabaSlsEndpointBuilderFactory.endpointBuilder(componentName, path); + } /** * Alibaba Short Message Service (SMS) (camel-alibaba-sms) * Send SMS messages using Alibaba Cloud Short Message Service (SMS). diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AlibabaOtsEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AlibabaOtsEndpointBuilderFactory.java new file mode 100644 index 0000000000000..27fc511b99fed --- /dev/null +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AlibabaOtsEndpointBuilderFactory.java @@ -0,0 +1,328 @@ +/* Generated by camel build tools - do NOT edit this file! */ +/* + * 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. + */ +package org.apache.camel.builder.endpoint.dsl; + +import java.util.*; +import java.util.concurrent.*; +import java.util.function.*; +import java.util.stream.*; +import javax.annotation.processing.Generated; +import org.apache.camel.builder.EndpointConsumerBuilder; +import org.apache.camel.builder.EndpointProducerBuilder; +import org.apache.camel.builder.endpoint.AbstractEndpointBuilder; + +/** + * Perform row operations on Alibaba Cloud Tablestore (OTS). + * + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointDslMojo") +public interface AlibabaOtsEndpointBuilderFactory { + + /** + * Builder for endpoint for the Alibaba Tablestore (OTS) component. + */ + public interface AlibabaOtsEndpointBuilder + extends + EndpointProducerBuilder { + default AdvancedAlibabaOtsEndpointBuilder advanced() { + return (AdvancedAlibabaOtsEndpointBuilder) this; + } + + /** + * Tablestore endpoint URL. + * + * The option is a: java.lang.String type. + * + * Required: true + * Group: producer + * + * @param endpoint the value to set + * @return the dsl builder + */ + default AlibabaOtsEndpointBuilder endpoint(String endpoint) { + doSetProperty("endpoint", endpoint); + return this; + } + /** + * Tablestore instance name. + * + * The option is a: java.lang.String type. + * + * Required: true + * Group: producer + * + * @param instanceName the value to set + * @return the dsl builder + */ + default AlibabaOtsEndpointBuilder instanceName(String instanceName) { + doSetProperty("instanceName", instanceName); + return this; + } + /** + * Access key for the cloud user. + * + * The option is a: java.lang.String type. + * + * Group: security + * + * @param accessKey the value to set + * @return the dsl builder + */ + default AlibabaOtsEndpointBuilder accessKey(String accessKey) { + doSetProperty("accessKey", accessKey); + return this; + } + /** + * Secret key for the cloud user. + * + * The option is a: java.lang.String type. + * + * Group: security + * + * @param secretKey the value to set + * @return the dsl builder + */ + default AlibabaOtsEndpointBuilder secretKey(String secretKey) { + doSetProperty("secretKey", secretKey); + return this; + } + /** + * Configuration object for cloud service authentication. + * + * The option is a: + * org.apache.camel.component.alibaba.common.models.ServiceKeys type. + * + * Group: security + * + * @param serviceKeys the value to set + * @return the dsl builder + */ + default AlibabaOtsEndpointBuilder serviceKeys(org.apache.camel.component.alibaba.common.models.ServiceKeys serviceKeys) { + doSetProperty("serviceKeys", serviceKeys); + return this; + } + /** + * Configuration object for cloud service authentication. + * + * The option will be converted to a + * org.apache.camel.component.alibaba.common.models.ServiceKeys type. + * + * Group: security + * + * @param serviceKeys the value to set + * @return the dsl builder + */ + default AlibabaOtsEndpointBuilder serviceKeys(String serviceKeys) { + doSetProperty("serviceKeys", serviceKeys); + return this; + } + } + + /** + * Advanced builder for endpoint for the Alibaba Tablestore (OTS) component. + */ + public interface AdvancedAlibabaOtsEndpointBuilder + extends + EndpointProducerBuilder { + default AlibabaOtsEndpointBuilder basic() { + return (AlibabaOtsEndpointBuilder) this; + } + + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option is a: boolean type. + * + * Default: false + * Group: producer (advanced) + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AdvancedAlibabaOtsEndpointBuilder lazyStartProducer(boolean lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option will be converted to a boolean type. + * + * Default: false + * Group: producer (advanced) + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AdvancedAlibabaOtsEndpointBuilder lazyStartProducer(String lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + /** + * Autowire an existing Tablestore client instance. + * + * The option is a: + * com.alicloud.openservices.tablestore.SyncClient type. + * + * Group: advanced + * + * @param otsClient the value to set + * @return the dsl builder + */ + default AdvancedAlibabaOtsEndpointBuilder otsClient(com.alicloud.openservices.tablestore.SyncClient otsClient) { + doSetProperty("otsClient", otsClient); + return this; + } + /** + * Autowire an existing Tablestore client instance. + * + * The option will be converted to a + * com.alicloud.openservices.tablestore.SyncClient type. + * + * Group: advanced + * + * @param otsClient the value to set + * @return the dsl builder + */ + default AdvancedAlibabaOtsEndpointBuilder otsClient(String otsClient) { + doSetProperty("otsClient", otsClient); + return this; + } + } + + public interface AlibabaOtsBuilders { + /** + * Alibaba Tablestore (OTS) (camel-alibaba-ots) + * Perform row operations on Alibaba Cloud Tablestore (OTS). + * + * Category: cloud,database + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-ots + * + * @return the dsl builder for the headers' name. + */ + default AlibabaOtsHeaderNameBuilder alibabaOts() { + return AlibabaOtsHeaderNameBuilder.INSTANCE; + } + /** + * Alibaba Tablestore (OTS) (camel-alibaba-ots) + * Perform row operations on Alibaba Cloud Tablestore (OTS). + * + * Category: cloud,database + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-ots + * + * Syntax: alibaba-ots:operation + * + * Path parameter: operation (required) + * Operation to perform + * There are 5 enums and the value can be one of: putRow, getRow, + * updateRow, deleteRow, listTables + * + * @param path operation + * @return the dsl builder + */ + default AlibabaOtsEndpointBuilder alibabaOts(String path) { + return AlibabaOtsEndpointBuilderFactory.endpointBuilder("alibaba-ots", path); + } + /** + * Alibaba Tablestore (OTS) (camel-alibaba-ots) + * Perform row operations on Alibaba Cloud Tablestore (OTS). + * + * Category: cloud,database + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-ots + * + * Syntax: alibaba-ots:operation + * + * Path parameter: operation (required) + * Operation to perform + * There are 5 enums and the value can be one of: putRow, getRow, + * updateRow, deleteRow, listTables + * + * @param componentName to use a custom component name for the endpoint + * instead of the default name + * @param path operation + * @return the dsl builder + */ + default AlibabaOtsEndpointBuilder alibabaOts(String componentName, String path) { + return AlibabaOtsEndpointBuilderFactory.endpointBuilder(componentName, path); + } + + } + /** + * The builder of headers' name for the Alibaba Tablestore (OTS) component. + */ + public static class AlibabaOtsHeaderNameBuilder { + /** + * The internal instance of the builder used to access to all the + * methods representing the name of headers. + */ + public static final AlibabaOtsHeaderNameBuilder INSTANCE = new AlibabaOtsHeaderNameBuilder(); + + /** + * Operation override. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaOtsOperation}. + */ + public String alibabaOtsOperation() { + return "CamelAlibabaOtsOperation"; + } + /** + * Tablestore request id. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaOtsRequestId}. + */ + public String alibabaOtsRequestId() { + return "CamelAlibabaOtsRequestId"; + } + } + static AlibabaOtsEndpointBuilder endpointBuilder(String componentName, String path) { + class AlibabaOtsEndpointBuilderImpl extends AbstractEndpointBuilder implements AlibabaOtsEndpointBuilder, AdvancedAlibabaOtsEndpointBuilder { + public AlibabaOtsEndpointBuilderImpl(String path) { + super(componentName, path); + } + } + return new AlibabaOtsEndpointBuilderImpl(path); + } +} \ No newline at end of file diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AlibabaSlsEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AlibabaSlsEndpointBuilderFactory.java new file mode 100644 index 0000000000000..8e0ca6768784d --- /dev/null +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AlibabaSlsEndpointBuilderFactory.java @@ -0,0 +1,684 @@ +/* Generated by camel build tools - do NOT edit this file! */ +/* + * 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. + */ +package org.apache.camel.builder.endpoint.dsl; + +import java.util.*; +import java.util.concurrent.*; +import java.util.function.*; +import java.util.stream.*; +import javax.annotation.processing.Generated; +import org.apache.camel.builder.EndpointConsumerBuilder; +import org.apache.camel.builder.EndpointProducerBuilder; +import org.apache.camel.builder.endpoint.AbstractEndpointBuilder; + +/** + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + * + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointDslMojo") +public interface AlibabaSlsEndpointBuilderFactory { + + /** + * Builder for endpoint for the Alibaba Simple Log Service (SLS) component. + */ + public interface AlibabaSlsEndpointBuilder + extends + EndpointProducerBuilder { + default AdvancedAlibabaSlsEndpointBuilder advanced() { + return (AdvancedAlibabaSlsEndpointBuilder) this; + } + + /** + * SLS endpoint URL (e.g. cn-hangzhou.log.aliyuncs.com). Carries higher + * precedence than region based client initialization. + * + * The option is a: java.lang.String type. + * + * Group: producer + * + * @param endpoint the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder endpoint(String endpoint) { + doSetProperty("endpoint", endpoint); + return this; + } + /** + * SLS log store name. + * + * The option is a: java.lang.String type. + * + * Group: producer + * + * @param logStoreName the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder logStoreName(String logStoreName) { + doSetProperty("logStoreName", logStoreName); + return this; + } + /** + * SLS project name. + * + * The option is a: java.lang.String type. + * + * Group: producer + * + * @param project the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder project(String project) { + doSetProperty("project", project); + return this; + } + /** + * Alibaba Cloud region. + * + * The option is a: java.lang.String type. + * + * Required: true + * Group: producer + * + * @param region the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder region(String region) { + doSetProperty("region", region); + return this; + } + /** + * Query start time for getLogs (Unix timestamp in seconds). + * + * The option is a: java.lang.Integer type. + * + * Group: getLogs + * + * @param from the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder from(Integer from) { + doSetProperty("from", from); + return this; + } + /** + * Query start time for getLogs (Unix timestamp in seconds). + * + * The option will be converted to a java.lang.Integer + * type. + * + * Group: getLogs + * + * @param from the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder from(String from) { + doSetProperty("from", from); + return this; + } + /** + * Maximum number of log lines to return for getLogs. + * + * The option is a: java.lang.Long type. + * + * Group: getLogs + * + * @param line the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder line(Long line) { + doSetProperty("line", line); + return this; + } + /** + * Maximum number of log lines to return for getLogs. + * + * The option will be converted to a java.lang.Long type. + * + * Group: getLogs + * + * @param line the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder line(String line) { + doSetProperty("line", line); + return this; + } + /** + * Log query offset for getLogs. + * + * The option is a: java.lang.Long type. + * + * Group: getLogs + * + * @param offset the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder offset(Long offset) { + doSetProperty("offset", offset); + return this; + } + /** + * Log query offset for getLogs. + * + * The option will be converted to a java.lang.Long type. + * + * Group: getLogs + * + * @param offset the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder offset(String offset) { + doSetProperty("offset", offset); + return this; + } + /** + * Log query string for getLogs. + * + * The option is a: java.lang.String type. + * + * Group: getLogs + * + * @param query the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder query(String query) { + doSetProperty("query", query); + return this; + } + /** + * Whether to return logs in reverse order for getLogs. + * + * The option is a: java.lang.Boolean type. + * + * Default: false + * Group: getLogs + * + * @param reverse the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder reverse(Boolean reverse) { + doSetProperty("reverse", reverse); + return this; + } + /** + * Whether to return logs in reverse order for getLogs. + * + * The option will be converted to a java.lang.Boolean + * type. + * + * Default: false + * Group: getLogs + * + * @param reverse the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder reverse(String reverse) { + doSetProperty("reverse", reverse); + return this; + } + /** + * Query end time for getLogs (Unix timestamp in seconds). + * + * The option is a: java.lang.Integer type. + * + * Group: getLogs + * + * @param to the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder to(Integer to) { + doSetProperty("to", to); + return this; + } + /** + * Query end time for getLogs (Unix timestamp in seconds). + * + * The option will be converted to a java.lang.Integer + * type. + * + * Group: getLogs + * + * @param to the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder to(String to) { + doSetProperty("to", to); + return this; + } + /** + * Log topic filter for getLogs. + * + * The option is a: java.lang.String type. + * + * Group: getLogs + * + * @param topic the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder topic(String topic) { + doSetProperty("topic", topic); + return this; + } + /** + * Access key for the cloud user. + * + * The option is a: java.lang.String type. + * + * Group: security + * + * @param accessKey the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder accessKey(String accessKey) { + doSetProperty("accessKey", accessKey); + return this; + } + /** + * Secret key for the cloud user. + * + * The option is a: java.lang.String type. + * + * Group: security + * + * @param secretKey the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder secretKey(String secretKey) { + doSetProperty("secretKey", secretKey); + return this; + } + /** + * Configuration object for cloud service authentication. + * + * The option is a: + * org.apache.camel.component.alibaba.common.models.ServiceKeys type. + * + * Group: security + * + * @param serviceKeys the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder serviceKeys(org.apache.camel.component.alibaba.common.models.ServiceKeys serviceKeys) { + doSetProperty("serviceKeys", serviceKeys); + return this; + } + /** + * Configuration object for cloud service authentication. + * + * The option will be converted to a + * org.apache.camel.component.alibaba.common.models.ServiceKeys type. + * + * Group: security + * + * @param serviceKeys the value to set + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder serviceKeys(String serviceKeys) { + doSetProperty("serviceKeys", serviceKeys); + return this; + } + } + + /** + * Advanced builder for endpoint for the Alibaba Simple Log Service (SLS) component. + */ + public interface AdvancedAlibabaSlsEndpointBuilder + extends + EndpointProducerBuilder { + default AlibabaSlsEndpointBuilder basic() { + return (AlibabaSlsEndpointBuilder) this; + } + + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option is a: boolean type. + * + * Default: false + * Group: producer (advanced) + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AdvancedAlibabaSlsEndpointBuilder lazyStartProducer(boolean lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option will be converted to a boolean type. + * + * Default: false + * Group: producer (advanced) + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AdvancedAlibabaSlsEndpointBuilder lazyStartProducer(String lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + /** + * Autowire an existing SLS client instance. + * + * The option is a: com.aliyun.sls20201230.Client type. + * + * Group: advanced + * + * @param slsClient the value to set + * @return the dsl builder + */ + default AdvancedAlibabaSlsEndpointBuilder slsClient(com.aliyun.sls20201230.Client slsClient) { + doSetProperty("slsClient", slsClient); + return this; + } + /** + * Autowire an existing SLS client instance. + * + * The option will be converted to a + * com.aliyun.sls20201230.Client type. + * + * Group: advanced + * + * @param slsClient the value to set + * @return the dsl builder + */ + default AdvancedAlibabaSlsEndpointBuilder slsClient(String slsClient) { + doSetProperty("slsClient", slsClient); + return this; + } + } + + public interface AlibabaSlsBuilders { + /** + * Alibaba Simple Log Service (SLS) (camel-alibaba-sls) + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + * + * Category: cloud,monitoring + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-sls + * + * @return the dsl builder for the headers' name. + */ + default AlibabaSlsHeaderNameBuilder alibabaSls() { + return AlibabaSlsHeaderNameBuilder.INSTANCE; + } + /** + * Alibaba Simple Log Service (SLS) (camel-alibaba-sls) + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + * + * Category: cloud,monitoring + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-sls + * + * Syntax: alibaba-sls:operation + * + * Path parameter: operation (required) + * Operation to perform + * There are 3 enums and the value can be one of: putLogs, getLogs, + * listLogStores + * + * @param path operation + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder alibabaSls(String path) { + return AlibabaSlsEndpointBuilderFactory.endpointBuilder("alibaba-sls", path); + } + /** + * Alibaba Simple Log Service (SLS) (camel-alibaba-sls) + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + * + * Category: cloud,monitoring + * Since: 4.23 + * Maven coordinates: org.apache.camel:camel-alibaba-sls + * + * Syntax: alibaba-sls:operation + * + * Path parameter: operation (required) + * Operation to perform + * There are 3 enums and the value can be one of: putLogs, getLogs, + * listLogStores + * + * @param componentName to use a custom component name for the endpoint + * instead of the default name + * @param path operation + * @return the dsl builder + */ + default AlibabaSlsEndpointBuilder alibabaSls(String componentName, String path) { + return AlibabaSlsEndpointBuilderFactory.endpointBuilder(componentName, path); + } + + } + /** + * The builder of headers' name for the Alibaba Simple Log Service (SLS) component. + */ + public static class AlibabaSlsHeaderNameBuilder { + /** + * The internal instance of the builder used to access to all the + * methods representing the name of headers. + */ + public static final AlibabaSlsHeaderNameBuilder INSTANCE = new AlibabaSlsHeaderNameBuilder(); + + /** + * SLS project name override. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsProject}. + */ + public String alibabaSlsProject() { + return "CamelAlibabaSlsProject"; + } + /** + * SLS log store name override. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsLogStoreName}. + */ + public String alibabaSlsLogStoreName() { + return "CamelAlibabaSlsLogStoreName"; + } + /** + * Log query string override. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsQuery}. + */ + public String alibabaSlsQuery() { + return "CamelAlibabaSlsQuery"; + } + /** + * Query start time override (Unix timestamp in seconds). + * + * The option is a: {@code Integer} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsFrom}. + */ + public String alibabaSlsFrom() { + return "CamelAlibabaSlsFrom"; + } + /** + * Query end time override (Unix timestamp in seconds). + * + * The option is a: {@code Integer} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsTo}. + */ + public String alibabaSlsTo() { + return "CamelAlibabaSlsTo"; + } + /** + * Maximum number of log lines to return. + * + * The option is a: {@code Long} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsLine}. + */ + public String alibabaSlsLine() { + return "CamelAlibabaSlsLine"; + } + /** + * Log query offset. + * + * The option is a: {@code Long} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsOffset}. + */ + public String alibabaSlsOffset() { + return "CamelAlibabaSlsOffset"; + } + /** + * Log topic filter override. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsTopic}. + */ + public String alibabaSlsTopic() { + return "CamelAlibabaSlsTopic"; + } + /** + * Whether to return logs in reverse order. + * + * The option is a: {@code Boolean} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsReverse}. + */ + public String alibabaSlsReverse() { + return "CamelAlibabaSlsReverse"; + } + /** + * Log store name prefix filter for listLogStores. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsLogstoreName}. + */ + public String alibabaSlsLogstoreName() { + return "CamelAlibabaSlsLogstoreName"; + } + /** + * List mode for listLogStores. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsMode}. + */ + public String alibabaSlsMode() { + return "CamelAlibabaSlsMode"; + } + /** + * Page size for listLogStores. + * + * The option is a: {@code Integer} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsSize}. + */ + public String alibabaSlsSize() { + return "CamelAlibabaSlsSize"; + } + /** + * Telemetry type filter for listLogStores. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsTelemetryType}. + */ + public String alibabaSlsTelemetryType() { + return "CamelAlibabaSlsTelemetryType"; + } + /** + * Alibaba Cloud request id. + * + * The option is a: {@code String} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsRequestId}. + */ + public String alibabaSlsRequestId() { + return "CamelAlibabaSlsRequestId"; + } + /** + * HTTP status code from SLS response. + * + * The option is a: {@code Integer} type. + * + * Group: producer + * + * @return the name of the header {@code AlibabaSlsStatusCode}. + */ + public String alibabaSlsStatusCode() { + return "CamelAlibabaSlsStatusCode"; + } + } + static AlibabaSlsEndpointBuilder endpointBuilder(String componentName, String path) { + class AlibabaSlsEndpointBuilderImpl extends AbstractEndpointBuilder implements AlibabaSlsEndpointBuilder, AdvancedAlibabaSlsEndpointBuilder { + public AlibabaSlsEndpointBuilderImpl(String path) { + super(componentName, path); + } + } + return new AlibabaSlsEndpointBuilderImpl(path); + } +} \ No newline at end of file diff --git a/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties b/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties index ab3785ea8160e..59249c431ca1a 100644 --- a/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties +++ b/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties @@ -26,6 +26,8 @@ org.apache.camel.component.alibaba.fc.FCComponent=camel:alibaba-fc org.apache.camel.component.alibaba.kms.KMSComponent=camel:alibaba-kms org.apache.camel.component.alibaba.mns.MNSComponent=camel:alibaba-mns org.apache.camel.component.alibaba.oss.OSSComponent=camel:alibaba-oss +org.apache.camel.component.alibaba.ots.AlibabaOtsComponent=camel:alibaba-ots +org.apache.camel.component.alibaba.sls.AlibabaSlsComponent=camel:alibaba-sls org.apache.camel.component.alibaba.sms.SMSComponent=camel:alibaba-sms org.apache.camel.component.amqp.AMQPComponent=camel:amqp org.apache.camel.component.arangodb.ArangoDbComponent=camel:arangodb diff --git a/parent/pom.xml b/parent/pom.xml index 0664bce21e6b0..990d88c866705 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -69,8 +69,10 @@ 2.1.0 4.1.1 2.2.0 + 5.9.0 5.2.2 1.2.6 + 5.17.11 0.3.8 3.5.1 2.0.5 @@ -736,11 +738,21 @@ kms20160120 ${aliyun-kms-version} + + com.aliyun + sls20201230 + ${aliyun-sls-version} + com.aliyun tea-openapi ${tea-openapi-version} + + com.aliyun.openservices + tablestore + ${aliyun-tablestore-version} + org.apache.camel camel-a2a @@ -801,6 +813,16 @@ camel-alibaba-oss ${project.version} + + org.apache.camel + camel-alibaba-ots + ${project.version} + + + org.apache.camel + camel-alibaba-sls + ${project.version} + org.apache.camel camel-alibaba-sms diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java index 4d798e49d2b05..fd54baeaccbfc 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java @@ -149,7 +149,9 @@ public static List getComponentPath(Path dir) { dir.resolve("camel-alibaba-fc"), dir.resolve("camel-alibaba-sms"), dir.resolve("camel-alibaba-kms"), - dir.resolve("camel-alibaba-eventbridge")); + dir.resolve("camel-alibaba-sls"), + dir.resolve("camel-alibaba-eventbridge"), + dir.resolve("camel-alibaba-ots")); case "camel-huawei": return Arrays.asList(dir.resolve("camel-huaweicloud-frs"), dir.resolve("camel-huaweicloud-dms"),