diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-secrets-manager.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-secrets-manager.json index d752f6b813c61..27c10d35f695f 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-secrets-manager.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-secrets-manager.json @@ -46,7 +46,7 @@ "secretKey": { "index": 18, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, "sessionToken": { "index": 19, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, "trustAllCertificates": { "index": 20, "kind": "property", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, - "useDefaultCredentialsProvider": { "index": 21, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Translate client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in." }, + "useDefaultCredentialsProvider": { "index": 21, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Secrets Manager client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in." }, "useSessionCredentials": { "index": 22, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Secrets Manager client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Secrets Manager." } }, "headers": { @@ -81,7 +81,7 @@ "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, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, "sessionToken": { "index": 16, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, "trustAllCertificates": { "index": 17, "kind": "parameter", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, - "useDefaultCredentialsProvider": { "index": 18, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Translate client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in." }, + "useDefaultCredentialsProvider": { "index": 18, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Secrets Manager client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in." }, "useSessionCredentials": { "index": 19, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Secrets Manager client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Secrets Manager." } } } diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-athena.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-athena.json index 57a23cfb9985b..ae22a1de72bec 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-athena.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-athena.json @@ -35,31 +35,34 @@ "operation": { "index": 8, "kind": "property", "displayName": "Operation", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.aws2.athena.Athena2Operations", "enum": [ "getQueryExecution", "getQueryResults", "listQueryExecutions", "startQueryExecution" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "startQueryExecution", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The Athena API function to call." }, "outputLocation": { "index": 9, "kind": "property", "displayName": "Output Location", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The location in Amazon S3 where query results are stored, such as s3:\/\/path\/to\/query\/bucket\/. Ensure this value ends with a forward slash." }, "outputType": { "index": 10, "kind": "property", "displayName": "Output Type", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.aws2.athena.Athena2OutputType", "enum": [ "StreamList", "SelectList", "S3Pointer" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "StreamList", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "How query results should be returned. One of StreamList (default - return a GetQueryResultsIterable that can page through all results), SelectList (returns at most 1000 rows at a time, plus a NextToken value as a header than can be used for manual pagination of results), S3Pointer (return an S3 path pointing to the results)." }, - "queryExecutionId": { "index": 11, "kind": "property", "displayName": "Query Execution Id", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The unique ID identifying the query execution." }, - "queryString": { "index": 12, "kind": "property", "displayName": "Query String", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The SQL query to run. Except for simple queries, prefer setting this as the body of the Exchange or as a header using Athena2Constants.QUERY_STRING to avoid having to deal with URL encoding issues." }, - "region": { "index": 13, "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "ap-south-2", "ap-south-1", "eu-south-1", "eu-south-2", "us-gov-east-1", "me-central-1", "il-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "eu-central-2", "eu-isoe-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "ca-west-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "ap-southeast-4", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The region in which Athena client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1)." }, - "resetWaitTimeoutOnRetry": { "index": 14, "kind": "property", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "retry": { "index": 15, "kind": "property", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list of error types to retry the query for. Use: 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "waitTimeout": { "index": 16, "kind": "property", "displayName": "Wait Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "workGroup": { "index": 17, "kind": "property", "displayName": "Work Group", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." }, - "amazonAthenaClient": { "index": 18, "kind": "property", "displayName": "Amazon Athena Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.athena.AthenaClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The AmazonAthena instance to use as the client." }, - "autowiredEnabled": { "index": 19, "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." }, - "clientRequestToken": { "index": 20, "kind": "property", "displayName": "Client Request Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this." }, - "includeTrace": { "index": 21, "kind": "property", "displayName": "Include Trace", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Include useful trace information at the beginning of queries as an SQL comment (prefixed with --)." }, - "healthCheckConsumerEnabled": { "index": 22, "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": 23, "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." }, - "proxyHost": { "index": 24, "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Athena client." }, - "proxyPort": { "index": 25, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Athena client." }, - "proxyProtocol": { "index": 26, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Athena client." }, - "accessKey": { "index": 27, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key." }, - "encryptionOption": { "index": 28, "kind": "property", "displayName": "Encryption Option", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.services.athena.model.EncryptionOption", "enum": [ "SSE_S3", "SSE_KMS", "CSE_KMS", "null" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The encryption type to use when storing query results in S3. One of SSE_S3, SSE_KMS, or CSE_KMS." }, - "kmsKey": { "index": 29, "kind": "property", "displayName": "Kms Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "For SSE-KMS and CSE-KMS, this is the KMS key ARN or ID." }, - "profileCredentialsName": { "index": 30, "kind": "property", "displayName": "Profile Credentials Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider, this parameter will set the profile name" }, - "secretKey": { "index": 31, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." }, - "sessionToken": { "index": 32, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, - "useDefaultCredentialsProvider": { "index": 33, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in" }, - "useProfileCredentialsProvider": { "index": 34, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a profile credentials provider." }, - "useSessionCredentials": { "index": 35, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Athena." } + "overrideEndpoint": { "index": 11, "kind": "property", "displayName": "Override Endpoint", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used in combination with the uriEndpointOverride option" }, + "queryExecutionId": { "index": 12, "kind": "property", "displayName": "Query Execution Id", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The unique ID identifying the query execution." }, + "queryString": { "index": 13, "kind": "property", "displayName": "Query String", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The SQL query to run. Except for simple queries, prefer setting this as the body of the Exchange or as a header using Athena2Constants.QUERY_STRING to avoid having to deal with URL encoding issues." }, + "region": { "index": 14, "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "ap-south-2", "ap-south-1", "eu-south-1", "eu-south-2", "us-gov-east-1", "me-central-1", "il-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "eu-central-2", "eu-isoe-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "ca-west-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "ap-southeast-4", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The region in which Athena client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1)." }, + "resetWaitTimeoutOnRetry": { "index": 15, "kind": "property", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "retry": { "index": 16, "kind": "property", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list of error types to retry the query for. Use: 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "uriEndpointOverride": { "index": 17, "kind": "property", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option" }, + "waitTimeout": { "index": 18, "kind": "property", "displayName": "Wait Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "workGroup": { "index": 19, "kind": "property", "displayName": "Work Group", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." }, + "amazonAthenaClient": { "index": 20, "kind": "property", "displayName": "Amazon Athena Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.athena.AthenaClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The AmazonAthena instance to use as the client." }, + "autowiredEnabled": { "index": 21, "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." }, + "clientRequestToken": { "index": 22, "kind": "property", "displayName": "Client Request Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this." }, + "includeTrace": { "index": 23, "kind": "property", "displayName": "Include Trace", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Include useful trace information at the beginning of queries as an SQL comment (prefixed with --)." }, + "healthCheckConsumerEnabled": { "index": 24, "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": 25, "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." }, + "proxyHost": { "index": 26, "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Athena client." }, + "proxyPort": { "index": 27, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Athena client." }, + "proxyProtocol": { "index": 28, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Athena client." }, + "accessKey": { "index": 29, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key." }, + "encryptionOption": { "index": 30, "kind": "property", "displayName": "Encryption Option", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.services.athena.model.EncryptionOption", "enum": [ "SSE_S3", "SSE_KMS", "CSE_KMS", "null" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The encryption type to use when storing query results in S3. One of SSE_S3, SSE_KMS, or CSE_KMS." }, + "kmsKey": { "index": 31, "kind": "property", "displayName": "Kms Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "For SSE-KMS and CSE-KMS, this is the KMS key ARN or ID." }, + "profileCredentialsName": { "index": 32, "kind": "property", "displayName": "Profile Credentials Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider, this parameter will set the profile name" }, + "secretKey": { "index": 33, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." }, + "sessionToken": { "index": 34, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, + "trustAllCertificates": { "index": 35, "kind": "property", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, + "useDefaultCredentialsProvider": { "index": 36, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in" }, + "useProfileCredentialsProvider": { "index": 37, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a profile credentials provider." }, + "useSessionCredentials": { "index": 38, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Athena." } }, "headers": { "CamelAwsAthenaOperation": { "index": 0, "kind": "header", "displayName": "", "group": "all", "label": "all", "required": false, "javaType": "org.apache.camel.component.aws2.athena.Athena2Operations", "enum": [ "getQueryExecution", "getQueryResults", "listQueryExecutions", "startQueryExecution" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "startQueryExecution", "description": "The operation to perform. Permitted values are getQueryExecution, getQueryResults, listQueryExecutions, startQueryExecution.", "constantName": "org.apache.camel.component.aws2.athena.Athena2Constants#OPERATION" }, @@ -96,28 +99,31 @@ "operation": { "index": 7, "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.aws2.athena.Athena2Operations", "enum": [ "getQueryExecution", "getQueryResults", "listQueryExecutions", "startQueryExecution" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "startQueryExecution", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The Athena API function to call." }, "outputLocation": { "index": 8, "kind": "parameter", "displayName": "Output Location", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The location in Amazon S3 where query results are stored, such as s3:\/\/path\/to\/query\/bucket\/. Ensure this value ends with a forward slash." }, "outputType": { "index": 9, "kind": "parameter", "displayName": "Output Type", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.aws2.athena.Athena2OutputType", "enum": [ "StreamList", "SelectList", "S3Pointer" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "StreamList", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "How query results should be returned. One of StreamList (default - return a GetQueryResultsIterable that can page through all results), SelectList (returns at most 1000 rows at a time, plus a NextToken value as a header than can be used for manual pagination of results), S3Pointer (return an S3 path pointing to the results)." }, - "queryExecutionId": { "index": 10, "kind": "parameter", "displayName": "Query Execution Id", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The unique ID identifying the query execution." }, - "queryString": { "index": 11, "kind": "parameter", "displayName": "Query String", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The SQL query to run. Except for simple queries, prefer setting this as the body of the Exchange or as a header using Athena2Constants.QUERY_STRING to avoid having to deal with URL encoding issues." }, - "region": { "index": 12, "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "ap-south-2", "ap-south-1", "eu-south-1", "eu-south-2", "us-gov-east-1", "me-central-1", "il-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "eu-central-2", "eu-isoe-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "ca-west-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "ap-southeast-4", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The region in which Athena client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1)." }, - "resetWaitTimeoutOnRetry": { "index": 13, "kind": "parameter", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "retry": { "index": 14, "kind": "parameter", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list of error types to retry the query for. Use: 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "waitTimeout": { "index": 15, "kind": "parameter", "displayName": "Wait Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "workGroup": { "index": 16, "kind": "parameter", "displayName": "Work Group", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." }, - "lazyStartProducer": { "index": 17, "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." }, - "amazonAthenaClient": { "index": 18, "kind": "parameter", "displayName": "Amazon Athena Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.athena.AthenaClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The AmazonAthena instance to use as the client." }, - "clientRequestToken": { "index": 19, "kind": "parameter", "displayName": "Client Request Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this." }, - "includeTrace": { "index": 20, "kind": "parameter", "displayName": "Include Trace", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Include useful trace information at the beginning of queries as an SQL comment (prefixed with --)." }, - "proxyHost": { "index": 21, "kind": "parameter", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Athena client." }, - "proxyPort": { "index": 22, "kind": "parameter", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Athena client." }, - "proxyProtocol": { "index": 23, "kind": "parameter", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Athena client." }, - "accessKey": { "index": 24, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key." }, - "encryptionOption": { "index": 25, "kind": "parameter", "displayName": "Encryption Option", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.services.athena.model.EncryptionOption", "enum": [ "SSE_S3", "SSE_KMS", "CSE_KMS", "null" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The encryption type to use when storing query results in S3. One of SSE_S3, SSE_KMS, or CSE_KMS." }, - "kmsKey": { "index": 26, "kind": "parameter", "displayName": "Kms Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "For SSE-KMS and CSE-KMS, this is the KMS key ARN or ID." }, - "profileCredentialsName": { "index": 27, "kind": "parameter", "displayName": "Profile Credentials Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider, this parameter will set the profile name" }, - "secretKey": { "index": 28, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." }, - "sessionToken": { "index": 29, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, - "useDefaultCredentialsProvider": { "index": 30, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in" }, - "useProfileCredentialsProvider": { "index": 31, "kind": "parameter", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a profile credentials provider." }, - "useSessionCredentials": { "index": 32, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Athena." } + "overrideEndpoint": { "index": 10, "kind": "parameter", "displayName": "Override Endpoint", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used in combination with the uriEndpointOverride option" }, + "queryExecutionId": { "index": 11, "kind": "parameter", "displayName": "Query Execution Id", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The unique ID identifying the query execution." }, + "queryString": { "index": 12, "kind": "parameter", "displayName": "Query String", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The SQL query to run. Except for simple queries, prefer setting this as the body of the Exchange or as a header using Athena2Constants.QUERY_STRING to avoid having to deal with URL encoding issues." }, + "region": { "index": 13, "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "ap-south-2", "ap-south-1", "eu-south-1", "eu-south-2", "us-gov-east-1", "me-central-1", "il-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "eu-central-2", "eu-isoe-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "ca-west-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "ap-southeast-4", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The region in which Athena client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1)." }, + "resetWaitTimeoutOnRetry": { "index": 14, "kind": "parameter", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "retry": { "index": 15, "kind": "parameter", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list of error types to retry the query for. Use: 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "uriEndpointOverride": { "index": 16, "kind": "parameter", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option" }, + "waitTimeout": { "index": 17, "kind": "parameter", "displayName": "Wait Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "workGroup": { "index": 18, "kind": "parameter", "displayName": "Work Group", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." }, + "lazyStartProducer": { "index": 19, "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." }, + "amazonAthenaClient": { "index": 20, "kind": "parameter", "displayName": "Amazon Athena Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.athena.AthenaClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The AmazonAthena instance to use as the client." }, + "clientRequestToken": { "index": 21, "kind": "parameter", "displayName": "Client Request Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this." }, + "includeTrace": { "index": 22, "kind": "parameter", "displayName": "Include Trace", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Include useful trace information at the beginning of queries as an SQL comment (prefixed with --)." }, + "proxyHost": { "index": 23, "kind": "parameter", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Athena client." }, + "proxyPort": { "index": 24, "kind": "parameter", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Athena client." }, + "proxyProtocol": { "index": 25, "kind": "parameter", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Athena client." }, + "accessKey": { "index": 26, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key." }, + "encryptionOption": { "index": 27, "kind": "parameter", "displayName": "Encryption Option", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.services.athena.model.EncryptionOption", "enum": [ "SSE_S3", "SSE_KMS", "CSE_KMS", "null" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The encryption type to use when storing query results in S3. One of SSE_S3, SSE_KMS, or CSE_KMS." }, + "kmsKey": { "index": 28, "kind": "parameter", "displayName": "Kms Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "For SSE-KMS and CSE-KMS, this is the KMS key ARN or ID." }, + "profileCredentialsName": { "index": 29, "kind": "parameter", "displayName": "Profile Credentials Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider, this parameter will set the profile name" }, + "secretKey": { "index": 30, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." }, + "sessionToken": { "index": 31, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, + "trustAllCertificates": { "index": 32, "kind": "parameter", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, + "useDefaultCredentialsProvider": { "index": 33, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in" }, + "useProfileCredentialsProvider": { "index": 34, "kind": "parameter", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a profile credentials provider." }, + "useSessionCredentials": { "index": 35, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Athena." } } } diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-timestream.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-timestream.json index f723b0f3097a4..cc9f02cf65007 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-timestream.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-timestream.json @@ -44,7 +44,9 @@ "proxyPort": { "index": 17, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Timestream client" }, "proxyProtocol": { "index": 18, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Timestream client" }, "accessKey": { "index": 19, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" }, - "secretKey": { "index": 20, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" } + "secretKey": { "index": 20, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, + "sessionToken": { "index": 21, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, + "useSessionCredentials": { "index": 22, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Set whether the Timestream client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Timestream." } }, "headers": { "CamelAwsTimestreamOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.timestream.Timestream2Constants#OPERATION" }, @@ -105,6 +107,8 @@ "proxyPort": { "index": 15, "kind": "parameter", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Timestream client" }, "proxyProtocol": { "index": 16, "kind": "parameter", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Timestream client" }, "accessKey": { "index": 17, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" }, - "secretKey": { "index": 18, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" } + "secretKey": { "index": 18, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, + "sessionToken": { "index": 19, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, + "useSessionCredentials": { "index": 20, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Set whether the Timestream client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Timestream." } } } diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-transcribe.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-transcribe.json index a8b1088ede3b7..9da016371f301 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-transcribe.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-transcribe.json @@ -33,7 +33,7 @@ "protocol": { "index": 6, "kind": "property", "displayName": "Protocol", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, "proxyHost": { "index": 7, "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Transcribe client" }, "proxyPort": { "index": 8, "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Transcribe client" }, - "proxyProtocol": { "index": 9, "kind": "property", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, + "proxyProtocol": { "index": 9, "kind": "property", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, "region": { "index": 10, "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "The region in which Transcribe client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id()" }, "transcribeClient": { "index": 11, "kind": "property", "displayName": "Transcribe Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.transcribe.TranscribeClient", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To use a existing configured AWS Transcribe as client" }, "trustAllCertificates": { "index": 12, "kind": "property", "displayName": "Trust All Certificates", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, @@ -73,7 +73,7 @@ "protocol": { "index": 5, "kind": "parameter", "displayName": "Protocol", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, "proxyHost": { "index": 6, "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Transcribe client" }, "proxyPort": { "index": 7, "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Transcribe client" }, - "proxyProtocol": { "index": 8, "kind": "parameter", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, + "proxyProtocol": { "index": 8, "kind": "parameter", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, "region": { "index": 9, "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "The region in which Transcribe client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id()" }, "transcribeClient": { "index": 10, "kind": "parameter", "displayName": "Transcribe Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.transcribe.TranscribeClient", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To use a existing configured AWS Transcribe as client" }, "trustAllCertificates": { "index": 11, "kind": "parameter", "displayName": "Trust All Certificates", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, diff --git a/components/camel-aws/camel-aws-bedrock/pom.xml b/components/camel-aws/camel-aws-bedrock/pom.xml index 9418097e2f65e..b4a1ae80d908b 100644 --- a/components/camel-aws/camel-aws-bedrock/pom.xml +++ b/components/camel-aws/camel-aws-bedrock/pom.xml @@ -40,6 +40,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + org.apache.camel camel-jackson diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConfiguration.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConfiguration.java index 3d2f459e79e2f..77cedc9b85b18 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConfiguration.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.bedrock.agent; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.bedrockagent.BedrockAgentClient; @UriParams -public class BedrockAgentConfiguration implements Cloneable { +public class BedrockAgentConfiguration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) @@ -232,7 +233,7 @@ public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvid this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentEndpoint.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentEndpoint.java index e2f9e611d1d27..316942ea3b9fb 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentEndpoint.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentEndpoint.java @@ -74,7 +74,7 @@ public void doStart() throws Exception { bedrockAgentClient = configuration.getBedrockAgentClient() != null ? configuration.getBedrockAgentClient() - : BedrockAgentClientFactory.getBedrockAgentClient(configuration).getBedrockAgentClient(); + : BedrockAgentClientFactory.getBedrockAgentClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/BedrockAgentClientFactory.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/BedrockAgentClientFactory.java index a2156edc1074b..3c1edeaeecf11 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/BedrockAgentClientFactory.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/BedrockAgentClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws2.bedrock.agent.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration; -import org.apache.camel.component.aws2.bedrock.agent.client.impl.BedrockAgentClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.agent.client.impl.BedrockAgentClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.agent.client.impl.BedrockAgentClientSessionTokenImpl; -import org.apache.camel.component.aws2.bedrock.agent.client.impl.BedrockAgentClientStandardImpl; +import software.amazon.awssdk.services.bedrockagent.BedrockAgentClient; /** - * Factory class to return the correct type of AWS Bedrock runtime client. + * Factory class to create AWS Bedrock Agent clients using common configuration. */ public final class BedrockAgentClientFactory { @@ -31,21 +29,14 @@ private BedrockAgentClientFactory() { } /** - * Return the correct AWS Bedrock Agent client (based on remote vs local). + * Create a BedrockAgentClient based on configuration. * - * @param configuration configuration - * @return BedrockAgentInternalClient + * @param configuration The Bedrock Agent configuration + * @return Configured BedrockAgentClient */ - public static BedrockAgentInternalClient getBedrockAgentClient( - BedrockAgentConfiguration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new BedrockAgentClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new BedrockAgentClientIAMProfileOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new BedrockAgentClientSessionTokenImpl(configuration); - } else { - return new BedrockAgentClientStandardImpl(configuration); - } + public static BedrockAgentClient getBedrockAgentClient(BedrockAgentConfiguration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + BedrockAgentClient::builder); } } diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/BedrockAgentInternalClient.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/BedrockAgentInternalClient.java deleted file mode 100644 index cf1253f243737..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/BedrockAgentInternalClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.aws2.bedrock.agent.client; - -import software.amazon.awssdk.services.bedrockagent.BedrockAgentClient; - -/** - * Manage the required actions of an Bedrock Agent client for either local or remote. - */ -public interface BedrockAgentInternalClient { - - /** - * Returns an Bedrock Agent client after a factory method determines which one to return. - * - * @return BedrockAgentClient BedrockAgentClient - */ - BedrockAgentClient getBedrockAgentClient(); -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientIAMOptimizedImpl.java deleted file mode 100644 index a75266bed056b..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientIAMOptimizedImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.aws2.bedrock.agent.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration; -import org.apache.camel.component.aws2.bedrock.agent.client.BedrockAgentInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockagent.BedrockAgentClient; -import software.amazon.awssdk.services.bedrockagent.BedrockAgentClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Agent client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class BedrockAgentClientIAMOptimizedImpl implements BedrockAgentInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockAgentClientIAMOptimizedImpl.class); - private BedrockAgentConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockAgentClientIAMOptimizedImpl(BedrockAgentConfiguration configuration) { - LOG.trace( - "Creating an AWS Bedrock Agent client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Agent aws client that is used. - * - * @return BedrockAgentClient Client. - */ - @Override - public BedrockAgentClient getBedrockAgentClient() { - BedrockAgentClient client = null; - BedrockAgentClientBuilder clientBuilder = BedrockAgentClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientIAMProfileOptimizedImpl.java deleted file mode 100644 index f1b814ad21225..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.aws2.bedrock.agent.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration; -import org.apache.camel.component.aws2.bedrock.agent.client.BedrockAgentInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockagent.BedrockAgentClient; -import software.amazon.awssdk.services.bedrockagent.BedrockAgentClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Agent Runtime client for all users to use (enabling temporary creds). This implementation is - * for remote instances to manage the credentials on their own (eliminating credential rotations) - */ -public class BedrockAgentClientIAMProfileOptimizedImpl implements BedrockAgentInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockAgentClientIAMProfileOptimizedImpl.class); - private BedrockAgentConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockAgentClientIAMProfileOptimizedImpl(BedrockAgentConfiguration configuration) { - LOG.trace( - "Creating an AWS Bedrock Agent client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Agent aws client that is used. - * - * @return Bedrock Agent Client. - */ - @Override - public BedrockAgentClient getBedrockAgentClient() { - BedrockAgentClient client = null; - BedrockAgentClientBuilder clientBuilder = BedrockAgentClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientSessionTokenImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientSessionTokenImpl.java deleted file mode 100644 index e415e650662e4..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientSessionTokenImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.aws2.bedrock.agent.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration; -import org.apache.camel.component.aws2.bedrock.agent.client.BedrockAgentInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockagent.BedrockAgentClient; -import software.amazon.awssdk.services.bedrockagent.BedrockAgentClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Agent client for all users to use. This implementation is for local instances to use a static - * and solid credential set. - */ -public class BedrockAgentClientSessionTokenImpl implements BedrockAgentInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockAgentClientSessionTokenImpl.class); - private BedrockAgentConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockAgentClientSessionTokenImpl(BedrockAgentConfiguration configuration) { - LOG.trace("Creating an AWS Bedrock Agent manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Agent AWS client that is used. - * - * @return BedrockAgentClient Client. - */ - @Override - public BedrockAgentClient getBedrockAgentClient() { - BedrockAgentClient client = null; - BedrockAgentClientBuilder clientBuilder = BedrockAgentClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientStandardImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientStandardImpl.java deleted file mode 100644 index 8d09a255eb26f..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agent/client/impl/BedrockAgentClientStandardImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.aws2.bedrock.agent.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration; -import org.apache.camel.component.aws2.bedrock.agent.client.BedrockAgentInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockagent.BedrockAgentClient; -import software.amazon.awssdk.services.bedrockagent.BedrockAgentClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Agent Runtime client for all users to use. This implementation is for local instances to use a - * static and solid credential set. - */ -public class BedrockAgentClientStandardImpl implements BedrockAgentInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockAgentClientStandardImpl.class); - private BedrockAgentConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockAgentClientStandardImpl(BedrockAgentConfiguration configuration) { - LOG.trace("Creating an AWS Bedrock Agent manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Agent AWS client that is used. - * - * @return BedrockAgentClient Client. - */ - @Override - public BedrockAgentClient getBedrockAgentClient() { - BedrockAgentClient client = null; - BedrockAgentClientBuilder clientBuilder = BedrockAgentClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeConfiguration.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeConfiguration.java index 89326c39871e1..c3bc5de3cb639 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeConfiguration.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.bedrock.agentruntime; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClient; @UriParams -public class BedrockAgentRuntimeConfiguration implements Cloneable { +public class BedrockAgentRuntimeConfiguration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) @@ -227,7 +228,7 @@ public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvid this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeEndpoint.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeEndpoint.java index ee48a087ac202..7e2fbce5f7829 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeEndpoint.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeEndpoint.java @@ -67,7 +67,7 @@ public void doStart() throws Exception { bedrockAgentRuntimeClient = configuration.getBedrockAgentRuntimeClient() != null ? configuration.getBedrockAgentRuntimeClient() - : BedrockAgentRuntimeClientFactory.getBedrockAgentRuntimeClient(configuration).getBedrockAgentRuntimeClient(); + : BedrockAgentRuntimeClientFactory.getBedrockAgentRuntimeClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/BedrockAgentRuntimeClientFactory.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/BedrockAgentRuntimeClientFactory.java index 2bf95bb7a2cd9..b63354c10335c 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/BedrockAgentRuntimeClientFactory.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/BedrockAgentRuntimeClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws2.bedrock.agentruntime.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.impl.BedrockAgentRuntimeClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.impl.BedrockAgentRuntimeClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.impl.BedrockAgentRuntimeClientSessionTokenImpl; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.impl.BedrockAgentRuntimeClientStandardImpl; +import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClient; /** - * Factory class to return the correct type of AWS Bedrock runtime client. + * Factory class to create AWS Bedrock Agent Runtime clients using common configuration. */ public final class BedrockAgentRuntimeClientFactory { @@ -31,21 +29,14 @@ private BedrockAgentRuntimeClientFactory() { } /** - * Return the correct AWS Bedrock Agent runtime client (based on remote vs local). + * Create a BedrockAgentRuntimeClient based on configuration. * - * @param configuration configuration - * @return BedrockAgentRuntimeInternalClient + * @param configuration The Bedrock Agent Runtime configuration + * @return Configured BedrockAgentRuntimeClient */ - public static BedrockAgentRuntimeInternalClient getBedrockAgentRuntimeClient( - BedrockAgentRuntimeConfiguration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new BedrockAgentRuntimeClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new BedrockAgentRuntimeClientIAMProfileOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new BedrockAgentRuntimeClientSessionTokenImpl(configuration); - } else { - return new BedrockAgentRuntimeClientStandardImpl(configuration); - } + public static BedrockAgentRuntimeClient getBedrockAgentRuntimeClient(BedrockAgentRuntimeConfiguration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + BedrockAgentRuntimeClient::builder); } } diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/BedrockAgentRuntimeInternalClient.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/BedrockAgentRuntimeInternalClient.java deleted file mode 100644 index c254cf1f87f0f..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/BedrockAgentRuntimeInternalClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.aws2.bedrock.agentruntime.client; - -import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClient; - -/** - * Manage the required actions of an Bedrock Agent Runtime client for either local or remote. - */ -public interface BedrockAgentRuntimeInternalClient { - - /** - * Returns an Bedrock Agent Runtime client after a factory method determines which one to return. - * - * @return BedrockRuntimeClient BedrockRuntimeClient - */ - BedrockAgentRuntimeClient getBedrockAgentRuntimeClient(); -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientIAMOptimizedImpl.java deleted file mode 100644 index dbd9730a5b049..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientIAMOptimizedImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.aws2.bedrock.agentruntime.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.BedrockAgentRuntimeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClient; -import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Runtime client for all users to use (enabling temporary creds). This implementation is for - * remote instances to manage the credentials on their own (eliminating credential rotations) - */ -public class BedrockAgentRuntimeClientIAMOptimizedImpl implements BedrockAgentRuntimeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockAgentRuntimeClientIAMOptimizedImpl.class); - private BedrockAgentRuntimeConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockAgentRuntimeClientIAMOptimizedImpl(BedrockAgentRuntimeConfiguration configuration) { - LOG.trace( - "Creating an AWS Bedrock Agent Runtime client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Agent Runtime aws client that is used. - * - * @return BedrockAgentRuntimeClient Client. - */ - @Override - public BedrockAgentRuntimeClient getBedrockAgentRuntimeClient() { - BedrockAgentRuntimeClient client = null; - BedrockAgentRuntimeClientBuilder clientBuilder = BedrockAgentRuntimeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientIAMProfileOptimizedImpl.java deleted file mode 100644 index f41c6583e1390..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.aws2.bedrock.agentruntime.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.BedrockAgentRuntimeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClient; -import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Agent Runtime client for all users to use (enabling temporary creds). This implementation is - * for remote instances to manage the credentials on their own (eliminating credential rotations) - */ -public class BedrockAgentRuntimeClientIAMProfileOptimizedImpl implements BedrockAgentRuntimeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockAgentRuntimeClientIAMProfileOptimizedImpl.class); - private BedrockAgentRuntimeConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockAgentRuntimeClientIAMProfileOptimizedImpl(BedrockAgentRuntimeConfiguration configuration) { - LOG.trace( - "Creating an AWS Bedrock Agent Runtime client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Agent Runtime aws client that is used. - * - * @return Bedrock Agent Runtime Client. - */ - @Override - public BedrockAgentRuntimeClient getBedrockAgentRuntimeClient() { - BedrockAgentRuntimeClient client = null; - BedrockAgentRuntimeClientBuilder clientBuilder = BedrockAgentRuntimeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientSessionTokenImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientSessionTokenImpl.java deleted file mode 100644 index 65ed10cfb2809..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientSessionTokenImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.aws2.bedrock.agentruntime.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.BedrockAgentRuntimeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClient; -import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Agent Runtime client for all users to use. This implementation is for local instances to use a - * static and solid credential set. - */ -public class BedrockAgentRuntimeClientSessionTokenImpl implements BedrockAgentRuntimeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockAgentRuntimeClientSessionTokenImpl.class); - private BedrockAgentRuntimeConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockAgentRuntimeClientSessionTokenImpl(BedrockAgentRuntimeConfiguration configuration) { - LOG.trace("Creating an AWS Bedrock Agent Runtime manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Agent Runtime AWS client that is used. - * - * @return BedrockAgentRuntimeClient Client. - */ - @Override - public BedrockAgentRuntimeClient getBedrockAgentRuntimeClient() { - BedrockAgentRuntimeClient client = null; - BedrockAgentRuntimeClientBuilder clientBuilder = BedrockAgentRuntimeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientStandardImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientStandardImpl.java deleted file mode 100644 index cc8e788ba95db..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/client/impl/BedrockAgentRuntimeClientStandardImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.aws2.bedrock.agentruntime.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.BedrockAgentRuntimeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClient; -import software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Agent Runtime client for all users to use. This implementation is for local instances to use a - * static and solid credential set. - */ -public class BedrockAgentRuntimeClientStandardImpl implements BedrockAgentRuntimeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockAgentRuntimeClientStandardImpl.class); - private BedrockAgentRuntimeConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockAgentRuntimeClientStandardImpl(BedrockAgentRuntimeConfiguration configuration) { - LOG.trace("Creating an AWS Bedrock Agent Runtime manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Agent Runtime AWS client that is used. - * - * @return BedrockAgenRuitimeClient Client. - */ - @Override - public BedrockAgentRuntimeClient getBedrockAgentRuntimeClient() { - BedrockAgentRuntimeClient client = null; - BedrockAgentRuntimeClientBuilder clientBuilder = BedrockAgentRuntimeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConfiguration.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConfiguration.java index 50fd0ecd00972..06cf99a518ce0 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConfiguration.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.bedrock.runtime; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; @UriParams -public class BedrockConfiguration implements Cloneable { +public class BedrockConfiguration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) @@ -248,7 +249,7 @@ public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvid this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpoint.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpoint.java index 24505dee95cca..93013de2a4890 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpoint.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockEndpoint.java @@ -74,12 +74,12 @@ public void doStart() throws Exception { // Get sync client bedrockRuntimeClient = configuration.getBedrockRuntimeClient() != null ? configuration.getBedrockRuntimeClient() - : BedrockClientFactory.getBedrockRuntimeClient(configuration).getBedrockRuntimeClient(); + : BedrockClientFactory.getBedrockRuntimeClient(configuration); // Get async client for streaming operations bedrockRuntimeAsyncClient = configuration.getBedrockRuntimeAsyncClient() != null ? configuration.getBedrockRuntimeAsyncClient() - : BedrockClientFactory.getBedrockRuntimeClient(configuration).getBedrockRuntimeAsyncClient(); + : BedrockClientFactory.getBedrockRuntimeAsyncClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/BedrockClientFactory.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/BedrockClientFactory.java index 96417a59ceb81..47738a6dde7cd 100644 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/BedrockClientFactory.java +++ b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/BedrockClientFactory.java @@ -16,14 +16,13 @@ */ package org.apache.camel.component.aws2.bedrock.runtime.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration; -import org.apache.camel.component.aws2.bedrock.runtime.client.impl.BedrockRuntimeClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.runtime.client.impl.BedrockRuntimeClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.runtime.client.impl.BedrockRuntimeClientSessionTokenImpl; -import org.apache.camel.component.aws2.bedrock.runtime.client.impl.BedrockRuntimeClientStandardImpl; +import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient; +import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; /** - * Factory class to return the correct type of AWS Bedrock runtime client. + * Factory class to create AWS Bedrock Runtime clients using common configuration. */ public final class BedrockClientFactory { @@ -31,20 +30,26 @@ private BedrockClientFactory() { } /** - * Return the correct AWS Bedrock runtime client (based on remote vs local). + * Create a BedrockRuntimeClient (sync) based on configuration. * - * @param configuration configuration - * @return BedrockRuntimeInternalClient + * @param configuration The Bedrock configuration + * @return Configured BedrockRuntimeClient */ - public static BedrockRuntimeInternalClient getBedrockRuntimeClient(BedrockConfiguration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new BedrockRuntimeClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new BedrockRuntimeClientIAMProfileOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new BedrockRuntimeClientSessionTokenImpl(configuration); - } else { - return new BedrockRuntimeClientStandardImpl(configuration); - } + public static BedrockRuntimeClient getBedrockRuntimeClient(BedrockConfiguration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + BedrockRuntimeClient::builder); + } + + /** + * Create a BedrockRuntimeAsyncClient based on configuration. + * + * @param configuration The Bedrock configuration + * @return Configured BedrockRuntimeAsyncClient + */ + public static BedrockRuntimeAsyncClient getBedrockRuntimeAsyncClient(BedrockConfiguration configuration) { + return AwsClientBuilderUtil.buildAsyncClient( + configuration, + BedrockRuntimeAsyncClient::builder); } } diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/BedrockRuntimeInternalClient.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/BedrockRuntimeInternalClient.java deleted file mode 100644 index 25efb64240165..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/BedrockRuntimeInternalClient.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.aws2.bedrock.runtime.client; - -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; - -/** - * Manage the required actions of an Bedrock Runtime client for either local or remote. - */ -public interface BedrockRuntimeInternalClient { - - /** - * Returns an Bedrock Runtime client after a factory method determines which one to return. - * - * @return BedrockRuntimeClient BedrockRuntimeClient - */ - BedrockRuntimeClient getBedrockRuntimeClient(); - - /** - * Returns an Bedrock Runtime async client for streaming operations. - * - * @return BedrockRuntimeAsyncClient BedrockRuntimeAsyncClient - */ - BedrockRuntimeAsyncClient getBedrockRuntimeAsyncClient(); -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientIAMOptimizedImpl.java deleted file mode 100644 index 27790c26aabb8..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientIAMOptimizedImpl.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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.aws2.bedrock.runtime.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration; -import org.apache.camel.component.aws2.bedrock.runtime.client.BedrockRuntimeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClientBuilder; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Runtime client for all users to use (enabling temporary creds). This implementation is for - * remote instances to manage the credentials on their own (eliminating credential rotations) - */ -public class BedrockRuntimeClientIAMOptimizedImpl implements BedrockRuntimeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockRuntimeClientIAMOptimizedImpl.class); - private BedrockConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockRuntimeClientIAMOptimizedImpl(BedrockConfiguration configuration) { - LOG.trace( - "Creating an AWS Bedrock Runtime client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock aws client that is used. - * - * @return BedrockRuntimeClient Client. - */ - @Override - public BedrockRuntimeClient getBedrockRuntimeClient() { - BedrockRuntimeClient client = null; - BedrockRuntimeClientBuilder clientBuilder = BedrockRuntimeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } - - @Override - public BedrockRuntimeAsyncClient getBedrockRuntimeAsyncClient() { - BedrockRuntimeAsyncClient client = null; - BedrockRuntimeAsyncClientBuilder clientBuilder = BedrockRuntimeAsyncClient.builder(); - - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - // Note: Async clients use default credentials provider and Netty HTTP client - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientIAMProfileOptimizedImpl.java deleted file mode 100644 index 24a17b8123f12..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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.aws2.bedrock.runtime.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration; -import org.apache.camel.component.aws2.bedrock.runtime.client.BedrockRuntimeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClientBuilder; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Runtime client for all users to use (enabling temporary creds). This implementation is for - * remote instances to manage the credentials on their own (eliminating credential rotations) - */ -public class BedrockRuntimeClientIAMProfileOptimizedImpl implements BedrockRuntimeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockRuntimeClientIAMProfileOptimizedImpl.class); - private BedrockConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockRuntimeClientIAMProfileOptimizedImpl(BedrockConfiguration configuration) { - LOG.trace( - "Creating an AWS Bedrock Runtime client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Runtime aws client that is used. - * - * @return Bedrock Runtime Client. - */ - @Override - public BedrockRuntimeClient getBedrockRuntimeClient() { - BedrockRuntimeClient client = null; - BedrockRuntimeClientBuilder clientBuilder = BedrockRuntimeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } - - @Override - public BedrockRuntimeAsyncClient getBedrockRuntimeAsyncClient() { - BedrockRuntimeAsyncClient client = null; - BedrockRuntimeAsyncClientBuilder clientBuilder = BedrockRuntimeAsyncClient.builder(); - - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - // Note: Async clients use Netty by default, proxy and TLS configuration would require NettyNioAsyncHttpClient - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientSessionTokenImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientSessionTokenImpl.java deleted file mode 100644 index 9d591fdabda9e..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientSessionTokenImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.aws2.bedrock.runtime.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration; -import org.apache.camel.component.aws2.bedrock.runtime.client.BedrockRuntimeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClientBuilder; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Runtime client for all users to use. This implementation is for local instances to use a static - * and solid credential set. - */ -public class BedrockRuntimeClientSessionTokenImpl implements BedrockRuntimeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockRuntimeClientSessionTokenImpl.class); - private BedrockConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockRuntimeClientSessionTokenImpl(BedrockConfiguration configuration) { - LOG.trace("Creating an AWS Bedrock Runtime manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Runtime AWS client that is used. - * - * @return BedrockRuntimeClient Client. - */ - @Override - public BedrockRuntimeClient getBedrockRuntimeClient() { - BedrockRuntimeClient client = null; - BedrockRuntimeClientBuilder clientBuilder = BedrockRuntimeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } - - @Override - public BedrockRuntimeAsyncClient getBedrockRuntimeAsyncClient() { - BedrockRuntimeAsyncClient client = null; - BedrockRuntimeAsyncClientBuilder clientBuilder = BedrockRuntimeAsyncClient.builder(); - - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - // Note: Async clients use Netty by default, proxy and TLS configuration would require NettyNioAsyncHttpClient - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientStandardImpl.java b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientStandardImpl.java deleted file mode 100644 index 57373d296204b..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/client/impl/BedrockRuntimeClientStandardImpl.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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.aws2.bedrock.runtime.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration; -import org.apache.camel.component.aws2.bedrock.runtime.client.BedrockRuntimeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClientBuilder; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; -import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Bedrock Runtime client for all users to use. This implementation is for local instances to use a static - * and solid credential set. - */ -public class BedrockRuntimeClientStandardImpl implements BedrockRuntimeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(BedrockRuntimeClientStandardImpl.class); - private BedrockConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public BedrockRuntimeClientStandardImpl(BedrockConfiguration configuration) { - LOG.trace("Creating an AWS Bedrock Runtime manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Bedrock Runtime AWS client that is used. - * - * @return BedrockRuntime Client. - */ - @Override - public BedrockRuntimeClient getBedrockRuntimeClient() { - BedrockRuntimeClient client = null; - BedrockRuntimeClientBuilder clientBuilder = BedrockRuntimeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } - - /** - * Getting the Bedrock Runtime AWS async client for streaming operations. - * - * @return BedrockRuntimeAsyncClient Async Client. - */ - @Override - public BedrockRuntimeAsyncClient getBedrockRuntimeAsyncClient() { - BedrockRuntimeAsyncClient client = null; - BedrockRuntimeAsyncClientBuilder clientBuilder = BedrockRuntimeAsyncClient.builder(); - - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - // Note: Async clients use Netty by default, proxy and TLS configuration would require NettyNioAsyncHttpClient - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentClientFactoryTest.java b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentClientFactoryTest.java deleted file mode 100644 index 92e05161bc06f..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agent/BedrockAgentClientFactoryTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.aws2.bedrock.agent; - -import org.apache.camel.component.aws2.bedrock.agent.client.BedrockAgentClientFactory; -import org.apache.camel.component.aws2.bedrock.agent.client.BedrockAgentInternalClient; -import org.apache.camel.component.aws2.bedrock.agent.client.impl.BedrockAgentClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.agent.client.impl.BedrockAgentClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.agent.client.impl.BedrockAgentClientSessionTokenImpl; -import org.apache.camel.component.aws2.bedrock.agent.client.impl.BedrockAgentClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BedrockAgentClientFactoryTest { - - @Test - public void getStandardBedrockAgentClientDefault() { - BedrockAgentConfiguration bedrockConfiguration = new BedrockAgentConfiguration(); - BedrockAgentInternalClient bedrockClient - = BedrockAgentClientFactory.getBedrockAgentClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockAgentClientStandardImpl); - } - - @Test - public void getStandardNoIamBedrockAgentClientDefault() { - BedrockAgentConfiguration bedrockConfiguration = new BedrockAgentConfiguration(); - bedrockConfiguration.setUseDefaultCredentialsProvider(false); - BedrockAgentInternalClient bedrockClient - = BedrockAgentClientFactory.getBedrockAgentClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockAgentClientStandardImpl); - } - - @Test - public void getIamBedrockAgentClientDefault() { - BedrockAgentConfiguration bedrockConfiguration = new BedrockAgentConfiguration(); - bedrockConfiguration.setUseDefaultCredentialsProvider(true); - BedrockAgentInternalClient bedrockClient - = BedrockAgentClientFactory.getBedrockAgentClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockAgentClientIAMOptimizedImpl); - } - - @Test - public void getSessionBedrockAgentClientDefault() { - BedrockAgentConfiguration bedrockConfiguration = new BedrockAgentConfiguration(); - bedrockConfiguration.setUseSessionCredentials(true); - BedrockAgentInternalClient bedrockClient - = BedrockAgentClientFactory.getBedrockAgentClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockAgentClientSessionTokenImpl); - } - - @Test - public void getIamProfileBedrockAgentClientDefault() { - BedrockAgentConfiguration bedrockConfiguration = new BedrockAgentConfiguration(); - bedrockConfiguration.setUseProfileCredentialsProvider(true); - BedrockAgentInternalClient bedrockClient - = BedrockAgentClientFactory.getBedrockAgentClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockAgentClientIAMProfileOptimizedImpl); - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeClientFactoryTest.java b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeClientFactoryTest.java deleted file mode 100644 index b77d95edd261f..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeClientFactoryTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.aws2.bedrock.agentruntime; - -import org.apache.camel.component.aws2.bedrock.agentruntime.client.BedrockAgentRuntimeClientFactory; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.BedrockAgentRuntimeInternalClient; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.impl.BedrockAgentRuntimeClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.impl.BedrockAgentRuntimeClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.impl.BedrockAgentRuntimeClientSessionTokenImpl; -import org.apache.camel.component.aws2.bedrock.agentruntime.client.impl.BedrockAgentRuntimeClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BedrockAgentRuntimeClientFactoryTest { - - @Test - public void getStandardBedrockAgentRuntimeClientDefault() { - BedrockAgentRuntimeConfiguration bedrockConfiguration = new BedrockAgentRuntimeConfiguration(); - BedrockAgentRuntimeInternalClient bedrockClient - = BedrockAgentRuntimeClientFactory.getBedrockAgentRuntimeClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockAgentRuntimeClientStandardImpl); - } - - @Test - public void getStandardDefaultBedrockAgentRuntimeClient() { - BedrockAgentRuntimeConfiguration bedrockConfiguration = new BedrockAgentRuntimeConfiguration(); - bedrockConfiguration.setUseDefaultCredentialsProvider(false); - BedrockAgentRuntimeInternalClient bedrockClient - = BedrockAgentRuntimeClientFactory.getBedrockAgentRuntimeClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockAgentRuntimeClientStandardImpl); - } - - @Test - public void getIAMOptimizedBedrockAgentRuntimeClient() { - BedrockAgentRuntimeConfiguration bedrockConfiguration = new BedrockAgentRuntimeConfiguration(); - bedrockConfiguration.setUseDefaultCredentialsProvider(true); - BedrockAgentRuntimeInternalClient bedrockClient - = BedrockAgentRuntimeClientFactory.getBedrockAgentRuntimeClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockAgentRuntimeClientIAMOptimizedImpl); - } - - @Test - public void getSessionTokenBedrockAgentRuntimeClient() { - BedrockAgentRuntimeConfiguration bedrockConfiguration = new BedrockAgentRuntimeConfiguration(); - bedrockConfiguration.setUseSessionCredentials(true); - BedrockAgentRuntimeInternalClient bedrockClient - = BedrockAgentRuntimeClientFactory.getBedrockAgentRuntimeClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockAgentRuntimeClientSessionTokenImpl); - } - - @Test - public void getProfileBedrockAgentRuntimeClient() { - BedrockAgentRuntimeConfiguration bedrockConfiguration = new BedrockAgentRuntimeConfiguration(); - bedrockConfiguration.setUseProfileCredentialsProvider(true); - BedrockAgentRuntimeInternalClient bedrockClient - = BedrockAgentRuntimeClientFactory.getBedrockAgentRuntimeClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockAgentRuntimeClientIAMProfileOptimizedImpl); - } -} diff --git a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockRuntimeClientFactoryTest.java b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockRuntimeClientFactoryTest.java deleted file mode 100644 index 07f89a8cd4dc0..0000000000000 --- a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/runtime/BedrockRuntimeClientFactoryTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.aws2.bedrock.runtime; - -import org.apache.camel.component.aws2.bedrock.runtime.client.BedrockClientFactory; -import org.apache.camel.component.aws2.bedrock.runtime.client.BedrockRuntimeInternalClient; -import org.apache.camel.component.aws2.bedrock.runtime.client.impl.BedrockRuntimeClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.runtime.client.impl.BedrockRuntimeClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.bedrock.runtime.client.impl.BedrockRuntimeClientSessionTokenImpl; -import org.apache.camel.component.aws2.bedrock.runtime.client.impl.BedrockRuntimeClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BedrockRuntimeClientFactoryTest { - - @Test - public void getStandardBedrockClientDefault() { - BedrockConfiguration bedrockConfiguration = new BedrockConfiguration(); - BedrockRuntimeInternalClient bedrockClient = BedrockClientFactory.getBedrockRuntimeClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockRuntimeClientStandardImpl); - } - - @Test - public void getStandardDefaultBedrockClient() { - BedrockConfiguration bedrockConfiguration = new BedrockConfiguration(); - bedrockConfiguration.setUseDefaultCredentialsProvider(false); - BedrockRuntimeInternalClient bedrockClient = BedrockClientFactory.getBedrockRuntimeClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockRuntimeClientStandardImpl); - } - - @Test - public void getIAMOptimizedBedrockClient() { - BedrockConfiguration bedrockConfiguration = new BedrockConfiguration(); - bedrockConfiguration.setUseDefaultCredentialsProvider(true); - BedrockRuntimeInternalClient bedrockClient = BedrockClientFactory.getBedrockRuntimeClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockRuntimeClientIAMOptimizedImpl); - } - - @Test - public void getSessionTokenBedrockClient() { - BedrockConfiguration bedrockConfiguration = new BedrockConfiguration(); - bedrockConfiguration.setUseSessionCredentials(true); - BedrockRuntimeInternalClient bedrockClient = BedrockClientFactory.getBedrockRuntimeClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockRuntimeClientSessionTokenImpl); - } - - @Test - public void getProfileBedrockClient() { - BedrockConfiguration bedrockConfiguration = new BedrockConfiguration(); - bedrockConfiguration.setUseProfileCredentialsProvider(true); - BedrockRuntimeInternalClient bedrockClient = BedrockClientFactory.getBedrockRuntimeClient(bedrockConfiguration); - assertTrue(bedrockClient instanceof BedrockRuntimeClientIAMProfileOptimizedImpl); - } -} diff --git a/components/camel-aws/camel-aws-cloudtrail/pom.xml b/components/camel-aws/camel-aws-cloudtrail/pom.xml index 28d66539456a3..697f63ac624f4 100644 --- a/components/camel-aws/camel-aws-cloudtrail/pom.xml +++ b/components/camel-aws/camel-aws-cloudtrail/pom.xml @@ -40,6 +40,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + software.amazon.awssdk cloudtrail diff --git a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConfiguration.java b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConfiguration.java index e2cc6cede9403..b705b743379b8 100644 --- a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConfiguration.java +++ b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws.cloudtrail; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.cloudtrail.CloudTrailClient; @UriParams -public class CloudtrailConfiguration implements Cloneable { +public class CloudtrailConfiguration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "A label for indexing cloudtrail endpoints") @Metadata(required = true) diff --git a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailEndpoint.java b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailEndpoint.java index 41ee638b3b458..fbc618878cc4a 100644 --- a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailEndpoint.java +++ b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailEndpoint.java @@ -53,7 +53,7 @@ protected void doStart() throws Exception { super.doStart(); cloudTrailClient = configuration.getCloudTrailClient() != null ? configuration.getCloudTrailClient() - : CloudtrailClientFactory.getCloudtrailClient(configuration).getCloudtrailClient(); + : CloudtrailClientFactory.getCloudtrailClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/CloudtrailClientFactory.java b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/CloudtrailClientFactory.java index 83fed0000fdf9..582d1f7018296 100644 --- a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/CloudtrailClientFactory.java +++ b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/CloudtrailClientFactory.java @@ -17,13 +17,11 @@ package org.apache.camel.component.aws.cloudtrail.client; import org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration; -import org.apache.camel.component.aws.cloudtrail.client.impl.CloudtrailClientIAMOptimizedImpl; -import org.apache.camel.component.aws.cloudtrail.client.impl.CloudtrailClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws.cloudtrail.client.impl.CloudtrailClientSessionTokenImpl; -import org.apache.camel.component.aws.cloudtrail.client.impl.CloudtrailClientStandardImpl; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; +import software.amazon.awssdk.services.cloudtrail.CloudTrailClient; /** - * Factory class to return the correct type of AWS Cloudtrail client. + * Factory class to create AWS CloudTrail clients using common configuration. */ public final class CloudtrailClientFactory { @@ -31,20 +29,14 @@ private CloudtrailClientFactory() { } /** - * Return the correct aws Cloudtrail client (based on remote vs local). + * Create a CloudTrailClient based on configuration. * - * @param configuration configuration - * @return CloudTrailClient + * @param configuration The CloudTrail configuration + * @return Configured CloudTrailClient */ - public static CloudtrailInternalClient getCloudtrailClient(CloudtrailConfiguration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new CloudtrailClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new CloudtrailClientIAMProfileOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new CloudtrailClientSessionTokenImpl(configuration); - } else { - return new CloudtrailClientStandardImpl(configuration); - } + public static CloudTrailClient getCloudtrailClient(CloudtrailConfiguration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + CloudTrailClient::builder); } } diff --git a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/CloudtrailInternalClient.java b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/CloudtrailInternalClient.java deleted file mode 100644 index 7fa530c265787..0000000000000 --- a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/CloudtrailInternalClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.aws.cloudtrail.client; - -import software.amazon.awssdk.services.cloudtrail.CloudTrailClient; - -/** - * Manage the required actions of a CloudTrail client for either local or remote. - */ -public interface CloudtrailInternalClient { - - /** - * Returns a Cloudtrail client after a factory method determines which one to return. - * - * @return CloudTrail client - */ - CloudTrailClient getCloudtrailClient(); -} diff --git a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientIAMOptimizedImpl.java deleted file mode 100644 index dd89ed48e3a89..0000000000000 --- a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientIAMOptimizedImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.aws.cloudtrail.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration; -import org.apache.camel.component.aws.cloudtrail.client.CloudtrailInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.cloudtrail.CloudTrailClient; -import software.amazon.awssdk.services.cloudtrail.CloudTrailClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Cloudtrail client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class CloudtrailClientIAMOptimizedImpl implements CloudtrailInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(CloudtrailClientIAMOptimizedImpl.class); - private CloudtrailConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public CloudtrailClientIAMOptimizedImpl(CloudtrailConfiguration configuration) { - LOG.trace("Creating an AWS Cloudtrail client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Cloudtrail client that is used. - * - * @return Amazon Cloudtrail Client. - */ - @Override - public CloudTrailClient getCloudtrailClient() { - CloudTrailClient client = null; - CloudTrailClientBuilder clientBuilder = CloudTrailClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientIAMProfileOptimizedImpl.java deleted file mode 100644 index 23598d742c217..0000000000000 --- a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.aws.cloudtrail.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration; -import org.apache.camel.component.aws.cloudtrail.client.CloudtrailInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.cloudtrail.CloudTrailClient; -import software.amazon.awssdk.services.cloudtrail.CloudTrailClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Cloudtrail client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class CloudtrailClientIAMProfileOptimizedImpl implements CloudtrailInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(CloudtrailClientIAMProfileOptimizedImpl.class); - private CloudtrailConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public CloudtrailClientIAMProfileOptimizedImpl(CloudtrailConfiguration configuration) { - LOG.trace("Creating an AWS Cloudtrail client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Cloudtrail client that is used. - * - * @return Amazon Cloudtrail Client. - */ - @Override - public CloudTrailClient getCloudtrailClient() { - CloudTrailClient client = null; - CloudTrailClientBuilder clientBuilder = CloudTrailClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientSessionTokenImpl.java b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientSessionTokenImpl.java deleted file mode 100644 index 9a0128ba3af34..0000000000000 --- a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientSessionTokenImpl.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.aws.cloudtrail.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration; -import org.apache.camel.component.aws.cloudtrail.client.CloudtrailInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.cloudtrail.CloudTrailClient; -import software.amazon.awssdk.services.cloudtrail.CloudTrailClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Cloudtrail client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class CloudtrailClientSessionTokenImpl implements CloudtrailInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(CloudtrailClientStandardImpl.class); - private CloudtrailConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public CloudtrailClientSessionTokenImpl(CloudtrailConfiguration configuration) { - LOG.trace("Creating an AWS Cloudtrail manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Cloudtrail client that is used. - * - * @return Amazon Cloudtrail Client. - */ - @Override - public CloudTrailClient getCloudtrailClient() { - CloudTrailClient client = null; - CloudTrailClientBuilder clientBuilder = CloudTrailClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientStandardImpl.java b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientStandardImpl.java deleted file mode 100644 index eb09e30a23d90..0000000000000 --- a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/client/impl/CloudtrailClientStandardImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.aws.cloudtrail.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration; -import org.apache.camel.component.aws.cloudtrail.client.CloudtrailInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.cloudtrail.CloudTrailClient; -import software.amazon.awssdk.services.cloudtrail.CloudTrailClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Cloudtrail client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class CloudtrailClientStandardImpl implements CloudtrailInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(CloudtrailClientStandardImpl.class); - private CloudtrailConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public CloudtrailClientStandardImpl(CloudtrailConfiguration configuration) { - LOG.trace("Creating an AWS Cloudtrail manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Cloudtrail client that is used. - * - * @return Amazon Cloudtrail Client. - */ - @Override - public CloudTrailClient getCloudtrailClient() { - CloudTrailClient client = null; - CloudTrailClientBuilder clientBuilder = CloudTrailClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-cloudtrail/src/test/java/org/apache/camel/component/aws/cloudtrail/CloudtrailClientFactoryTest.java b/components/camel-aws/camel-aws-cloudtrail/src/test/java/org/apache/camel/component/aws/cloudtrail/CloudtrailClientFactoryTest.java deleted file mode 100644 index 4779eee8c13f3..0000000000000 --- a/components/camel-aws/camel-aws-cloudtrail/src/test/java/org/apache/camel/component/aws/cloudtrail/CloudtrailClientFactoryTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.aws.cloudtrail; - -import org.apache.camel.component.aws.cloudtrail.client.CloudtrailClientFactory; -import org.apache.camel.component.aws.cloudtrail.client.CloudtrailInternalClient; -import org.apache.camel.component.aws.cloudtrail.client.impl.CloudtrailClientIAMOptimizedImpl; -import org.apache.camel.component.aws.cloudtrail.client.impl.CloudtrailClientSessionTokenImpl; -import org.apache.camel.component.aws.cloudtrail.client.impl.CloudtrailClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class CloudtrailClientFactoryTest { - - @Test - public void getStandardCloudtrailClientDefault() { - CloudtrailConfiguration cloudtrailConf = new CloudtrailConfiguration(); - CloudtrailInternalClient cloudtrailClient = CloudtrailClientFactory.getCloudtrailClient(cloudtrailConf); - assertTrue(cloudtrailClient instanceof CloudtrailClientStandardImpl); - } - - @Test - public void getStandardCloudtrailClient() { - CloudtrailConfiguration cloudtrailConf = new CloudtrailConfiguration(); - cloudtrailConf.setUseDefaultCredentialsProvider(false); - CloudtrailInternalClient cloudtrailClient = CloudtrailClientFactory.getCloudtrailClient(cloudtrailConf); - assertTrue(cloudtrailClient instanceof CloudtrailClientStandardImpl); - } - - @Test - public void getIAMOptimizedCloudtrailClient() { - CloudtrailConfiguration cloudtrailConf = new CloudtrailConfiguration(); - cloudtrailConf.setUseDefaultCredentialsProvider(true); - CloudtrailInternalClient cloudtrailClient = CloudtrailClientFactory.getCloudtrailClient(cloudtrailConf); - assertTrue(cloudtrailClient instanceof CloudtrailClientIAMOptimizedImpl); - } - - @Test - public void getIAMSessionTokenCloudtrailClient() { - CloudtrailConfiguration cloudtrailConf = new CloudtrailConfiguration(); - cloudtrailConf.setUseSessionCredentials(true); - CloudtrailInternalClient cloudtrailClient = CloudtrailClientFactory.getCloudtrailClient(cloudtrailConf); - assertTrue(cloudtrailClient instanceof CloudtrailClientSessionTokenImpl); - } -} diff --git a/components/camel-aws/camel-aws-config/pom.xml b/components/camel-aws/camel-aws-config/pom.xml index 2fc4687d76f68..ed8aaaeb2983c 100644 --- a/components/camel-aws/camel-aws-config/pom.xml +++ b/components/camel-aws/camel-aws-config/pom.xml @@ -40,6 +40,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + software.amazon.awssdk config diff --git a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/AWSConfigConfiguration.java b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/AWSConfigConfiguration.java index 3382d7e2b0e3e..c364c07a06f72 100644 --- a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/AWSConfigConfiguration.java +++ b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/AWSConfigConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws.config; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.config.ConfigClient; @UriParams -public class AWSConfigConfiguration implements Cloneable { +public class AWSConfigConfiguration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) @@ -216,11 +217,11 @@ public void setUriEndpointOverride(String uriEndpointOverride) { * Set whether the Config client should expect to load credentials through a default credentials provider or to * expect static credentials to be passed in. */ - public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvider) { + public void setUseDefaultCredentialsProvider(boolean useDefaultCredentialsProvider) { this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/AWSConfigEndpoint.java b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/AWSConfigEndpoint.java index b073f5c5b46ee..8459fc8668bfd 100644 --- a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/AWSConfigEndpoint.java +++ b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/AWSConfigEndpoint.java @@ -67,7 +67,7 @@ public void doStart() throws Exception { super.doStart(); configClient = configuration.getConfigClient() != null - ? configuration.getConfigClient() : AWSConfigClientFactory.getConfigClient(configuration).getConfigClient(); + ? configuration.getConfigClient() : AWSConfigClientFactory.getConfigClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/AWSConfigClientFactory.java b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/AWSConfigClientFactory.java index 0dcd31f101e2e..8464340418b7e 100644 --- a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/AWSConfigClientFactory.java +++ b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/AWSConfigClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws.config.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws.config.AWSConfigConfiguration; -import org.apache.camel.component.aws.config.client.impl.AWSConfigClientIAMOptimizedImpl; -import org.apache.camel.component.aws.config.client.impl.AWSConfigClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws.config.client.impl.AWSConfigClientSessionTokenImpl; -import org.apache.camel.component.aws.config.client.impl.AWSConfigClientStandardImpl; +import software.amazon.awssdk.services.config.ConfigClient; /** - * Factory class to return the correct type of AWS Config client. + * Factory class to create AWS Config clients using common configuration. */ public final class AWSConfigClientFactory { @@ -31,20 +29,14 @@ private AWSConfigClientFactory() { } /** - * Return the correct AWS Config client (based on remote vs local). + * Create a ConfigClient based on configuration. * - * @param configuration configuration - * @return ConfigClient + * @param configuration The Config configuration + * @return Configured ConfigClient */ - public static AWSConfigInternalClient getConfigClient(AWSConfigConfiguration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new AWSConfigClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new AWSConfigClientIAMProfileOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new AWSConfigClientSessionTokenImpl(configuration); - } else { - return new AWSConfigClientStandardImpl(configuration); - } + public static ConfigClient getConfigClient(AWSConfigConfiguration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + ConfigClient::builder); } } diff --git a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/AWSConfigInternalClient.java b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/AWSConfigInternalClient.java deleted file mode 100644 index f77cabfb0b42b..0000000000000 --- a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/AWSConfigInternalClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.aws.config.client; - -import software.amazon.awssdk.services.config.ConfigClient; - -/** - * Manage the required actions of a Config client for either local or remote. - */ -public interface AWSConfigInternalClient { - - /** - * Returns a Config client after a factory method determines which one to return. - * - * @return ConfigClient ConfigClient - */ - ConfigClient getConfigClient(); -} diff --git a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientIAMOptimizedImpl.java deleted file mode 100644 index 0ca273f95543b..0000000000000 --- a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientIAMOptimizedImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.aws.config.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.config.AWSConfigConfiguration; -import org.apache.camel.component.aws.config.client.AWSConfigInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.config.ConfigClient; -import software.amazon.awssdk.services.config.ConfigClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Config client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class AWSConfigClientIAMOptimizedImpl implements AWSConfigInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(AWSConfigClientIAMOptimizedImpl.class); - private AWSConfigConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public AWSConfigClientIAMOptimizedImpl(AWSConfigConfiguration configuration) { - LOG.trace("Creating an AWS Config client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Config aws client that is used. - * - * @return ConfigClient Client. - */ - @Override - public ConfigClient getConfigClient() { - ConfigClient client = null; - ConfigClientBuilder clientBuilder = ConfigClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientIAMProfileOptimizedImpl.java deleted file mode 100644 index fb5bc657e413a..0000000000000 --- a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.aws.config.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.config.AWSConfigConfiguration; -import org.apache.camel.component.aws.config.client.AWSConfigInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.config.ConfigClient; -import software.amazon.awssdk.services.config.ConfigClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Config client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class AWSConfigClientIAMProfileOptimizedImpl implements AWSConfigInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(AWSConfigClientIAMProfileOptimizedImpl.class); - private AWSConfigConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public AWSConfigClientIAMProfileOptimizedImpl(AWSConfigConfiguration configuration) { - LOG.trace("Creating an AWS Config client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Config aws client that is used. - * - * @return ConfigClient Client. - */ - @Override - public ConfigClient getConfigClient() { - ConfigClient client = null; - ConfigClientBuilder clientBuilder = ConfigClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientSessionTokenImpl.java b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientSessionTokenImpl.java deleted file mode 100644 index b0c368a9ec263..0000000000000 --- a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientSessionTokenImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.aws.config.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.config.AWSConfigConfiguration; -import org.apache.camel.component.aws.config.client.AWSConfigInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.config.ConfigClient; -import software.amazon.awssdk.services.config.ConfigClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Config client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class AWSConfigClientSessionTokenImpl implements AWSConfigInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(AWSConfigClientSessionTokenImpl.class); - private AWSConfigConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public AWSConfigClientSessionTokenImpl(AWSConfigConfiguration configuration) { - LOG.trace("Creating an AWS Config manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Config AWS client that is used. - * - * @return Amazon Config Client. - */ - @Override - public ConfigClient getConfigClient() { - ConfigClient client = null; - ConfigClientBuilder clientBuilder = ConfigClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientStandardImpl.java b/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientStandardImpl.java deleted file mode 100644 index 997e0f161c764..0000000000000 --- a/components/camel-aws/camel-aws-config/src/main/java/org/apache/camel/component/aws/config/client/impl/AWSConfigClientStandardImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.aws.config.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.config.AWSConfigConfiguration; -import org.apache.camel.component.aws.config.client.AWSConfigInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.config.ConfigClient; -import software.amazon.awssdk.services.config.ConfigClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Config client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class AWSConfigClientStandardImpl implements AWSConfigInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(AWSConfigClientStandardImpl.class); - private AWSConfigConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public AWSConfigClientStandardImpl(AWSConfigConfiguration configuration) { - LOG.trace("Creating an AWS Config manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Config AWS client that is used. - * - * @return Amazon Config Client. - */ - @Override - public ConfigClient getConfigClient() { - ConfigClient client = null; - ConfigClientBuilder clientBuilder = ConfigClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-config/src/test/java/org/apache/camel/component/aws/config/AWSConfigClientFactoryTest.java b/components/camel-aws/camel-aws-config/src/test/java/org/apache/camel/component/aws/config/AWSConfigClientFactoryTest.java deleted file mode 100644 index 64951e308673d..0000000000000 --- a/components/camel-aws/camel-aws-config/src/test/java/org/apache/camel/component/aws/config/AWSConfigClientFactoryTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.aws.config; - -import org.apache.camel.component.aws.config.client.AWSConfigClientFactory; -import org.apache.camel.component.aws.config.client.AWSConfigInternalClient; -import org.apache.camel.component.aws.config.client.impl.AWSConfigClientIAMOptimizedImpl; -import org.apache.camel.component.aws.config.client.impl.AWSConfigClientSessionTokenImpl; -import org.apache.camel.component.aws.config.client.impl.AWSConfigClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class AWSConfigClientFactoryTest { - - @Test - public void getStandardConfigClientDefault() { - AWSConfigConfiguration configConfiguration = new AWSConfigConfiguration(); - AWSConfigInternalClient configClient = AWSConfigClientFactory.getConfigClient(configConfiguration); - assertTrue(configClient instanceof AWSConfigClientStandardImpl); - } - - @Test - public void getStandardConfigClient() { - AWSConfigConfiguration configConfiguration = new AWSConfigConfiguration(); - configConfiguration.setUseDefaultCredentialsProvider(false); - AWSConfigInternalClient configClient = AWSConfigClientFactory.getConfigClient(configConfiguration); - assertTrue(configClient instanceof AWSConfigClientStandardImpl); - } - - @Test - public void getIAMOptimizedConfigClient() { - AWSConfigConfiguration configConfiguration = new AWSConfigConfiguration(); - configConfiguration.setUseDefaultCredentialsProvider(true); - AWSConfigInternalClient configClient = AWSConfigClientFactory.getConfigClient(configConfiguration); - assertTrue(configClient instanceof AWSConfigClientIAMOptimizedImpl); - } - - @Test - public void getSessionTokenConfigClient() { - AWSConfigConfiguration configConfiguration = new AWSConfigConfiguration(); - configConfiguration.setUseSessionCredentials(true); - AWSConfigInternalClient configClient = AWSConfigClientFactory.getConfigClient(configConfiguration); - assertTrue(configClient instanceof AWSConfigClientSessionTokenImpl); - } -} diff --git a/components/camel-aws/camel-aws-secrets-manager/pom.xml b/components/camel-aws/camel-aws-secrets-manager/pom.xml index 9eccbb6f11b0b..d9eb53fc393bd 100644 --- a/components/camel-aws/camel-aws-secrets-manager/pom.xml +++ b/components/camel-aws/camel-aws-secrets-manager/pom.xml @@ -42,6 +42,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + org.apache.camel camel-util-json diff --git a/components/camel-aws/camel-aws-secrets-manager/src/generated/resources/META-INF/org/apache/camel/component/aws/secretsmanager/aws-secrets-manager.json b/components/camel-aws/camel-aws-secrets-manager/src/generated/resources/META-INF/org/apache/camel/component/aws/secretsmanager/aws-secrets-manager.json index d752f6b813c61..27c10d35f695f 100644 --- a/components/camel-aws/camel-aws-secrets-manager/src/generated/resources/META-INF/org/apache/camel/component/aws/secretsmanager/aws-secrets-manager.json +++ b/components/camel-aws/camel-aws-secrets-manager/src/generated/resources/META-INF/org/apache/camel/component/aws/secretsmanager/aws-secrets-manager.json @@ -46,7 +46,7 @@ "secretKey": { "index": 18, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, "sessionToken": { "index": 19, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, "trustAllCertificates": { "index": 20, "kind": "property", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, - "useDefaultCredentialsProvider": { "index": 21, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Translate client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in." }, + "useDefaultCredentialsProvider": { "index": 21, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Secrets Manager client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in." }, "useSessionCredentials": { "index": 22, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Secrets Manager client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Secrets Manager." } }, "headers": { @@ -81,7 +81,7 @@ "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, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, "sessionToken": { "index": 16, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, "trustAllCertificates": { "index": 17, "kind": "parameter", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, - "useDefaultCredentialsProvider": { "index": 18, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Translate client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in." }, + "useDefaultCredentialsProvider": { "index": 18, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Secrets Manager client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in." }, "useSessionCredentials": { "index": 19, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration", "configurationField": "configuration", "description": "Set whether the Secrets Manager client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Secrets Manager." } } } diff --git a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerConfiguration.java b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerConfiguration.java index 3ca3ceca1044e..9654a3bd12ed9 100644 --- a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerConfiguration.java +++ b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws.secretsmanager; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient; @UriParams -public class SecretsManagerConfiguration implements Cloneable { +public class SecretsManagerConfiguration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) @@ -231,14 +232,14 @@ public void setBinaryPayload(boolean binaryPayload) { } /** - * Set whether the Translate client should expect to load credentials through a default credentials provider or to - * expect static credentials to be passed in. + * Set whether the Secrets Manager client should expect to load credentials through a default credentials provider + * or to expect static credentials to be passed in. */ - public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvider) { + public void setUseDefaultCredentialsProvider(boolean useDefaultCredentialsProvider) { this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerEndpoint.java b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerEndpoint.java index 3630526753975..a2fa0489f14e4 100644 --- a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerEndpoint.java +++ b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerEndpoint.java @@ -72,7 +72,7 @@ public void doStart() throws Exception { secretsManagerClient = configuration.getSecretsManagerClient() != null ? configuration.getSecretsManagerClient() - : SecretsManagerClientFactory.getSecretsManagerClient(configuration).getSecretsManagerClient(); + : SecretsManagerClientFactory.getSecretsManagerClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/SecretsManagerClientFactory.java b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/SecretsManagerClientFactory.java index e3d0b1b4a1526..5224c5df52a67 100644 --- a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/SecretsManagerClientFactory.java +++ b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/SecretsManagerClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws.secretsmanager.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration; -import org.apache.camel.component.aws.secretsmanager.client.impl.SecretsManagerClientIAMOptimized; -import org.apache.camel.component.aws.secretsmanager.client.impl.SecretsManagerClientIAMProfileOptimized; -import org.apache.camel.component.aws.secretsmanager.client.impl.SecretsManagerClientSessionTokenImpl; -import org.apache.camel.component.aws.secretsmanager.client.impl.SecretsManagerClientStandardImpl; +import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient; /** - * Factory class to return the correct type of AWS Secrets Manager aws. + * Factory class to create AWS Secrets Manager clients using common configuration. */ public final class SecretsManagerClientFactory { @@ -31,20 +29,14 @@ private SecretsManagerClientFactory() { } /** - * Return the correct aws Secrets Manager client (based on remote vs local). + * Create a SecretsManagerClient based on configuration. * - * @param configuration configuration - * @return SecretsManagerClient + * @param configuration The Secrets Manager configuration + * @return Configured SecretsManagerClient */ - public static SecretsManagerInternalClient getSecretsManagerClient(SecretsManagerConfiguration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new SecretsManagerClientIAMOptimized(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new SecretsManagerClientIAMProfileOptimized(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new SecretsManagerClientSessionTokenImpl(configuration); - } else { - return new SecretsManagerClientStandardImpl(configuration); - } + public static SecretsManagerClient getSecretsManagerClient(SecretsManagerConfiguration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + SecretsManagerClient::builder); } } diff --git a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/SecretsManagerInternalClient.java b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/SecretsManagerInternalClient.java deleted file mode 100644 index fa8cd02598a96..0000000000000 --- a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/SecretsManagerInternalClient.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.aws.secretsmanager.client; - -import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient; - -public interface SecretsManagerInternalClient { - - /** - * Returns an secrets manager client after a factory method determines which one to return. - * - * @return SecretsManagerClient secretsManagerClient - */ - SecretsManagerClient getSecretsManagerClient(); - -} diff --git a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientIAMOptimized.java b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientIAMOptimized.java deleted file mode 100644 index 0905d67cf6d22..0000000000000 --- a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientIAMOptimized.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.aws.secretsmanager.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration; -import org.apache.camel.component.aws.secretsmanager.client.SecretsManagerInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient; -import software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Secrets Manager client for all users to use. This implementation is for remote instances to manage the - * credentials on their own (eliminating credential rotations) - */ -public class SecretsManagerClientIAMOptimized implements SecretsManagerInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(SecretsManagerClientIAMOptimized.class); - private SecretsManagerConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public SecretsManagerClientIAMOptimized(SecretsManagerConfiguration configuration) { - LOG.trace("Creating an AWS Secrets Manager client for working on AWS Services"); - this.configuration = configuration; - } - - /** - * Getting the Secrets Manager aws client that is used. - * - * @return Amazon Secrets Manager Client. - */ - @Override - public SecretsManagerClient getSecretsManagerClient() { - SecretsManagerClient client = null; - SecretsManagerClientBuilder clientBuilder = SecretsManagerClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientIAMProfileOptimized.java b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientIAMProfileOptimized.java deleted file mode 100644 index 9b061961f5306..0000000000000 --- a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientIAMProfileOptimized.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.aws.secretsmanager.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration; -import org.apache.camel.component.aws.secretsmanager.client.SecretsManagerInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient; -import software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Secrets Manager client for all users to use. This implementation is for remote instances to manage the - * credentials on their own (eliminating credential rotations) - */ -public class SecretsManagerClientIAMProfileOptimized implements SecretsManagerInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(SecretsManagerClientIAMProfileOptimized.class); - private SecretsManagerConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public SecretsManagerClientIAMProfileOptimized(SecretsManagerConfiguration configuration) { - LOG.trace("Creating an AWS Secrets Manager client for working on AWS Services"); - this.configuration = configuration; - } - - /** - * Getting the Secrets Manager aws client that is used. - * - * @return Amazon Secrets Manager Client. - */ - @Override - public SecretsManagerClient getSecretsManagerClient() { - SecretsManagerClient client = null; - SecretsManagerClientBuilder clientBuilder = SecretsManagerClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientSessionTokenImpl.java b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientSessionTokenImpl.java deleted file mode 100644 index 43bbf2fb4db59..0000000000000 --- a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientSessionTokenImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.aws.secretsmanager.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration; -import org.apache.camel.component.aws.secretsmanager.client.SecretsManagerInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient; -import software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Secrets Manager client for all users to use. This implementation is for local instances to use a static - * and solid credential set. - */ -public class SecretsManagerClientSessionTokenImpl implements SecretsManagerInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(SecretsManagerClientStandardImpl.class); - private SecretsManagerConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public SecretsManagerClientSessionTokenImpl(SecretsManagerConfiguration configuration) { - LOG.trace("Creating an AWS Secrets Manager manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Secrets Manager aws client that is used. - * - * @return Amazon Secrets Manager Client. - */ - @Override - public SecretsManagerClient getSecretsManagerClient() { - SecretsManagerClient client = null; - SecretsManagerClientBuilder clientBuilder = SecretsManagerClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientStandardImpl.java b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientStandardImpl.java deleted file mode 100644 index 4d9c4708a8703..0000000000000 --- a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/client/impl/SecretsManagerClientStandardImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.aws.secretsmanager.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration; -import org.apache.camel.component.aws.secretsmanager.client.SecretsManagerInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient; -import software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Secrets Manager client for all users to use. This implementation is for local instances to use a static - * and solid credential set. - */ -public class SecretsManagerClientStandardImpl implements SecretsManagerInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(SecretsManagerClientStandardImpl.class); - private SecretsManagerConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public SecretsManagerClientStandardImpl(SecretsManagerConfiguration configuration) { - LOG.trace("Creating an AWS Secrets Manager manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Secrets Manager aws client that is used. - * - * @return Amazon Secrets Manager Client. - */ - @Override - public SecretsManagerClient getSecretsManagerClient() { - SecretsManagerClient client = null; - SecretsManagerClientBuilder clientBuilder = SecretsManagerClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerClientFactoryTest.java b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerClientFactoryTest.java deleted file mode 100644 index a63564918f26c..0000000000000 --- a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerClientFactoryTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.aws.secretsmanager; - -import org.apache.camel.component.aws.secretsmanager.client.SecretsManagerClientFactory; -import org.apache.camel.component.aws.secretsmanager.client.SecretsManagerInternalClient; -import org.apache.camel.component.aws.secretsmanager.client.impl.SecretsManagerClientIAMOptimized; -import org.apache.camel.component.aws.secretsmanager.client.impl.SecretsManagerClientSessionTokenImpl; -import org.apache.camel.component.aws.secretsmanager.client.impl.SecretsManagerClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class SecretsManagerClientFactoryTest { - - @Test - public void getStandardSecretsManagerClientDefault() { - SecretsManagerConfiguration secretsManagerConfiguration = new SecretsManagerConfiguration(); - SecretsManagerInternalClient secretsManagerClient - = SecretsManagerClientFactory.getSecretsManagerClient(secretsManagerConfiguration); - assertTrue(secretsManagerClient instanceof SecretsManagerClientStandardImpl); - } - - @Test - public void getStandardSecretsManagerClient() { - SecretsManagerConfiguration secretsManagerConfiguration = new SecretsManagerConfiguration(); - secretsManagerConfiguration.setUseDefaultCredentialsProvider(false); - SecretsManagerInternalClient secretsManagerClient - = SecretsManagerClientFactory.getSecretsManagerClient(secretsManagerConfiguration); - assertTrue(secretsManagerClient instanceof SecretsManagerClientStandardImpl); - } - - @Test - public void getSecretsManagerOptimizedIAMClient() { - SecretsManagerConfiguration secretsManagerConfiguration = new SecretsManagerConfiguration(); - secretsManagerConfiguration.setUseDefaultCredentialsProvider(true); - SecretsManagerInternalClient secretsManagerClient - = SecretsManagerClientFactory.getSecretsManagerClient(secretsManagerConfiguration); - assertTrue(secretsManagerClient instanceof SecretsManagerClientIAMOptimized); - } - - @Test - public void getSecretsManagerSessionTokenClient() { - SecretsManagerConfiguration secretsManagerConfiguration = new SecretsManagerConfiguration(); - secretsManagerConfiguration.setUseSessionCredentials(true); - SecretsManagerInternalClient secretsManagerClient - = SecretsManagerClientFactory.getSecretsManagerClient(secretsManagerConfiguration); - assertTrue(secretsManagerClient instanceof SecretsManagerClientSessionTokenImpl); - } -} diff --git a/components/camel-aws/camel-aws2-athena/pom.xml b/components/camel-aws/camel-aws2-athena/pom.xml index b36e12d71461a..ead58965d4556 100644 --- a/components/camel-aws/camel-aws2-athena/pom.xml +++ b/components/camel-aws/camel-aws2-athena/pom.xml @@ -40,6 +40,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + software.amazon.awssdk athena diff --git a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2ComponentConfigurer.java b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2ComponentConfigurer.java index 9245b7406fd6a..ff510029e37d2 100644 --- a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2ComponentConfigurer.java +++ b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2ComponentConfigurer.java @@ -66,6 +66,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "outputLocation": getOrCreateConfiguration(target).setOutputLocation(property(camelContext, java.lang.String.class, value)); return true; case "outputtype": case "outputType": getOrCreateConfiguration(target).setOutputType(property(camelContext, org.apache.camel.component.aws2.athena.Athena2OutputType.class, value)); return true; + case "overrideendpoint": + case "overrideEndpoint": getOrCreateConfiguration(target).setOverrideEndpoint(property(camelContext, boolean.class, value)); return true; case "profilecredentialsname": case "profileCredentialsName": getOrCreateConfiguration(target).setProfileCredentialsName(property(camelContext, java.lang.String.class, value)); return true; case "proxyhost": @@ -86,6 +88,10 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "secretKey": getOrCreateConfiguration(target).setSecretKey(property(camelContext, java.lang.String.class, value)); return true; case "sessiontoken": case "sessionToken": getOrCreateConfiguration(target).setSessionToken(property(camelContext, java.lang.String.class, value)); return true; + case "trustallcertificates": + case "trustAllCertificates": getOrCreateConfiguration(target).setTrustAllCertificates(property(camelContext, boolean.class, value)); return true; + case "uriendpointoverride": + case "uriEndpointOverride": getOrCreateConfiguration(target).setUriEndpointOverride(property(camelContext, java.lang.String.class, value)); return true; case "usedefaultcredentialsprovider": case "useDefaultCredentialsProvider": getOrCreateConfiguration(target).setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true; case "useprofilecredentialsprovider": @@ -144,6 +150,8 @@ public Class getOptionType(String name, boolean ignoreCase) { case "outputLocation": return java.lang.String.class; case "outputtype": case "outputType": return org.apache.camel.component.aws2.athena.Athena2OutputType.class; + case "overrideendpoint": + case "overrideEndpoint": return boolean.class; case "profilecredentialsname": case "profileCredentialsName": return java.lang.String.class; case "proxyhost": @@ -164,6 +172,10 @@ public Class getOptionType(String name, boolean ignoreCase) { case "secretKey": return java.lang.String.class; case "sessiontoken": case "sessionToken": return java.lang.String.class; + case "trustallcertificates": + case "trustAllCertificates": return boolean.class; + case "uriendpointoverride": + case "uriEndpointOverride": return java.lang.String.class; case "usedefaultcredentialsprovider": case "useDefaultCredentialsProvider": return boolean.class; case "useprofilecredentialsprovider": @@ -218,6 +230,8 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "outputLocation": return getOrCreateConfiguration(target).getOutputLocation(); case "outputtype": case "outputType": return getOrCreateConfiguration(target).getOutputType(); + case "overrideendpoint": + case "overrideEndpoint": return getOrCreateConfiguration(target).isOverrideEndpoint(); case "profilecredentialsname": case "profileCredentialsName": return getOrCreateConfiguration(target).getProfileCredentialsName(); case "proxyhost": @@ -238,6 +252,10 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "secretKey": return getOrCreateConfiguration(target).getSecretKey(); case "sessiontoken": case "sessionToken": return getOrCreateConfiguration(target).getSessionToken(); + case "trustallcertificates": + case "trustAllCertificates": return getOrCreateConfiguration(target).isTrustAllCertificates(); + case "uriendpointoverride": + case "uriEndpointOverride": return getOrCreateConfiguration(target).getUriEndpointOverride(); case "usedefaultcredentialsprovider": case "useDefaultCredentialsProvider": return getOrCreateConfiguration(target).isUseDefaultCredentialsProvider(); case "useprofilecredentialsprovider": diff --git a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointConfigurer.java b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointConfigurer.java index 3b65899e5b6ff..11cfa82ec3824 100644 --- a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointConfigurer.java +++ b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointConfigurer.java @@ -52,6 +52,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "outputLocation": target.getConfiguration().setOutputLocation(property(camelContext, java.lang.String.class, value)); return true; case "outputtype": case "outputType": target.getConfiguration().setOutputType(property(camelContext, org.apache.camel.component.aws2.athena.Athena2OutputType.class, value)); return true; + case "overrideendpoint": + case "overrideEndpoint": target.getConfiguration().setOverrideEndpoint(property(camelContext, boolean.class, value)); return true; case "profilecredentialsname": case "profileCredentialsName": target.getConfiguration().setProfileCredentialsName(property(camelContext, java.lang.String.class, value)); return true; case "proxyhost": @@ -72,6 +74,10 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "secretKey": target.getConfiguration().setSecretKey(property(camelContext, java.lang.String.class, value)); return true; case "sessiontoken": case "sessionToken": target.getConfiguration().setSessionToken(property(camelContext, java.lang.String.class, value)); return true; + case "trustallcertificates": + case "trustAllCertificates": target.getConfiguration().setTrustAllCertificates(property(camelContext, boolean.class, value)); return true; + case "uriendpointoverride": + case "uriEndpointOverride": target.getConfiguration().setUriEndpointOverride(property(camelContext, java.lang.String.class, value)); return true; case "usedefaultcredentialsprovider": case "useDefaultCredentialsProvider": target.getConfiguration().setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true; case "useprofilecredentialsprovider": @@ -123,6 +129,8 @@ public Class getOptionType(String name, boolean ignoreCase) { case "outputLocation": return java.lang.String.class; case "outputtype": case "outputType": return org.apache.camel.component.aws2.athena.Athena2OutputType.class; + case "overrideendpoint": + case "overrideEndpoint": return boolean.class; case "profilecredentialsname": case "profileCredentialsName": return java.lang.String.class; case "proxyhost": @@ -143,6 +151,10 @@ public Class getOptionType(String name, boolean ignoreCase) { case "secretKey": return java.lang.String.class; case "sessiontoken": case "sessionToken": return java.lang.String.class; + case "trustallcertificates": + case "trustAllCertificates": return boolean.class; + case "uriendpointoverride": + case "uriEndpointOverride": return java.lang.String.class; case "usedefaultcredentialsprovider": case "useDefaultCredentialsProvider": return boolean.class; case "useprofilecredentialsprovider": @@ -190,6 +202,8 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "outputLocation": return target.getConfiguration().getOutputLocation(); case "outputtype": case "outputType": return target.getConfiguration().getOutputType(); + case "overrideendpoint": + case "overrideEndpoint": return target.getConfiguration().isOverrideEndpoint(); case "profilecredentialsname": case "profileCredentialsName": return target.getConfiguration().getProfileCredentialsName(); case "proxyhost": @@ -210,6 +224,10 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "secretKey": return target.getConfiguration().getSecretKey(); case "sessiontoken": case "sessionToken": return target.getConfiguration().getSessionToken(); + case "trustallcertificates": + case "trustAllCertificates": return target.getConfiguration().isTrustAllCertificates(); + case "uriendpointoverride": + case "uriEndpointOverride": return target.getConfiguration().getUriEndpointOverride(); case "usedefaultcredentialsprovider": case "useDefaultCredentialsProvider": return target.getConfiguration().isUseDefaultCredentialsProvider(); case "useprofilecredentialsprovider": diff --git a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointUriFactory.java b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointUriFactory.java index 04b2eb26075bf..d2fcd30867e06 100644 --- a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointUriFactory.java +++ b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointUriFactory.java @@ -23,7 +23,7 @@ public class Athena2EndpointUriFactory extends org.apache.camel.support.componen private static final Set SECRET_PROPERTY_NAMES; private static final Map MULTI_VALUE_PREFIXES; static { - Set props = new HashSet<>(33); + Set props = new HashSet<>(36); props.add("accessKey"); props.add("amazonAthenaClient"); props.add("clientRequestToken"); @@ -41,6 +41,7 @@ public class Athena2EndpointUriFactory extends org.apache.camel.support.componen props.add("operation"); props.add("outputLocation"); props.add("outputType"); + props.add("overrideEndpoint"); props.add("profileCredentialsName"); props.add("proxyHost"); props.add("proxyPort"); @@ -52,6 +53,8 @@ public class Athena2EndpointUriFactory extends org.apache.camel.support.componen props.add("retry"); props.add("secretKey"); props.add("sessionToken"); + props.add("trustAllCertificates"); + props.add("uriEndpointOverride"); props.add("useDefaultCredentialsProvider"); props.add("useProfileCredentialsProvider"); props.add("useSessionCredentials"); diff --git a/components/camel-aws/camel-aws2-athena/src/generated/resources/META-INF/org/apache/camel/component/aws2/athena/aws2-athena.json b/components/camel-aws/camel-aws2-athena/src/generated/resources/META-INF/org/apache/camel/component/aws2/athena/aws2-athena.json index 57a23cfb9985b..ae22a1de72bec 100644 --- a/components/camel-aws/camel-aws2-athena/src/generated/resources/META-INF/org/apache/camel/component/aws2/athena/aws2-athena.json +++ b/components/camel-aws/camel-aws2-athena/src/generated/resources/META-INF/org/apache/camel/component/aws2/athena/aws2-athena.json @@ -35,31 +35,34 @@ "operation": { "index": 8, "kind": "property", "displayName": "Operation", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.aws2.athena.Athena2Operations", "enum": [ "getQueryExecution", "getQueryResults", "listQueryExecutions", "startQueryExecution" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "startQueryExecution", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The Athena API function to call." }, "outputLocation": { "index": 9, "kind": "property", "displayName": "Output Location", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The location in Amazon S3 where query results are stored, such as s3:\/\/path\/to\/query\/bucket\/. Ensure this value ends with a forward slash." }, "outputType": { "index": 10, "kind": "property", "displayName": "Output Type", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.aws2.athena.Athena2OutputType", "enum": [ "StreamList", "SelectList", "S3Pointer" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "StreamList", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "How query results should be returned. One of StreamList (default - return a GetQueryResultsIterable that can page through all results), SelectList (returns at most 1000 rows at a time, plus a NextToken value as a header than can be used for manual pagination of results), S3Pointer (return an S3 path pointing to the results)." }, - "queryExecutionId": { "index": 11, "kind": "property", "displayName": "Query Execution Id", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The unique ID identifying the query execution." }, - "queryString": { "index": 12, "kind": "property", "displayName": "Query String", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The SQL query to run. Except for simple queries, prefer setting this as the body of the Exchange or as a header using Athena2Constants.QUERY_STRING to avoid having to deal with URL encoding issues." }, - "region": { "index": 13, "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "ap-south-2", "ap-south-1", "eu-south-1", "eu-south-2", "us-gov-east-1", "me-central-1", "il-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "eu-central-2", "eu-isoe-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "ca-west-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "ap-southeast-4", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The region in which Athena client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1)." }, - "resetWaitTimeoutOnRetry": { "index": 14, "kind": "property", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "retry": { "index": 15, "kind": "property", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list of error types to retry the query for. Use: 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "waitTimeout": { "index": 16, "kind": "property", "displayName": "Wait Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "workGroup": { "index": 17, "kind": "property", "displayName": "Work Group", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." }, - "amazonAthenaClient": { "index": 18, "kind": "property", "displayName": "Amazon Athena Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.athena.AthenaClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The AmazonAthena instance to use as the client." }, - "autowiredEnabled": { "index": 19, "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." }, - "clientRequestToken": { "index": 20, "kind": "property", "displayName": "Client Request Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this." }, - "includeTrace": { "index": 21, "kind": "property", "displayName": "Include Trace", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Include useful trace information at the beginning of queries as an SQL comment (prefixed with --)." }, - "healthCheckConsumerEnabled": { "index": 22, "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": 23, "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." }, - "proxyHost": { "index": 24, "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Athena client." }, - "proxyPort": { "index": 25, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Athena client." }, - "proxyProtocol": { "index": 26, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Athena client." }, - "accessKey": { "index": 27, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key." }, - "encryptionOption": { "index": 28, "kind": "property", "displayName": "Encryption Option", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.services.athena.model.EncryptionOption", "enum": [ "SSE_S3", "SSE_KMS", "CSE_KMS", "null" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The encryption type to use when storing query results in S3. One of SSE_S3, SSE_KMS, or CSE_KMS." }, - "kmsKey": { "index": 29, "kind": "property", "displayName": "Kms Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "For SSE-KMS and CSE-KMS, this is the KMS key ARN or ID." }, - "profileCredentialsName": { "index": 30, "kind": "property", "displayName": "Profile Credentials Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider, this parameter will set the profile name" }, - "secretKey": { "index": 31, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." }, - "sessionToken": { "index": 32, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, - "useDefaultCredentialsProvider": { "index": 33, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in" }, - "useProfileCredentialsProvider": { "index": 34, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a profile credentials provider." }, - "useSessionCredentials": { "index": 35, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Athena." } + "overrideEndpoint": { "index": 11, "kind": "property", "displayName": "Override Endpoint", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used in combination with the uriEndpointOverride option" }, + "queryExecutionId": { "index": 12, "kind": "property", "displayName": "Query Execution Id", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The unique ID identifying the query execution." }, + "queryString": { "index": 13, "kind": "property", "displayName": "Query String", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The SQL query to run. Except for simple queries, prefer setting this as the body of the Exchange or as a header using Athena2Constants.QUERY_STRING to avoid having to deal with URL encoding issues." }, + "region": { "index": 14, "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "ap-south-2", "ap-south-1", "eu-south-1", "eu-south-2", "us-gov-east-1", "me-central-1", "il-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "eu-central-2", "eu-isoe-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "ca-west-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "ap-southeast-4", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The region in which Athena client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1)." }, + "resetWaitTimeoutOnRetry": { "index": 15, "kind": "property", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "retry": { "index": 16, "kind": "property", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list of error types to retry the query for. Use: 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "uriEndpointOverride": { "index": 17, "kind": "property", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option" }, + "waitTimeout": { "index": 18, "kind": "property", "displayName": "Wait Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "workGroup": { "index": 19, "kind": "property", "displayName": "Work Group", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." }, + "amazonAthenaClient": { "index": 20, "kind": "property", "displayName": "Amazon Athena Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.athena.AthenaClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The AmazonAthena instance to use as the client." }, + "autowiredEnabled": { "index": 21, "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." }, + "clientRequestToken": { "index": 22, "kind": "property", "displayName": "Client Request Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this." }, + "includeTrace": { "index": 23, "kind": "property", "displayName": "Include Trace", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Include useful trace information at the beginning of queries as an SQL comment (prefixed with --)." }, + "healthCheckConsumerEnabled": { "index": 24, "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": 25, "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." }, + "proxyHost": { "index": 26, "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Athena client." }, + "proxyPort": { "index": 27, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Athena client." }, + "proxyProtocol": { "index": 28, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Athena client." }, + "accessKey": { "index": 29, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key." }, + "encryptionOption": { "index": 30, "kind": "property", "displayName": "Encryption Option", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.services.athena.model.EncryptionOption", "enum": [ "SSE_S3", "SSE_KMS", "CSE_KMS", "null" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The encryption type to use when storing query results in S3. One of SSE_S3, SSE_KMS, or CSE_KMS." }, + "kmsKey": { "index": 31, "kind": "property", "displayName": "Kms Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "For SSE-KMS and CSE-KMS, this is the KMS key ARN or ID." }, + "profileCredentialsName": { "index": 32, "kind": "property", "displayName": "Profile Credentials Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider, this parameter will set the profile name" }, + "secretKey": { "index": 33, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." }, + "sessionToken": { "index": 34, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, + "trustAllCertificates": { "index": 35, "kind": "property", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, + "useDefaultCredentialsProvider": { "index": 36, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in" }, + "useProfileCredentialsProvider": { "index": 37, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a profile credentials provider." }, + "useSessionCredentials": { "index": 38, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Athena." } }, "headers": { "CamelAwsAthenaOperation": { "index": 0, "kind": "header", "displayName": "", "group": "all", "label": "all", "required": false, "javaType": "org.apache.camel.component.aws2.athena.Athena2Operations", "enum": [ "getQueryExecution", "getQueryResults", "listQueryExecutions", "startQueryExecution" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "startQueryExecution", "description": "The operation to perform. Permitted values are getQueryExecution, getQueryResults, listQueryExecutions, startQueryExecution.", "constantName": "org.apache.camel.component.aws2.athena.Athena2Constants#OPERATION" }, @@ -96,28 +99,31 @@ "operation": { "index": 7, "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.aws2.athena.Athena2Operations", "enum": [ "getQueryExecution", "getQueryResults", "listQueryExecutions", "startQueryExecution" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "startQueryExecution", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The Athena API function to call." }, "outputLocation": { "index": 8, "kind": "parameter", "displayName": "Output Location", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The location in Amazon S3 where query results are stored, such as s3:\/\/path\/to\/query\/bucket\/. Ensure this value ends with a forward slash." }, "outputType": { "index": 9, "kind": "parameter", "displayName": "Output Type", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.aws2.athena.Athena2OutputType", "enum": [ "StreamList", "SelectList", "S3Pointer" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "StreamList", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "How query results should be returned. One of StreamList (default - return a GetQueryResultsIterable that can page through all results), SelectList (returns at most 1000 rows at a time, plus a NextToken value as a header than can be used for manual pagination of results), S3Pointer (return an S3 path pointing to the results)." }, - "queryExecutionId": { "index": 10, "kind": "parameter", "displayName": "Query Execution Id", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The unique ID identifying the query execution." }, - "queryString": { "index": 11, "kind": "parameter", "displayName": "Query String", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The SQL query to run. Except for simple queries, prefer setting this as the body of the Exchange or as a header using Athena2Constants.QUERY_STRING to avoid having to deal with URL encoding issues." }, - "region": { "index": 12, "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "ap-south-2", "ap-south-1", "eu-south-1", "eu-south-2", "us-gov-east-1", "me-central-1", "il-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "eu-central-2", "eu-isoe-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "ca-west-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "ap-southeast-4", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The region in which Athena client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1)." }, - "resetWaitTimeoutOnRetry": { "index": 13, "kind": "parameter", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "retry": { "index": 14, "kind": "parameter", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list of error types to retry the query for. Use: 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "waitTimeout": { "index": 15, "kind": "parameter", "displayName": "Wait Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, - "workGroup": { "index": 16, "kind": "parameter", "displayName": "Work Group", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." }, - "lazyStartProducer": { "index": 17, "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." }, - "amazonAthenaClient": { "index": 18, "kind": "parameter", "displayName": "Amazon Athena Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.athena.AthenaClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The AmazonAthena instance to use as the client." }, - "clientRequestToken": { "index": 19, "kind": "parameter", "displayName": "Client Request Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this." }, - "includeTrace": { "index": 20, "kind": "parameter", "displayName": "Include Trace", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Include useful trace information at the beginning of queries as an SQL comment (prefixed with --)." }, - "proxyHost": { "index": 21, "kind": "parameter", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Athena client." }, - "proxyPort": { "index": 22, "kind": "parameter", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Athena client." }, - "proxyProtocol": { "index": 23, "kind": "parameter", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Athena client." }, - "accessKey": { "index": 24, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key." }, - "encryptionOption": { "index": 25, "kind": "parameter", "displayName": "Encryption Option", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.services.athena.model.EncryptionOption", "enum": [ "SSE_S3", "SSE_KMS", "CSE_KMS", "null" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The encryption type to use when storing query results in S3. One of SSE_S3, SSE_KMS, or CSE_KMS." }, - "kmsKey": { "index": 26, "kind": "parameter", "displayName": "Kms Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "For SSE-KMS and CSE-KMS, this is the KMS key ARN or ID." }, - "profileCredentialsName": { "index": 27, "kind": "parameter", "displayName": "Profile Credentials Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider, this parameter will set the profile name" }, - "secretKey": { "index": 28, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." }, - "sessionToken": { "index": 29, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, - "useDefaultCredentialsProvider": { "index": 30, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in" }, - "useProfileCredentialsProvider": { "index": 31, "kind": "parameter", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a profile credentials provider." }, - "useSessionCredentials": { "index": 32, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Athena." } + "overrideEndpoint": { "index": 10, "kind": "parameter", "displayName": "Override Endpoint", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used in combination with the uriEndpointOverride option" }, + "queryExecutionId": { "index": 11, "kind": "parameter", "displayName": "Query Execution Id", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The unique ID identifying the query execution." }, + "queryString": { "index": 12, "kind": "parameter", "displayName": "Query String", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The SQL query to run. Except for simple queries, prefer setting this as the body of the Exchange or as a header using Athena2Constants.QUERY_STRING to avoid having to deal with URL encoding issues." }, + "region": { "index": 13, "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "ap-south-2", "ap-south-1", "eu-south-1", "eu-south-2", "us-gov-east-1", "me-central-1", "il-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "eu-central-2", "eu-isoe-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "ca-west-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "ap-southeast-4", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The region in which Athena client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1)." }, + "resetWaitTimeoutOnRetry": { "index": 14, "kind": "parameter", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "retry": { "index": 15, "kind": "parameter", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list of error types to retry the query for. Use: 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "uriEndpointOverride": { "index": 16, "kind": "parameter", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option" }, + "waitTimeout": { "index": 17, "kind": "parameter", "displayName": "Wait Timeout", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section Waiting for Query Completion and Retrying Failed Queries to learn more." }, + "workGroup": { "index": 18, "kind": "parameter", "displayName": "Work Group", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." }, + "lazyStartProducer": { "index": 19, "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." }, + "amazonAthenaClient": { "index": 20, "kind": "parameter", "displayName": "Amazon Athena Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.athena.AthenaClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The AmazonAthena instance to use as the client." }, + "clientRequestToken": { "index": 21, "kind": "parameter", "displayName": "Client Request Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this." }, + "includeTrace": { "index": 22, "kind": "parameter", "displayName": "Include Trace", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Include useful trace information at the beginning of queries as an SQL comment (prefixed with --)." }, + "proxyHost": { "index": 23, "kind": "parameter", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Athena client." }, + "proxyPort": { "index": 24, "kind": "parameter", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Athena client." }, + "proxyProtocol": { "index": 25, "kind": "parameter", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Athena client." }, + "accessKey": { "index": 26, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key." }, + "encryptionOption": { "index": 27, "kind": "parameter", "displayName": "Encryption Option", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.services.athena.model.EncryptionOption", "enum": [ "SSE_S3", "SSE_KMS", "CSE_KMS", "null" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The encryption type to use when storing query results in S3. One of SSE_S3, SSE_KMS, or CSE_KMS." }, + "kmsKey": { "index": 28, "kind": "parameter", "displayName": "Kms Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "For SSE-KMS and CSE-KMS, this is the KMS key ARN or ID." }, + "profileCredentialsName": { "index": 29, "kind": "parameter", "displayName": "Profile Credentials Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider, this parameter will set the profile name" }, + "secretKey": { "index": 30, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." }, + "sessionToken": { "index": 31, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, + "trustAllCertificates": { "index": 32, "kind": "parameter", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, + "useDefaultCredentialsProvider": { "index": 33, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in" }, + "useProfileCredentialsProvider": { "index": 34, "kind": "parameter", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials through a profile credentials provider." }, + "useSessionCredentials": { "index": 35, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Athena." } } } diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java index 533fd58e924e3..8115c89fccea3 100644 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java +++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.athena; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -27,7 +28,7 @@ import software.amazon.awssdk.services.athena.paginators.GetQueryResultsIterable; @UriParams -public class Athena2Configuration implements Cloneable { +public class Athena2Configuration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) @@ -135,6 +136,13 @@ public class Athena2Configuration implements Cloneable { @UriParam(label = "security") private String profileCredentialsName; + @UriParam(label = "security") + private boolean trustAllCertificates; + @UriParam + private boolean overrideEndpoint; + @UriParam + private String uriEndpointOverride; + public String getAccessKey() { return accessKey; } @@ -458,7 +466,7 @@ public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvid this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } @@ -496,6 +504,40 @@ public void setProfileCredentialsName(String profileCredentialsName) { this.profileCredentialsName = profileCredentialsName; } + public boolean isTrustAllCertificates() { + return trustAllCertificates; + } + + /** + * If we want to trust all certificates in case of overriding the endpoint + */ + public void setTrustAllCertificates(boolean trustAllCertificates) { + this.trustAllCertificates = trustAllCertificates; + } + + public boolean isOverrideEndpoint() { + return overrideEndpoint; + } + + /** + * Set the need for overriding the endpoint. This option needs to be used in combination with the + * uriEndpointOverride option + */ + public void setOverrideEndpoint(boolean overrideEndpoint) { + this.overrideEndpoint = overrideEndpoint; + } + + public String getUriEndpointOverride() { + return uriEndpointOverride; + } + + /** + * Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option + */ + public void setUriEndpointOverride(String uriEndpointOverride) { + this.uriEndpointOverride = uriEndpointOverride; + } + // ************************************************* // // ************************************************* diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java index 7eaa695946f67..9b098e3316cb0 100644 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java +++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java @@ -69,7 +69,7 @@ public void doInit() throws Exception { athenaClient = configuration.getAmazonAthenaClient() != null ? configuration.getAmazonAthenaClient() - : Athena2ClientFactory.getAWSAthenaClient(configuration).getAthenaClient(); + : Athena2ClientFactory.getAthenaClient(configuration); } diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2ClientFactory.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2ClientFactory.java index 7e2a630838b20..86d88ebd94675 100644 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2ClientFactory.java +++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2ClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws2.athena.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.athena.Athena2Configuration; -import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientStandardImpl; +import software.amazon.awssdk.services.athena.AthenaClient; /** - * Factory class to return the correct type of AWS Athena client. + * Factory class to create AWS Athena clients using common configuration. */ public final class Athena2ClientFactory { @@ -31,20 +29,14 @@ private Athena2ClientFactory() { } /** - * Return the correct AWS Athena client (based on remote vs local). + * Create an Athena client based on configuration. * - * @param configuration configuration - * @return AthenaClient + * @param configuration The Athena configuration + * @return Configured AthenaClient */ - public static Athena2InternalClient getAWSAthenaClient(Athena2Configuration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new Athena2ClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new Athena2ClientIAMProfileOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new Athena2ClientSessionTokenImpl(configuration); - } else { - return new Athena2ClientStandardImpl(configuration); - } + public static AthenaClient getAthenaClient(Athena2Configuration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + AthenaClient::builder); } } diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2InternalClient.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2InternalClient.java deleted file mode 100644 index 7749d36eec2b5..0000000000000 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2InternalClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.aws2.athena.client; - -import software.amazon.awssdk.services.athena.AthenaClient; - -/** - * Manage the required actions of an Athena client for either local or remote. - */ -public interface Athena2InternalClient { - - /** - * Returns an Athena client after a factory method determines which one to return. - * - * @return AthenaClient AthenaClient - */ - AthenaClient getAthenaClient(); -} diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java deleted file mode 100644 index 416449111a268..0000000000000 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.aws2.athena.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.athena.Athena2Configuration; -import org.apache.camel.component.aws2.athena.client.Athena2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.athena.AthenaClient; -import software.amazon.awssdk.services.athena.AthenaClientBuilder; - -/** - * Manage an AWS Athena client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class Athena2ClientIAMOptimizedImpl implements Athena2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Athena2ClientIAMOptimizedImpl.class); - private Athena2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Athena2ClientIAMOptimizedImpl(Athena2Configuration configuration) { - LOG.trace("Creating an AWS Athena client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the s3 aws client that is used. - * - * @return Amazon S3 Client. - */ - @Override - public AthenaClient getAthenaClient() { - AthenaClient client = null; - AthenaClientBuilder clientBuilder = AthenaClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMProfileOptimizedImpl.java deleted file mode 100644 index 30eafd23d73df..0000000000000 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.aws2.athena.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.athena.Athena2Configuration; -import org.apache.camel.component.aws2.athena.client.Athena2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.services.athena.AthenaClient; -import software.amazon.awssdk.services.athena.AthenaClientBuilder; - -/** - * Manage an AWS Athena client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class Athena2ClientIAMProfileOptimizedImpl implements Athena2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Athena2ClientIAMProfileOptimizedImpl.class); - private Athena2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Athena2ClientIAMProfileOptimizedImpl(Athena2Configuration configuration) { - LOG.trace("Creating an AWS Athena manager using profile credentials."); - this.configuration = configuration; - } - - /** - * Getting the Lambda aws client that is used. - * - * @return Amazon Lambda Client. - */ - @Override - public AthenaClient getAthenaClient() { - AthenaClient client = null; - AthenaClientBuilder clientBuilder = AthenaClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientSessionTokenImpl.java deleted file mode 100644 index 71e3a0cd37637..0000000000000 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientSessionTokenImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.aws2.athena.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.athena.Athena2Configuration; -import org.apache.camel.component.aws2.athena.client.Athena2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.athena.AthenaClient; -import software.amazon.awssdk.services.athena.AthenaClientBuilder; - -/** - * Manage an AWS Athena client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class Athena2ClientSessionTokenImpl implements Athena2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Athena2ClientSessionTokenImpl.class); - private Athena2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Athena2ClientSessionTokenImpl(Athena2Configuration configuration) { - LOG.trace("Creating an AWS Athena manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Athena AWS client that is used. - * - * @return Amazon Athena Client. - */ - @Override - public AthenaClient getAthenaClient() { - AthenaClient client = null; - AthenaClientBuilder clientBuilder = AthenaClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java deleted file mode 100644 index c27fa5d4ea686..0000000000000 --- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.aws2.athena.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.athena.Athena2Configuration; -import org.apache.camel.component.aws2.athena.client.Athena2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.athena.AthenaClient; -import software.amazon.awssdk.services.athena.AthenaClientBuilder; - -/** - * Manage an AWS Athena client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class Athena2ClientStandardImpl implements Athena2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Athena2ClientStandardImpl.class); - private Athena2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Athena2ClientStandardImpl(Athena2Configuration configuration) { - LOG.trace("Creating an AWS Athena manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Athena AWS client that is used. - * - * @return Amazon Athena Client. - */ - @Override - public AthenaClient getAthenaClient() { - AthenaClient client = null; - AthenaClientBuilder clientBuilder = AthenaClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-athena/src/test/java/org/apache/camel/component/aws2/athena/AthenaClientFactoryTest.java b/components/camel-aws/camel-aws2-athena/src/test/java/org/apache/camel/component/aws2/athena/AthenaClientFactoryTest.java deleted file mode 100644 index fce96eba344b7..0000000000000 --- a/components/camel-aws/camel-aws2-athena/src/test/java/org/apache/camel/component/aws2/athena/AthenaClientFactoryTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.aws2.athena; - -import org.apache.camel.component.aws2.athena.client.Athena2ClientFactory; -import org.apache.camel.component.aws2.athena.client.Athena2InternalClient; -import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class AthenaClientFactoryTest { - - @Test - public void getStandardAthenaClientDefault() { - Athena2Configuration athena2Configuration = new Athena2Configuration(); - Athena2InternalClient athenaClient = Athena2ClientFactory.getAWSAthenaClient(athena2Configuration); - assertTrue(athenaClient instanceof Athena2ClientStandardImpl); - } - - @Test - public void getStandardAthenaClient() { - Athena2Configuration athena2Configuration = new Athena2Configuration(); - athena2Configuration.setUseDefaultCredentialsProvider(false); - Athena2InternalClient athenaClient = Athena2ClientFactory.getAWSAthenaClient(athena2Configuration); - assertTrue(athenaClient instanceof Athena2ClientStandardImpl); - } - - @Test - public void getIAMOptimizedAthenaClient() { - Athena2Configuration athena2Configuration = new Athena2Configuration(); - athena2Configuration.setUseDefaultCredentialsProvider(true); - Athena2InternalClient athenaClient = Athena2ClientFactory.getAWSAthenaClient(athena2Configuration); - assertTrue(athenaClient instanceof Athena2ClientIAMOptimizedImpl); - } - - @Test - public void getSessionTokenAthenaClient() { - Athena2Configuration athena2Configuration = new Athena2Configuration(); - athena2Configuration.setUseSessionCredentials(true); - Athena2InternalClient athenaClient = Athena2ClientFactory.getAWSAthenaClient(athena2Configuration); - assertTrue(athenaClient instanceof Athena2ClientSessionTokenImpl); - } -} diff --git a/components/camel-aws/camel-aws2-cw/pom.xml b/components/camel-aws/camel-aws2-cw/pom.xml index 459353e67ae1b..8e7fa310687e8 100644 --- a/components/camel-aws/camel-aws2-cw/pom.xml +++ b/components/camel-aws/camel-aws2-cw/pom.xml @@ -40,6 +40,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + org.apache.camel camel-health diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java index 20847fcdc66e2..3ded82d5a9738 100644 --- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java +++ b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java @@ -19,6 +19,7 @@ import java.time.Instant; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -27,7 +28,7 @@ import software.amazon.awssdk.services.cloudwatch.CloudWatchClient; @UriParams -public class Cw2Configuration implements Cloneable { +public class Cw2Configuration implements Cloneable, AwsCommonConfiguration { @UriPath @Metadata(required = true) @@ -258,7 +259,7 @@ public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvid this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java index 21beb3aee477e..c02368e61c1cc 100644 --- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java +++ b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java @@ -67,7 +67,7 @@ public void doInit() throws Exception { super.doInit(); cloudWatchClient = configuration.getAmazonCwClient() != null - ? configuration.getAmazonCwClient() : Cw2ClientFactory.getCloudWatchClient(configuration).getCloudWatchClient(); + ? configuration.getAmazonCwClient() : Cw2ClientFactory.getCloudWatchClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/Cw2ClientFactory.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/Cw2ClientFactory.java index dff69031e27e9..1d21764b97775 100644 --- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/Cw2ClientFactory.java +++ b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/Cw2ClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws2.cw.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.cw.Cw2Configuration; -import org.apache.camel.component.aws2.cw.client.impl.Cw2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.cw.client.impl.Cw2ClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.cw.client.impl.Cw2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.cw.client.impl.Cw2ClientStandardImpl; +import software.amazon.awssdk.services.cloudwatch.CloudWatchClient; /** - * Factory class to return the correct type of AWS Cloud Watch client. + * Factory class to create AWS CloudWatch clients using common configuration. */ public final class Cw2ClientFactory { @@ -31,20 +29,14 @@ private Cw2ClientFactory() { } /** - * Return the correct AWS Cloud Watch client (based on remote vs local). + * Create a CloudWatch client based on configuration. * - * @param configuration configuration - * @return CloudWatchClient + * @param configuration The CloudWatch configuration + * @return Configured CloudWatchClient */ - public static Cw2InternalClient getCloudWatchClient(Cw2Configuration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new Cw2ClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new Cw2ClientIAMProfileOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new Cw2ClientSessionTokenImpl(configuration); - } else { - return new Cw2ClientStandardImpl(configuration); - } + public static CloudWatchClient getCloudWatchClient(Cw2Configuration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + CloudWatchClient::builder); } } diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/Cw2InternalClient.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/Cw2InternalClient.java deleted file mode 100644 index ea7af5cfbf14d..0000000000000 --- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/Cw2InternalClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.aws2.cw.client; - -import software.amazon.awssdk.services.cloudwatch.CloudWatchClient; - -/** - * Manage the required actions of an CloudWatch client for either local or remote. - */ -public interface Cw2InternalClient { - - /** - * Returns an CloudWatch client after a factory method determines which one to return. - * - * @return CloudWatchClient CloudWatchClient - */ - CloudWatchClient getCloudWatchClient(); -} diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientIAMOptimizedImpl.java deleted file mode 100644 index f53b78e8ed946..0000000000000 --- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientIAMOptimizedImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.aws2.cw.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.cw.Cw2Configuration; -import org.apache.camel.component.aws2.cw.client.Cw2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.cloudwatch.CloudWatchClient; -import software.amazon.awssdk.services.cloudwatch.CloudWatchClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS CloudWatch client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class Cw2ClientIAMOptimizedImpl implements Cw2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Cw2ClientIAMOptimizedImpl.class); - private Cw2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Cw2ClientIAMOptimizedImpl(Cw2Configuration configuration) { - LOG.trace("Creating an AWS CloudWatch client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Cloud watch aws client that is used. - * - * @return Cloud Watch Client. - */ - @Override - public CloudWatchClient getCloudWatchClient() { - CloudWatchClient client = null; - CloudWatchClientBuilder clientBuilder = CloudWatchClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientIAMProfileOptimizedImpl.java deleted file mode 100644 index 7462e35829ace..0000000000000 --- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.aws2.cw.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.cw.Cw2Configuration; -import org.apache.camel.component.aws2.cw.client.Cw2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.cloudwatch.CloudWatchClient; -import software.amazon.awssdk.services.cloudwatch.CloudWatchClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS CloudWatch client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class Cw2ClientIAMProfileOptimizedImpl implements Cw2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Cw2ClientIAMProfileOptimizedImpl.class); - private Cw2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Cw2ClientIAMProfileOptimizedImpl(Cw2Configuration configuration) { - LOG.trace("Creating an AWS CloudWatch client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Cloud watch aws client that is used. - * - * @return Cloud Watch Client. - */ - @Override - public CloudWatchClient getCloudWatchClient() { - CloudWatchClient client = null; - CloudWatchClientBuilder clientBuilder = CloudWatchClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientSessionTokenImpl.java deleted file mode 100644 index 2abf3e57f69c8..0000000000000 --- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientSessionTokenImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.aws2.cw.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.cw.Cw2Configuration; -import org.apache.camel.component.aws2.cw.client.Cw2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.cloudwatch.CloudWatchClient; -import software.amazon.awssdk.services.cloudwatch.CloudWatchClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Cloud Watch client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class Cw2ClientSessionTokenImpl implements Cw2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Cw2ClientStandardImpl.class); - private Cw2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Cw2ClientSessionTokenImpl(Cw2Configuration configuration) { - LOG.trace("Creating an AWS CloudWatch manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Cloud Watch AWS client that is used. - * - * @return Amazon Cloud Watch Client. - */ - @Override - public CloudWatchClient getCloudWatchClient() { - CloudWatchClient client = null; - CloudWatchClientBuilder clientBuilder = CloudWatchClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientStandardImpl.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientStandardImpl.java deleted file mode 100644 index 3b844f66ecaea..0000000000000 --- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/client/impl/Cw2ClientStandardImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.aws2.cw.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.cw.Cw2Configuration; -import org.apache.camel.component.aws2.cw.client.Cw2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.cloudwatch.CloudWatchClient; -import software.amazon.awssdk.services.cloudwatch.CloudWatchClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Cloud Watch client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class Cw2ClientStandardImpl implements Cw2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Cw2ClientStandardImpl.class); - private Cw2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Cw2ClientStandardImpl(Cw2Configuration configuration) { - LOG.trace("Creating an AWS CloudWatch manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Cloud Watch AWS client that is used. - * - * @return Amazon Cloud Watch Client. - */ - @Override - public CloudWatchClient getCloudWatchClient() { - CloudWatchClient client = null; - CloudWatchClientBuilder clientBuilder = CloudWatchClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientFactoryTest.java b/components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientFactoryTest.java deleted file mode 100644 index e70e8b602162e..0000000000000 --- a/components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientFactoryTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.aws2.cw; - -import org.apache.camel.component.aws2.cw.client.Cw2ClientFactory; -import org.apache.camel.component.aws2.cw.client.Cw2InternalClient; -import org.apache.camel.component.aws2.cw.client.impl.Cw2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.cw.client.impl.Cw2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.cw.client.impl.Cw2ClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class Cw2ClientFactoryTest { - - @Test - public void getStandardCWClientDefault() { - Cw2Configuration cw2Configuration = new Cw2Configuration(); - Cw2InternalClient cwClient = Cw2ClientFactory.getCloudWatchClient(cw2Configuration); - assertTrue(cwClient instanceof Cw2ClientStandardImpl); - } - - @Test - public void getStandardCWClient() { - Cw2Configuration cw2Configuration = new Cw2Configuration(); - cw2Configuration.setUseDefaultCredentialsProvider(false); - Cw2InternalClient cwClient = Cw2ClientFactory.getCloudWatchClient(cw2Configuration); - assertTrue(cwClient instanceof Cw2ClientStandardImpl); - } - - @Test - public void getIAMOptimizedCWClient() { - Cw2Configuration cw2Configuration = new Cw2Configuration(); - cw2Configuration.setUseDefaultCredentialsProvider(true); - Cw2InternalClient cwClient = Cw2ClientFactory.getCloudWatchClient(cw2Configuration); - assertTrue(cwClient instanceof Cw2ClientIAMOptimizedImpl); - } - - @Test - public void getSessionTokenCwClient() { - Cw2Configuration cw2Configuration = new Cw2Configuration(); - cw2Configuration.setUseSessionCredentials(true); - Cw2InternalClient cwClient = Cw2ClientFactory.getCloudWatchClient(cw2Configuration); - assertTrue(cwClient instanceof Cw2ClientSessionTokenImpl); - } -} diff --git a/components/camel-aws/camel-aws2-eventbridge/pom.xml b/components/camel-aws/camel-aws2-eventbridge/pom.xml index eda5881d27ab2..8a5159f877a45 100644 --- a/components/camel-aws/camel-aws2-eventbridge/pom.xml +++ b/components/camel-aws/camel-aws2-eventbridge/pom.xml @@ -40,6 +40,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + software.amazon.awssdk eventbridge diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConfiguration.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConfiguration.java index d952b7d9eb8bf..361c685b2cb51 100644 --- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConfiguration.java +++ b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.eventbridge; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -24,7 +25,7 @@ import software.amazon.awssdk.services.eventbridge.EventBridgeClient; @UriParams -public class EventbridgeConfiguration implements Cloneable { +public class EventbridgeConfiguration implements Cloneable, AwsCommonConfiguration { private String eventbusName = "default"; @UriParam @@ -243,7 +244,7 @@ public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvid this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeEndpoint.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeEndpoint.java index 83361947b7c06..af913a7ee8c93 100644 --- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeEndpoint.java +++ b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeEndpoint.java @@ -73,7 +73,7 @@ public void doStart() throws Exception { eventbridgeClient = configuration.getEventbridgeClient() != null ? configuration.getEventbridgeClient() - : EventbridgeClientFactory.getEventbridgeClient(configuration).getEventbridgeClient(); + : EventbridgeClientFactory.getEventbridgeClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/EventbridgeClientFactory.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/EventbridgeClientFactory.java index 332b960226476..53bda27f1b296 100644 --- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/EventbridgeClientFactory.java +++ b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/EventbridgeClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws2.eventbridge.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.eventbridge.EventbridgeConfiguration; -import org.apache.camel.component.aws2.eventbridge.client.impl.EventbridgeClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.eventbridge.client.impl.EventbridgeClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.eventbridge.client.impl.EventbridgeClientSessionTokenImpl; -import org.apache.camel.component.aws2.eventbridge.client.impl.EventbridgeClientStandardImpl; +import software.amazon.awssdk.services.eventbridge.EventBridgeClient; /** - * Factory class to return the correct type of AWS Eventbridge client. + * Factory class to create AWS EventBridge clients using common configuration. */ public final class EventbridgeClientFactory { @@ -31,20 +29,14 @@ private EventbridgeClientFactory() { } /** - * Return the correct AWS Eventbridge client (based on remote vs local). + * Create an EventBridge client based on configuration. * - * @param configuration configuration - * @return EventBridgeClient + * @param configuration The EventBridge configuration + * @return Configured EventBridgeClient */ - public static EventbridgeInternalClient getEventbridgeClient(EventbridgeConfiguration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new EventbridgeClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new EventbridgeClientIAMProfileOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new EventbridgeClientSessionTokenImpl(configuration); - } else { - return new EventbridgeClientStandardImpl(configuration); - } + public static EventBridgeClient getEventbridgeClient(EventbridgeConfiguration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + EventBridgeClient::builder); } } diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/EventbridgeInternalClient.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/EventbridgeInternalClient.java deleted file mode 100644 index 891fe2d2b93e3..0000000000000 --- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/EventbridgeInternalClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.aws2.eventbridge.client; - -import software.amazon.awssdk.services.eventbridge.EventBridgeClient; - -/** - * Manage the required actions of an Eventbridge client for either local or remote. - */ -public interface EventbridgeInternalClient { - - /** - * Returns an Eventbridge client after a factory method determines which one to return. - * - * @return EventBridgeClient EventBridgeClient - */ - EventBridgeClient getEventbridgeClient(); -} diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientIAMOptimizedImpl.java deleted file mode 100644 index da119ba3595a8..0000000000000 --- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientIAMOptimizedImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.aws2.eventbridge.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.eventbridge.EventbridgeConfiguration; -import org.apache.camel.component.aws2.eventbridge.client.EventbridgeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.eventbridge.EventBridgeClient; -import software.amazon.awssdk.services.eventbridge.EventBridgeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Eventbridge client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class EventbridgeClientIAMOptimizedImpl implements EventbridgeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(EventbridgeClientIAMOptimizedImpl.class); - private EventbridgeConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public EventbridgeClientIAMOptimizedImpl(EventbridgeConfiguration configuration) { - LOG.trace("Creating an AWS Eventbridge client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Eventbridge aws client that is used. - * - * @return Eventbridge Client. - */ - @Override - public EventBridgeClient getEventbridgeClient() { - EventBridgeClient client = null; - EventBridgeClientBuilder clientBuilder = EventBridgeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientIAMProfileOptimizedImpl.java deleted file mode 100644 index cbe02b2d10aa5..0000000000000 --- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.aws2.eventbridge.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.eventbridge.EventbridgeConfiguration; -import org.apache.camel.component.aws2.eventbridge.client.EventbridgeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.eventbridge.EventBridgeClient; -import software.amazon.awssdk.services.eventbridge.EventBridgeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Eventbridge client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class EventbridgeClientIAMProfileOptimizedImpl implements EventbridgeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(EventbridgeClientIAMProfileOptimizedImpl.class); - private EventbridgeConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public EventbridgeClientIAMProfileOptimizedImpl(EventbridgeConfiguration configuration) { - LOG.trace("Creating an AWS Eventbridge client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the Eventbridge aws client that is used. - * - * @return Eventbridge Client. - */ - @Override - public EventBridgeClient getEventbridgeClient() { - EventBridgeClient client = null; - EventBridgeClientBuilder clientBuilder = EventBridgeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientSessionTokenImpl.java deleted file mode 100644 index 493bd6c813056..0000000000000 --- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientSessionTokenImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.aws2.eventbridge.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.eventbridge.EventbridgeConfiguration; -import org.apache.camel.component.aws2.eventbridge.client.EventbridgeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.eventbridge.EventBridgeClient; -import software.amazon.awssdk.services.eventbridge.EventBridgeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS EKS client for all users to use. This implementation is for local instances to use a static and solid - * credential set. - */ -public class EventbridgeClientSessionTokenImpl implements EventbridgeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(EventbridgeClientSessionTokenImpl.class); - private EventbridgeConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public EventbridgeClientSessionTokenImpl(EventbridgeConfiguration configuration) { - LOG.trace("Creating an AWS Eventbridge manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Eventbridge AWS client that is used. - * - * @return Amazon Eventbridge Client. - */ - @Override - public EventBridgeClient getEventbridgeClient() { - EventBridgeClient client = null; - EventBridgeClientBuilder clientBuilder = EventBridgeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientStandardImpl.java b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientStandardImpl.java deleted file mode 100644 index d281e985786a5..0000000000000 --- a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/client/impl/EventbridgeClientStandardImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.aws2.eventbridge.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.eventbridge.EventbridgeConfiguration; -import org.apache.camel.component.aws2.eventbridge.client.EventbridgeInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.eventbridge.EventBridgeClient; -import software.amazon.awssdk.services.eventbridge.EventBridgeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS EKS client for all users to use. This implementation is for local instances to use a static and solid - * credential set. - */ -public class EventbridgeClientStandardImpl implements EventbridgeInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(EventbridgeClientStandardImpl.class); - private EventbridgeConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public EventbridgeClientStandardImpl(EventbridgeConfiguration configuration) { - LOG.trace("Creating an AWS Eventbridge manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Eventbridge AWS client that is used. - * - * @return Amazon Eventbridge Client. - */ - @Override - public EventBridgeClient getEventbridgeClient() { - EventBridgeClient client = null; - EventBridgeClientBuilder clientBuilder = EventBridgeClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientFactoryTest.java b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientFactoryTest.java deleted file mode 100644 index fc1aae731c7d9..0000000000000 --- a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeClientFactoryTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.aws2.eventbridge; - -import org.apache.camel.component.aws2.eventbridge.client.EventbridgeClientFactory; -import org.apache.camel.component.aws2.eventbridge.client.EventbridgeInternalClient; -import org.apache.camel.component.aws2.eventbridge.client.impl.EventbridgeClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.eventbridge.client.impl.EventbridgeClientSessionTokenImpl; -import org.apache.camel.component.aws2.eventbridge.client.impl.EventbridgeClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class EventbridgeClientFactoryTest { - - @Test - public void getStandardEventbridgeClientDefault() { - EventbridgeConfiguration eventbridgeConfiguration = new EventbridgeConfiguration(); - EventbridgeInternalClient eventbridgeClient = EventbridgeClientFactory.getEventbridgeClient(eventbridgeConfiguration); - assertTrue(eventbridgeClient instanceof EventbridgeClientStandardImpl); - } - - @Test - public void getStandardEventbridgeClient() { - EventbridgeConfiguration eventbridgeConfiguration = new EventbridgeConfiguration(); - eventbridgeConfiguration.setUseDefaultCredentialsProvider(false); - EventbridgeInternalClient eventbridgeClient = EventbridgeClientFactory.getEventbridgeClient(eventbridgeConfiguration); - assertTrue(eventbridgeClient instanceof EventbridgeClientStandardImpl); - } - - @Test - public void getIAMOptimizedEventbridgeClient() { - EventbridgeConfiguration eventbridgeConfiguration = new EventbridgeConfiguration(); - eventbridgeConfiguration.setUseDefaultCredentialsProvider(true); - EventbridgeInternalClient eventbridgeClient = EventbridgeClientFactory.getEventbridgeClient(eventbridgeConfiguration); - assertTrue(eventbridgeClient instanceof EventbridgeClientIAMOptimizedImpl); - } - - @Test - public void getSessionTokenEventbridgeClient() { - EventbridgeConfiguration eventbridgeConfiguration = new EventbridgeConfiguration(); - eventbridgeConfiguration.setUseSessionCredentials(true); - EventbridgeInternalClient eventbridgeClient = EventbridgeClientFactory.getEventbridgeClient(eventbridgeConfiguration); - assertTrue(eventbridgeClient instanceof EventbridgeClientSessionTokenImpl); - } -} diff --git a/components/camel-aws/camel-aws2-redshift/pom.xml b/components/camel-aws/camel-aws2-redshift/pom.xml index 72a6b011571cd..3ce2a0d30ec2a 100644 --- a/components/camel-aws/camel-aws2-redshift/pom.xml +++ b/components/camel-aws/camel-aws2-redshift/pom.xml @@ -43,6 +43,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + org.apache.camel camel-health diff --git a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2Configuration.java b/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2Configuration.java index ecc20e03d3e44..68f71475f2ff2 100644 --- a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2Configuration.java +++ b/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2Configuration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.redshift.data; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.redshiftdata.RedshiftDataClient; @UriParams -public class RedshiftData2Configuration implements Cloneable { +public class RedshiftData2Configuration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) @@ -221,7 +222,7 @@ public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvid this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2Endpoint.java b/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2Endpoint.java index fde580783b8a6..9adba536bed91 100644 --- a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2Endpoint.java +++ b/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2Endpoint.java @@ -70,7 +70,7 @@ public void doStart() throws Exception { super.doStart(); awsRedshiftDataClient = configuration.getAwsRedshiftDataClient() != null ? configuration.getAwsRedshiftDataClient() - : RedshiftData2ClientFactory.getRedshiftDataClient(configuration).getRedshiftDataClient(); + : RedshiftData2ClientFactory.getRedshiftDataClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/RedshiftData2ClientFactory.java b/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/RedshiftData2ClientFactory.java index 9b53ead1abb36..c020da9011a20 100644 --- a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/RedshiftData2ClientFactory.java +++ b/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/RedshiftData2ClientFactory.java @@ -16,13 +16,12 @@ */ package org.apache.camel.component.aws2.redshift.data.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.redshift.data.RedshiftData2Configuration; -import org.apache.camel.component.aws2.redshift.data.client.impl.RedshiftData2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.redshift.data.client.impl.RedshiftData2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.redshift.data.client.impl.RedshiftData2ClientStandardImpl; +import software.amazon.awssdk.services.redshiftdata.RedshiftDataClient; /** - * Factory class to return the correct type of AWS RedshiftData client. + * Factory class to create AWS RedshiftData clients using common configuration. */ public final class RedshiftData2ClientFactory { @@ -30,18 +29,14 @@ private RedshiftData2ClientFactory() { } /** - * Return the correct AWS RedshiftData client (based on remote vs local). + * Create a RedshiftData client based on configuration. * - * @param configuration configuration - * @return RedshiftDataClient + * @param configuration The RedshiftData configuration + * @return Configured RedshiftDataClient */ - public static RedshiftData2InternalClient getRedshiftDataClient(RedshiftData2Configuration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new RedshiftData2ClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new RedshiftData2ClientSessionTokenImpl(configuration); - } else { - return new RedshiftData2ClientStandardImpl(configuration); - } + public static RedshiftDataClient getRedshiftDataClient(RedshiftData2Configuration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + RedshiftDataClient::builder); } } diff --git a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/RedshiftData2InternalClient.java b/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/RedshiftData2InternalClient.java deleted file mode 100644 index bd56f0f85a09f..0000000000000 --- a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/RedshiftData2InternalClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.aws2.redshift.data.client; - -import software.amazon.awssdk.services.redshiftdata.RedshiftDataClient; - -/** - * Manage the required actions of an RedshiftData client for either local or remote. - */ -public interface RedshiftData2InternalClient { - - /** - * Returns an RedshiftData client after a factory method determines which one to return. - * - * @return RedshiftDataClient RedshiftDataClient - */ - RedshiftDataClient getRedshiftDataClient(); -} diff --git a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/impl/RedshiftData2ClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/impl/RedshiftData2ClientIAMOptimizedImpl.java deleted file mode 100644 index 0ca93b43865f9..0000000000000 --- a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/impl/RedshiftData2ClientIAMOptimizedImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.aws2.redshift.data.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.redshift.data.RedshiftData2Configuration; -import org.apache.camel.component.aws2.redshift.data.client.RedshiftData2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.redshiftdata.RedshiftDataClient; -import software.amazon.awssdk.services.redshiftdata.RedshiftDataClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS RedshiftData client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class RedshiftData2ClientIAMOptimizedImpl implements RedshiftData2InternalClient { - - private static final Logger LOG = LoggerFactory.getLogger(RedshiftData2ClientIAMOptimizedImpl.class); - private RedshiftData2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public RedshiftData2ClientIAMOptimizedImpl(RedshiftData2Configuration configuration) { - LOG.trace("Creating an AWS RedshiftData client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the RedshiftData aws client that is used. - * - * @return RedshiftData Client. - */ - @Override - public RedshiftDataClient getRedshiftDataClient() { - RedshiftDataClient client = null; - RedshiftDataClientBuilder clientBuilder = RedshiftDataClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/impl/RedshiftData2ClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/impl/RedshiftData2ClientSessionTokenImpl.java deleted file mode 100644 index 5b1407e9407a5..0000000000000 --- a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/impl/RedshiftData2ClientSessionTokenImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.aws2.redshift.data.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.redshift.data.RedshiftData2Configuration; -import org.apache.camel.component.aws2.redshift.data.client.RedshiftData2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.redshiftdata.RedshiftDataClient; -import software.amazon.awssdk.services.redshiftdata.RedshiftDataClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS RedshiftData client for all users to use. This implementation is for local instances to use a static - * and solid credential set. - */ -public class RedshiftData2ClientSessionTokenImpl implements RedshiftData2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(RedshiftData2ClientStandardImpl.class); - private RedshiftData2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public RedshiftData2ClientSessionTokenImpl(RedshiftData2Configuration configuration) { - LOG.trace("Creating an AWS RedshiftData manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the RedshiftData AWS client that is used. - * - * @return Amazon RedshiftData Client. - */ - @Override - public RedshiftDataClient getRedshiftDataClient() { - RedshiftDataClient client = null; - RedshiftDataClientBuilder clientBuilder = RedshiftDataClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/impl/RedshiftData2ClientStandardImpl.java b/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/impl/RedshiftData2ClientStandardImpl.java deleted file mode 100644 index d2fa05ab8cdf3..0000000000000 --- a/components/camel-aws/camel-aws2-redshift/src/main/java/org/apache/camel/component/aws2/redshift/data/client/impl/RedshiftData2ClientStandardImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.aws2.redshift.data.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.redshift.data.RedshiftData2Configuration; -import org.apache.camel.component.aws2.redshift.data.client.RedshiftData2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.redshiftdata.RedshiftDataClient; -import software.amazon.awssdk.services.redshiftdata.RedshiftDataClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS RedshiftData client for all users to use. This implementation is for local instances to use a static - * and solid credential set. - */ -public class RedshiftData2ClientStandardImpl implements RedshiftData2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(RedshiftData2ClientStandardImpl.class); - private RedshiftData2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public RedshiftData2ClientStandardImpl(RedshiftData2Configuration configuration) { - LOG.trace("Creating an AWS RedshiftData manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the RedshiftData AWS client that is used. - * - * @return Amazon RedshiftData Client. - */ - @Override - public RedshiftDataClient getRedshiftDataClient() { - RedshiftDataClient client = null; - RedshiftDataClientBuilder clientBuilder = RedshiftDataClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-redshift/src/test/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2ClientFactoryTest.java b/components/camel-aws/camel-aws2-redshift/src/test/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2ClientFactoryTest.java deleted file mode 100644 index 40c24cac23942..0000000000000 --- a/components/camel-aws/camel-aws2-redshift/src/test/java/org/apache/camel/component/aws2/redshift/data/RedshiftData2ClientFactoryTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.aws2.redshift.data; - -import org.apache.camel.component.aws2.redshift.data.client.RedshiftData2ClientFactory; -import org.apache.camel.component.aws2.redshift.data.client.RedshiftData2InternalClient; -import org.apache.camel.component.aws2.redshift.data.client.impl.RedshiftData2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.redshift.data.client.impl.RedshiftData2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.redshift.data.client.impl.RedshiftData2ClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class RedshiftData2ClientFactoryTest { - - @Test - public void getStandardRedshiftDataClientDefault() { - RedshiftData2Configuration redshiftData2Configuration = new RedshiftData2Configuration(); - RedshiftData2InternalClient redshiftDataClient - = RedshiftData2ClientFactory.getRedshiftDataClient(redshiftData2Configuration); - assertTrue(redshiftDataClient instanceof RedshiftData2ClientStandardImpl); - } - - @Test - public void getStandardRedshiftDataClient() { - RedshiftData2Configuration redshiftData2Configuration = new RedshiftData2Configuration(); - redshiftData2Configuration.setUseDefaultCredentialsProvider(false); - RedshiftData2InternalClient redshiftDataClient - = RedshiftData2ClientFactory.getRedshiftDataClient(redshiftData2Configuration); - assertTrue(redshiftDataClient instanceof RedshiftData2ClientStandardImpl); - } - - @Test - public void getIAMOptimizedRedshiftDataClient() { - RedshiftData2Configuration redshiftData2Configuration = new RedshiftData2Configuration(); - redshiftData2Configuration.setUseDefaultCredentialsProvider(true); - RedshiftData2InternalClient redshiftDataClient - = RedshiftData2ClientFactory.getRedshiftDataClient(redshiftData2Configuration); - assertTrue(redshiftDataClient instanceof RedshiftData2ClientIAMOptimizedImpl); - } - - @Test - public void getSessionTokenRedshiftDataClient() { - RedshiftData2Configuration redshiftData2Configuration = new RedshiftData2Configuration(); - redshiftData2Configuration.setUseSessionCredentials(true); - RedshiftData2InternalClient redshiftDataClient - = RedshiftData2ClientFactory.getRedshiftDataClient(redshiftData2Configuration); - assertTrue(redshiftDataClient instanceof RedshiftData2ClientSessionTokenImpl); - } -} diff --git a/components/camel-aws/camel-aws2-s3-vectors/pom.xml b/components/camel-aws/camel-aws2-s3-vectors/pom.xml index fe5bfdd8cc5d8..0dd34fcaacf49 100644 --- a/components/camel-aws/camel-aws2-s3-vectors/pom.xml +++ b/components/camel-aws/camel-aws2-s3-vectors/pom.xml @@ -40,6 +40,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + software.amazon.awssdk s3vectors diff --git a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsConfiguration.java b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsConfiguration.java index 9aee63486dcf5..44f809d1e5c4a 100644 --- a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsConfiguration.java +++ b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.s3vectors; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -24,7 +25,7 @@ import software.amazon.awssdk.services.s3vectors.S3VectorsClient; @UriParams -public class AWS2S3VectorsConfiguration implements Cloneable { +public class AWS2S3VectorsConfiguration implements Cloneable, AwsCommonConfiguration { private String vectorBucketName; @UriParam(label = "advanced") diff --git a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsEndpoint.java b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsEndpoint.java index 6f10dfd72d210..2928e42de8c14 100644 --- a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsEndpoint.java +++ b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsEndpoint.java @@ -104,7 +104,7 @@ public void doStart() throws Exception { s3VectorsClient = configuration.getS3VectorsClient() != null ? configuration.getS3VectorsClient() - : AWS2S3VectorsClientFactory.getS3VectorsClient(configuration).getS3VectorsClient(); + : AWS2S3VectorsClientFactory.getS3VectorsClient(configuration); LOG.trace("Using vector bucket [{}]", vectorBucketName); } diff --git a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/AWS2CamelS3VectorsInternalClient.java b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/AWS2CamelS3VectorsInternalClient.java deleted file mode 100644 index 8cb553f0fe161..0000000000000 --- a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/AWS2CamelS3VectorsInternalClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.aws2.s3vectors.client; - -import software.amazon.awssdk.services.s3vectors.S3VectorsClient; - -/** - * Manage the required actions of an S3 Vectors client for either local or remote. - */ -public interface AWS2CamelS3VectorsInternalClient { - - /** - * Returns an S3 Vectors client after a factory method determines which one to return. - * - * @return S3VectorsClient - */ - S3VectorsClient getS3VectorsClient(); -} diff --git a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/AWS2S3VectorsClientFactory.java b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/AWS2S3VectorsClientFactory.java index 94e88e6303f78..8431a3790e6a7 100644 --- a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/AWS2S3VectorsClientFactory.java +++ b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/AWS2S3VectorsClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws2.s3vectors.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConfiguration; -import org.apache.camel.component.aws2.s3vectors.client.impl.AWS2S3VectorsClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.s3vectors.client.impl.AWS2S3VectorsClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.s3vectors.client.impl.AWS2S3VectorsClientSessionTokenImpl; -import org.apache.camel.component.aws2.s3vectors.client.impl.AWS2S3VectorsClientStandardImpl; +import software.amazon.awssdk.services.s3vectors.S3VectorsClient; /** - * Factory class to return the correct type of AWS S3 Vectors client. + * Factory class to create AWS S3 Vectors clients using common configuration. */ public final class AWS2S3VectorsClientFactory { @@ -31,20 +29,14 @@ private AWS2S3VectorsClientFactory() { } /** - * Return the correct AWS S3 Vectors client (based on configuration). + * Create a S3VectorsClient based on configuration. * - * @param configuration configuration - * @return AWS2CamelS3VectorsInternalClient + * @param configuration The S3 Vectors configuration + * @return Configured S3VectorsClient */ - public static AWS2CamelS3VectorsInternalClient getS3VectorsClient(AWS2S3VectorsConfiguration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new AWS2S3VectorsClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new AWS2S3VectorsClientIAMProfileOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new AWS2S3VectorsClientSessionTokenImpl(configuration); - } else { - return new AWS2S3VectorsClientStandardImpl(configuration); - } + public static S3VectorsClient getS3VectorsClient(AWS2S3VectorsConfiguration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + S3VectorsClient::builder); } } diff --git a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientIAMOptimizedImpl.java deleted file mode 100644 index 712850a0064c8..0000000000000 --- a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientIAMOptimizedImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.aws2.s3vectors.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConfiguration; -import org.apache.camel.component.aws2.s3vectors.client.AWS2CamelS3VectorsInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.s3vectors.S3VectorsClient; -import software.amazon.awssdk.services.s3vectors.S3VectorsClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS S3 Vectors client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class AWS2S3VectorsClientIAMOptimizedImpl implements AWS2CamelS3VectorsInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(AWS2S3VectorsClientIAMOptimizedImpl.class); - private AWS2S3VectorsConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public AWS2S3VectorsClientIAMOptimizedImpl(AWS2S3VectorsConfiguration configuration) { - LOG.trace("Creating an AWS S3 Vectors client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the S3 Vectors AWS client that is used. - * - * @return S3 Vectors Client. - */ - @Override - public S3VectorsClient getS3VectorsClient() { - S3VectorsClient client = null; - S3VectorsClientBuilder clientBuilder = S3VectorsClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientIAMProfileOptimizedImpl.java deleted file mode 100644 index 730ef2f1e8605..0000000000000 --- a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.aws2.s3vectors.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConfiguration; -import org.apache.camel.component.aws2.s3vectors.client.AWS2CamelS3VectorsInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.s3vectors.S3VectorsClient; -import software.amazon.awssdk.services.s3vectors.S3VectorsClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS S3 Vectors client using profile credentials. - */ -public class AWS2S3VectorsClientIAMProfileOptimizedImpl implements AWS2CamelS3VectorsInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(AWS2S3VectorsClientIAMProfileOptimizedImpl.class); - private AWS2S3VectorsConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public AWS2S3VectorsClientIAMProfileOptimizedImpl(AWS2S3VectorsConfiguration configuration) { - LOG.trace("Creating an AWS S3 Vectors client using profile credentials."); - this.configuration = configuration; - } - - /** - * Getting the S3 Vectors AWS client that is used. - * - * @return S3 Vectors Client. - */ - @Override - public S3VectorsClient getS3VectorsClient() { - S3VectorsClient client = null; - S3VectorsClientBuilder clientBuilder = S3VectorsClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getProfileCredentialsName() != null) { - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } else { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - } else { - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(ProfileCredentialsProvider.create()); - } else { - clientBuilder = clientBuilder.credentialsProvider(ProfileCredentialsProvider.create()); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientSessionTokenImpl.java deleted file mode 100644 index 00baec3b93b97..0000000000000 --- a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientSessionTokenImpl.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.aws2.s3vectors.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConfiguration; -import org.apache.camel.component.aws2.s3vectors.client.AWS2CamelS3VectorsInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.s3vectors.S3VectorsClient; -import software.amazon.awssdk.services.s3vectors.S3VectorsClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS S3 Vectors client using session credentials. - */ -public class AWS2S3VectorsClientSessionTokenImpl implements AWS2CamelS3VectorsInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(AWS2S3VectorsClientSessionTokenImpl.class); - private AWS2S3VectorsConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public AWS2S3VectorsClientSessionTokenImpl(AWS2S3VectorsConfiguration configuration) { - LOG.trace("Creating an AWS S3 Vectors client using session credentials."); - this.configuration = configuration; - } - - /** - * Getting the S3 Vectors AWS client that is used. - * - * @return S3 Vectors Client. - */ - @Override - public S3VectorsClient getS3VectorsClient() { - S3VectorsClient client = null; - S3VectorsClientBuilder clientBuilder = S3VectorsClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientStandardImpl.java b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientStandardImpl.java deleted file mode 100644 index 09d3671eb0693..0000000000000 --- a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/client/impl/AWS2S3VectorsClientStandardImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.aws2.s3vectors.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConfiguration; -import org.apache.camel.component.aws2.s3vectors.client.AWS2CamelS3VectorsInternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.s3vectors.S3VectorsClient; -import software.amazon.awssdk.services.s3vectors.S3VectorsClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS S3 Vectors client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class AWS2S3VectorsClientStandardImpl implements AWS2CamelS3VectorsInternalClient { - private static final Logger LOG = LoggerFactory.getLogger(AWS2S3VectorsClientStandardImpl.class); - private AWS2S3VectorsConfiguration configuration; - - /** - * Constructor that uses the config file. - */ - public AWS2S3VectorsClientStandardImpl(AWS2S3VectorsConfiguration configuration) { - LOG.trace("Creating an AWS S3 Vectors client using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the S3 Vectors AWS client that is used. - * - * @return S3 Vectors Client. - */ - @Override - public S3VectorsClient getS3VectorsClient() { - S3VectorsClient client = null; - S3VectorsClientBuilder clientBuilder = S3VectorsClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-step-functions/pom.xml b/components/camel-aws/camel-aws2-step-functions/pom.xml index e57ec42a7c149..68472e20a6c20 100644 --- a/components/camel-aws/camel-aws2-step-functions/pom.xml +++ b/components/camel-aws/camel-aws2-step-functions/pom.xml @@ -41,6 +41,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + org.apache.camel camel-health diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Configuration.java b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Configuration.java index 6e3a22b911aa9..2be7205444dec 100644 --- a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Configuration.java +++ b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Configuration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.stepfunctions; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.sfn.SfnClient; @UriParams -public class StepFunctions2Configuration implements Cloneable { +public class StepFunctions2Configuration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) @@ -221,7 +222,7 @@ public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvid this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Endpoint.java b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Endpoint.java index 02fdfc0b564dc..ad39d0374caa9 100644 --- a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Endpoint.java +++ b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2Endpoint.java @@ -64,7 +64,7 @@ public void doStart() throws Exception { super.doStart(); awsSfnClient = configuration.getAwsSfnClient() != null ? configuration.getAwsSfnClient() - : StepFunctions2ClientFactory.getSfnClient(configuration).getSfnClient(); + : StepFunctions2ClientFactory.getSfnClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/StepFunctions2ClientFactory.java b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/StepFunctions2ClientFactory.java index 75614dbcf9805..90aec221d5ed6 100644 --- a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/StepFunctions2ClientFactory.java +++ b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/StepFunctions2ClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws2.stepfunctions.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.stepfunctions.StepFunctions2Configuration; -import org.apache.camel.component.aws2.stepfunctions.client.impl.StepFunctions2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.stepfunctions.client.impl.StepFunctions2ClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.stepfunctions.client.impl.StepFunctions2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.stepfunctions.client.impl.StepFunctions2ClientStandardImpl; +import software.amazon.awssdk.services.sfn.SfnClient; /** - * Factory class to return the correct type of AWS StepFunctions client. + * Factory class to create AWS StepFunctions clients using common configuration. */ public final class StepFunctions2ClientFactory { @@ -31,20 +29,14 @@ private StepFunctions2ClientFactory() { } /** - * Return the correct AWS StepFunctions client (based on remote vs local). + * Create a SfnClient based on configuration. * - * @param configuration configuration - * @return StepFunctionsClient + * @param configuration The StepFunctions configuration + * @return Configured SfnClient */ - public static StepFunctions2InternalClient getSfnClient(StepFunctions2Configuration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new StepFunctions2ClientIAMOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new StepFunctions2ClientIAMProfileOptimizedImpl(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new StepFunctions2ClientSessionTokenImpl(configuration); - } else { - return new StepFunctions2ClientStandardImpl(configuration); - } + public static SfnClient getSfnClient(StepFunctions2Configuration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + SfnClient::builder); } } diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/StepFunctions2InternalClient.java b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/StepFunctions2InternalClient.java deleted file mode 100644 index d582115e6d0e1..0000000000000 --- a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/StepFunctions2InternalClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.aws2.stepfunctions.client; - -import software.amazon.awssdk.services.sfn.SfnClient; - -/** - * Manage the required actions of an StepFunctions client for either local or remote. - */ -public interface StepFunctions2InternalClient { - - /** - * Returns an StepFunctions client after a factory method determines which one to return. - * - * @return SfnClient SfnClient - */ - SfnClient getSfnClient(); -} diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientIAMOptimizedImpl.java deleted file mode 100644 index a34c228fe6fba..0000000000000 --- a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientIAMOptimizedImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.aws2.stepfunctions.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.stepfunctions.StepFunctions2Configuration; -import org.apache.camel.component.aws2.stepfunctions.client.StepFunctions2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.sfn.SfnClient; -import software.amazon.awssdk.services.sfn.SfnClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS StepFunctions client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class StepFunctions2ClientIAMOptimizedImpl implements StepFunctions2InternalClient { - - private static final Logger LOG = LoggerFactory.getLogger(StepFunctions2ClientIAMOptimizedImpl.class); - private StepFunctions2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public StepFunctions2ClientIAMOptimizedImpl(StepFunctions2Configuration configuration) { - LOG.trace("Creating an AWS StepFunctions client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the StepFunctions aws client that is used. - * - * @return StepFunctions Client. - */ - @Override - public SfnClient getSfnClient() { - SfnClient client = null; - SfnClientBuilder clientBuilder = SfnClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientIAMProfileOptimizedImpl.java deleted file mode 100644 index f767871570bff..0000000000000 --- a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.aws2.stepfunctions.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.stepfunctions.StepFunctions2Configuration; -import org.apache.camel.component.aws2.stepfunctions.client.StepFunctions2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.sfn.SfnClient; -import software.amazon.awssdk.services.sfn.SfnClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS StepFunctions client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class StepFunctions2ClientIAMProfileOptimizedImpl implements StepFunctions2InternalClient { - - private static final Logger LOG = LoggerFactory.getLogger(StepFunctions2ClientIAMProfileOptimizedImpl.class); - private StepFunctions2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public StepFunctions2ClientIAMProfileOptimizedImpl(StepFunctions2Configuration configuration) { - LOG.trace("Creating an AWS StepFunctions client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the StepFunctions aws client that is used. - * - * @return StepFunctions Client. - */ - @Override - public SfnClient getSfnClient() { - SfnClient client = null; - SfnClientBuilder clientBuilder = SfnClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientSessionTokenImpl.java deleted file mode 100644 index 6dc44adda8055..0000000000000 --- a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientSessionTokenImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.aws2.stepfunctions.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.stepfunctions.StepFunctions2Configuration; -import org.apache.camel.component.aws2.stepfunctions.client.StepFunctions2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.sfn.SfnClient; -import software.amazon.awssdk.services.sfn.SfnClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS StepFunctions client for all users to use. This implementation is for local instances to use a static - * and solid credential set. - */ -public class StepFunctions2ClientSessionTokenImpl implements StepFunctions2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(StepFunctions2ClientSessionTokenImpl.class); - private StepFunctions2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public StepFunctions2ClientSessionTokenImpl(StepFunctions2Configuration configuration) { - LOG.trace("Creating an AWS StepFunctions manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the StepFunctions AWS client that is used. - * - * @return Amazon StepFunctions Client. - */ - @Override - public SfnClient getSfnClient() { - SfnClient client = null; - SfnClientBuilder clientBuilder = SfnClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientStandardImpl.java b/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientStandardImpl.java deleted file mode 100644 index cac8c713444c4..0000000000000 --- a/components/camel-aws/camel-aws2-step-functions/src/main/java/org/apache/camel/component/aws2/stepfunctions/client/impl/StepFunctions2ClientStandardImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.aws2.stepfunctions.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.stepfunctions.StepFunctions2Configuration; -import org.apache.camel.component.aws2.stepfunctions.client.StepFunctions2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.sfn.SfnClient; -import software.amazon.awssdk.services.sfn.SfnClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS StepFunctions client for all users to use. This implementation is for local instances to use a static - * and solid credential set. - */ -public class StepFunctions2ClientStandardImpl implements StepFunctions2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(StepFunctions2ClientStandardImpl.class); - private StepFunctions2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public StepFunctions2ClientStandardImpl(StepFunctions2Configuration configuration) { - LOG.trace("Creating an AWS StepFunctions manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the StepFunctions AWS client that is used. - * - * @return Amazon StepFunctions Client. - */ - @Override - public SfnClient getSfnClient() { - SfnClient client = null; - SfnClientBuilder clientBuilder = SfnClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2ClientFactoryTest.java b/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2ClientFactoryTest.java deleted file mode 100644 index d409cc746748e..0000000000000 --- a/components/camel-aws/camel-aws2-step-functions/src/test/java/org/apache/camel/component/aws2/stepfunctions/StepFunctions2ClientFactoryTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.aws2.stepfunctions; - -import org.apache.camel.component.aws2.stepfunctions.client.StepFunctions2ClientFactory; -import org.apache.camel.component.aws2.stepfunctions.client.StepFunctions2InternalClient; -import org.apache.camel.component.aws2.stepfunctions.client.impl.StepFunctions2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.stepfunctions.client.impl.StepFunctions2ClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.stepfunctions.client.impl.StepFunctions2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.stepfunctions.client.impl.StepFunctions2ClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class StepFunctions2ClientFactoryTest { - - @Test - public void getStandardSfnClientDefault() { - StepFunctions2Configuration sfn2Configuration = new StepFunctions2Configuration(); - StepFunctions2InternalClient sfnClient = StepFunctions2ClientFactory.getSfnClient(sfn2Configuration); - assertTrue(sfnClient instanceof StepFunctions2ClientStandardImpl); - } - - @Test - public void getStandardSfnClient() { - StepFunctions2Configuration sfn2Configuration = new StepFunctions2Configuration(); - sfn2Configuration.setUseDefaultCredentialsProvider(false); - StepFunctions2InternalClient sfnClient = StepFunctions2ClientFactory.getSfnClient(sfn2Configuration); - assertTrue(sfnClient instanceof StepFunctions2ClientStandardImpl); - } - - @Test - public void getIAMOptimizedSfnClient() { - StepFunctions2Configuration sfn2Configuration = new StepFunctions2Configuration(); - sfn2Configuration.setUseDefaultCredentialsProvider(true); - StepFunctions2InternalClient sfnClient = StepFunctions2ClientFactory.getSfnClient(sfn2Configuration); - assertTrue(sfnClient instanceof StepFunctions2ClientIAMOptimizedImpl); - } - - @Test - public void getIAMProfileOptimizedSfnClient() { - StepFunctions2Configuration sfn2Configuration = new StepFunctions2Configuration(); - sfn2Configuration.setUseProfileCredentialsProvider(true); - StepFunctions2InternalClient sfnClient = StepFunctions2ClientFactory.getSfnClient(sfn2Configuration); - assertTrue(sfnClient instanceof StepFunctions2ClientIAMProfileOptimizedImpl); - } - - @Test - public void getSessionTokenSfnClient() { - StepFunctions2Configuration sfn2Configuration = new StepFunctions2Configuration(); - sfn2Configuration.setUseSessionCredentials(true); - StepFunctions2InternalClient sfnClient = StepFunctions2ClientFactory.getSfnClient(sfn2Configuration); - assertTrue(sfnClient instanceof StepFunctions2ClientSessionTokenImpl); - } -} diff --git a/components/camel-aws/camel-aws2-textract/pom.xml b/components/camel-aws/camel-aws2-textract/pom.xml index 4eb6268622f10..09125bc1aa375 100644 --- a/components/camel-aws/camel-aws2-textract/pom.xml +++ b/components/camel-aws/camel-aws2-textract/pom.xml @@ -40,6 +40,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + software.amazon.awssdk textract diff --git a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/Textract2Configuration.java b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/Textract2Configuration.java index f6ccb29221d4d..8abc6e3d7c214 100644 --- a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/Textract2Configuration.java +++ b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/Textract2Configuration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.textract; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.textract.TextractClient; @UriParams -public class Textract2Configuration implements Cloneable { +public class Textract2Configuration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) diff --git a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/Textract2Endpoint.java b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/Textract2Endpoint.java index 1c3bab7ab0f8f..3ffb0e8b0759e 100644 --- a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/Textract2Endpoint.java +++ b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/Textract2Endpoint.java @@ -68,7 +68,7 @@ public void doStart() throws Exception { textractClient = configuration.getTextractClient() != null ? configuration.getTextractClient() - : Textract2ClientFactory.getTextractClient(configuration).getTextractClient(); + : Textract2ClientFactory.getTextractClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/Textract2ClientFactory.java b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/Textract2ClientFactory.java index 802c9a1930aff..bbab4275fc160 100644 --- a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/Textract2ClientFactory.java +++ b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/Textract2ClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws2.textract.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.textract.Textract2Configuration; -import org.apache.camel.component.aws2.textract.client.impl.Textract2ClientIAMOptimized; -import org.apache.camel.component.aws2.textract.client.impl.Textract2ClientIAMProfileOptimized; -import org.apache.camel.component.aws2.textract.client.impl.Textract2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.textract.client.impl.Textract2ClientStandardImpl; +import software.amazon.awssdk.services.textract.TextractClient; /** - * Factory class to return the correct type of AWS Textract client. + * Factory class to create AWS Textract clients using common configuration. */ public final class Textract2ClientFactory { @@ -31,20 +29,14 @@ private Textract2ClientFactory() { } /** - * Return the correct aws Textract client (based on remote vs local). + * Create a TextractClient based on configuration. * - * @param configuration configuration - * @return TextractClient + * @param configuration The Textract configuration + * @return Configured TextractClient */ - public static Textract2InternalClient getTextractClient(Textract2Configuration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new Textract2ClientIAMOptimized(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new Textract2ClientIAMProfileOptimized(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new Textract2ClientSessionTokenImpl(configuration); - } else { - return new Textract2ClientStandardImpl(configuration); - } + public static TextractClient getTextractClient(Textract2Configuration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + TextractClient::builder); } } diff --git a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/Textract2InternalClient.java b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/Textract2InternalClient.java deleted file mode 100644 index 542334e5a9676..0000000000000 --- a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/Textract2InternalClient.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.aws2.textract.client; - -import software.amazon.awssdk.services.textract.TextractClient; - -public interface Textract2InternalClient { - - /** - * Returns a Textract client after a factory method determines which one to return. - * - * @return TextractClient textractClient - */ - TextractClient getTextractClient(); - -} diff --git a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientIAMOptimized.java b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientIAMOptimized.java deleted file mode 100644 index 993a9c4e3c3f1..0000000000000 --- a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientIAMOptimized.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.aws2.textract.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.textract.Textract2Configuration; -import org.apache.camel.component.aws2.textract.client.Textract2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.textract.TextractClient; -import software.amazon.awssdk.services.textract.TextractClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Textract client for all users to use. This implementation is for remote instances to manage the - * credentials on their own (eliminating credential rotations) - */ -public class Textract2ClientIAMOptimized implements Textract2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Textract2ClientIAMOptimized.class); - private Textract2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Textract2ClientIAMOptimized(Textract2Configuration configuration) { - LOG.trace("Creating an AWS Textract client for working on AWS Services"); - this.configuration = configuration; - } - - /** - * Getting the Textract aws client that is used. - * - * @return Amazon Textract Client. - */ - @Override - public TextractClient getTextractClient() { - TextractClient client = null; - TextractClientBuilder clientBuilder = TextractClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientIAMProfileOptimized.java b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientIAMProfileOptimized.java deleted file mode 100644 index 2fda5e334fecf..0000000000000 --- a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientIAMProfileOptimized.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.aws2.textract.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.textract.Textract2Configuration; -import org.apache.camel.component.aws2.textract.client.Textract2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.textract.TextractClient; -import software.amazon.awssdk.services.textract.TextractClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Textract client for all users to use. This implementation is for remote instances to manage the - * credentials on their own (eliminating credential rotations) - */ -public class Textract2ClientIAMProfileOptimized implements Textract2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Textract2ClientIAMProfileOptimized.class); - private Textract2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Textract2ClientIAMProfileOptimized(Textract2Configuration configuration) { - LOG.trace("Creating an AWS Textract client for working on AWS Services"); - this.configuration = configuration; - } - - /** - * Getting the Textract aws client that is used. - * - * @return Amazon Textract Client. - */ - @Override - public TextractClient getTextractClient() { - TextractClient client = null; - TextractClientBuilder clientBuilder = TextractClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientSessionTokenImpl.java deleted file mode 100644 index 40f49927cc0dd..0000000000000 --- a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientSessionTokenImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.aws2.textract.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.textract.Textract2Configuration; -import org.apache.camel.component.aws2.textract.client.Textract2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.textract.TextractClient; -import software.amazon.awssdk.services.textract.TextractClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Textract client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class Textract2ClientSessionTokenImpl implements Textract2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Textract2ClientSessionTokenImpl.class); - private Textract2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Textract2ClientSessionTokenImpl(Textract2Configuration configuration) { - LOG.trace("Creating an AWS Textract manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Textract aws client that is used. - * - * @return Amazon Textract Client. - */ - @Override - public TextractClient getTextractClient() { - TextractClient client = null; - TextractClientBuilder clientBuilder = TextractClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientStandardImpl.java b/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientStandardImpl.java deleted file mode 100644 index 3cac3b0116c37..0000000000000 --- a/components/camel-aws/camel-aws2-textract/src/main/java/org/apache/camel/component/aws2/textract/client/impl/Textract2ClientStandardImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.aws2.textract.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.textract.Textract2Configuration; -import org.apache.camel.component.aws2.textract.client.Textract2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.textract.TextractClient; -import software.amazon.awssdk.services.textract.TextractClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Textract client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class Textract2ClientStandardImpl implements Textract2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Textract2ClientStandardImpl.class); - private Textract2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Textract2ClientStandardImpl(Textract2Configuration configuration) { - LOG.trace("Creating an AWS Textract manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Textract aws client that is used. - * - * @return Amazon Textract Client. - */ - @Override - public TextractClient getTextractClient() { - TextractClient client = null; - TextractClientBuilder clientBuilder = TextractClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-textract/src/test/java/org/apache/camel/component/aws2/textract/Textract2ClientFactoryTest.java b/components/camel-aws/camel-aws2-textract/src/test/java/org/apache/camel/component/aws2/textract/Textract2ClientFactoryTest.java deleted file mode 100644 index 29e9314c6ab4f..0000000000000 --- a/components/camel-aws/camel-aws2-textract/src/test/java/org/apache/camel/component/aws2/textract/Textract2ClientFactoryTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.aws2.textract; - -import org.apache.camel.component.aws2.textract.client.Textract2ClientFactory; -import org.apache.camel.component.aws2.textract.client.Textract2InternalClient; -import org.apache.camel.component.aws2.textract.client.impl.Textract2ClientIAMOptimized; -import org.apache.camel.component.aws2.textract.client.impl.Textract2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.textract.client.impl.Textract2ClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class Textract2ClientFactoryTest { - - @Test - public void getStandardTextractClientDefault() { - Textract2Configuration textract2Configuration = new Textract2Configuration(); - Textract2InternalClient textractClient = Textract2ClientFactory.getTextractClient(textract2Configuration); - assertTrue(textractClient instanceof Textract2ClientStandardImpl); - } - - @Test - public void getStandardTextractClient() { - Textract2Configuration textract2Configuration = new Textract2Configuration(); - textract2Configuration.setUseDefaultCredentialsProvider(false); - Textract2InternalClient textractClient = Textract2ClientFactory.getTextractClient(textract2Configuration); - assertTrue(textractClient instanceof Textract2ClientStandardImpl); - } - - @Test - public void getTextractOptimizedIAMClient() { - Textract2Configuration textract2Configuration = new Textract2Configuration(); - textract2Configuration.setUseDefaultCredentialsProvider(true); - Textract2InternalClient textractClient = Textract2ClientFactory.getTextractClient(textract2Configuration); - assertTrue(textractClient instanceof Textract2ClientIAMOptimized); - } - - @Test - public void getTextractSessionTokenClient() { - Textract2Configuration textract2Configuration = new Textract2Configuration(); - textract2Configuration.setUseSessionCredentials(true); - Textract2InternalClient textractClient = Textract2ClientFactory.getTextractClient(textract2Configuration); - assertTrue(textractClient instanceof Textract2ClientSessionTokenImpl); - } -} diff --git a/components/camel-aws/camel-aws2-timestream/pom.xml b/components/camel-aws/camel-aws2-timestream/pom.xml index e2d7dd9ff26de..6ac4e5aa6f7a2 100644 --- a/components/camel-aws/camel-aws2-timestream/pom.xml +++ b/components/camel-aws/camel-aws2-timestream/pom.xml @@ -41,6 +41,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + org.apache.camel camel-health diff --git a/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2AbstractEndpointConfigurer.java b/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2AbstractEndpointConfigurer.java index 93c1ff4462be6..874029d61567d 100644 --- a/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2AbstractEndpointConfigurer.java +++ b/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2AbstractEndpointConfigurer.java @@ -47,6 +47,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "region": target.getConfiguration().setRegion(property(camelContext, java.lang.String.class, value)); return true; case "secretkey": case "secretKey": target.getConfiguration().setSecretKey(property(camelContext, java.lang.String.class, value)); return true; + case "sessiontoken": + case "sessionToken": target.getConfiguration().setSessionToken(property(camelContext, java.lang.String.class, value)); return true; case "trustallcertificates": case "trustAllCertificates": target.getConfiguration().setTrustAllCertificates(property(camelContext, boolean.class, value)); return true; case "uriendpointoverride": @@ -55,6 +57,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "useDefaultCredentialsProvider": target.getConfiguration().setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true; case "useprofilecredentialsprovider": case "useProfileCredentialsProvider": target.getConfiguration().setUseProfileCredentialsProvider(property(camelContext, boolean.class, value)); return true; + case "usesessioncredentials": + case "useSessionCredentials": target.getConfiguration().setUseSessionCredentials(property(camelContext, boolean.class, value)); return true; default: return false; } } @@ -91,6 +95,8 @@ public Class getOptionType(String name, boolean ignoreCase) { case "region": return java.lang.String.class; case "secretkey": case "secretKey": return java.lang.String.class; + case "sessiontoken": + case "sessionToken": return java.lang.String.class; case "trustallcertificates": case "trustAllCertificates": return boolean.class; case "uriendpointoverride": @@ -99,6 +105,8 @@ public Class getOptionType(String name, boolean ignoreCase) { case "useDefaultCredentialsProvider": return boolean.class; case "useprofilecredentialsprovider": case "useProfileCredentialsProvider": return boolean.class; + case "usesessioncredentials": + case "useSessionCredentials": return boolean.class; default: return null; } } @@ -131,6 +139,8 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "region": return target.getConfiguration().getRegion(); case "secretkey": case "secretKey": return target.getConfiguration().getSecretKey(); + case "sessiontoken": + case "sessionToken": return target.getConfiguration().getSessionToken(); case "trustallcertificates": case "trustAllCertificates": return target.getConfiguration().isTrustAllCertificates(); case "uriendpointoverride": @@ -139,6 +149,8 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "useDefaultCredentialsProvider": return target.getConfiguration().isUseDefaultCredentialsProvider(); case "useprofilecredentialsprovider": case "useProfileCredentialsProvider": return target.getConfiguration().isUseProfileCredentialsProvider(); + case "usesessioncredentials": + case "useSessionCredentials": return target.getConfiguration().isUseSessionCredentials(); default: return null; } } diff --git a/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2ComponentConfigurer.java b/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2ComponentConfigurer.java index 0a50317766030..7551e6055cefb 100644 --- a/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2ComponentConfigurer.java +++ b/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2ComponentConfigurer.java @@ -61,6 +61,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "region": getOrCreateConfiguration(target).setRegion(property(camelContext, java.lang.String.class, value)); return true; case "secretkey": case "secretKey": getOrCreateConfiguration(target).setSecretKey(property(camelContext, java.lang.String.class, value)); return true; + case "sessiontoken": + case "sessionToken": getOrCreateConfiguration(target).setSessionToken(property(camelContext, java.lang.String.class, value)); return true; case "trustallcertificates": case "trustAllCertificates": getOrCreateConfiguration(target).setTrustAllCertificates(property(camelContext, boolean.class, value)); return true; case "uriendpointoverride": @@ -69,6 +71,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "useDefaultCredentialsProvider": getOrCreateConfiguration(target).setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true; case "useprofilecredentialsprovider": case "useProfileCredentialsProvider": getOrCreateConfiguration(target).setUseProfileCredentialsProvider(property(camelContext, boolean.class, value)); return true; + case "usesessioncredentials": + case "useSessionCredentials": getOrCreateConfiguration(target).setUseSessionCredentials(property(camelContext, boolean.class, value)); return true; default: return false; } } @@ -112,6 +116,8 @@ public Class getOptionType(String name, boolean ignoreCase) { case "region": return java.lang.String.class; case "secretkey": case "secretKey": return java.lang.String.class; + case "sessiontoken": + case "sessionToken": return java.lang.String.class; case "trustallcertificates": case "trustAllCertificates": return boolean.class; case "uriendpointoverride": @@ -120,6 +126,8 @@ public Class getOptionType(String name, boolean ignoreCase) { case "useDefaultCredentialsProvider": return boolean.class; case "useprofilecredentialsprovider": case "useProfileCredentialsProvider": return boolean.class; + case "usesessioncredentials": + case "useSessionCredentials": return boolean.class; default: return null; } } @@ -159,6 +167,8 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "region": return getOrCreateConfiguration(target).getRegion(); case "secretkey": case "secretKey": return getOrCreateConfiguration(target).getSecretKey(); + case "sessiontoken": + case "sessionToken": return getOrCreateConfiguration(target).getSessionToken(); case "trustallcertificates": case "trustAllCertificates": return getOrCreateConfiguration(target).isTrustAllCertificates(); case "uriendpointoverride": @@ -167,6 +177,8 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "useDefaultCredentialsProvider": return getOrCreateConfiguration(target).isUseDefaultCredentialsProvider(); case "useprofilecredentialsprovider": case "useProfileCredentialsProvider": return getOrCreateConfiguration(target).isUseProfileCredentialsProvider(); + case "usesessioncredentials": + case "useSessionCredentials": return getOrCreateConfiguration(target).isUseSessionCredentials(); default: return null; } } diff --git a/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2EndpointUriFactory.java b/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2EndpointUriFactory.java index 80e8a5f0dd516..697cb0379830f 100644 --- a/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2EndpointUriFactory.java +++ b/components/camel-aws/camel-aws2-timestream/src/generated/java/org/apache/camel/component/aws2/timestream/Timestream2EndpointUriFactory.java @@ -23,7 +23,7 @@ public class Timestream2EndpointUriFactory extends org.apache.camel.support.comp private static final Set SECRET_PROPERTY_NAMES; private static final Map MULTI_VALUE_PREFIXES; static { - Set props = new HashSet<>(19); + Set props = new HashSet<>(21); props.add("accessKey"); props.add("awsTimestreamQueryClient"); props.add("awsTimestreamWriteClient"); @@ -39,14 +39,17 @@ public class Timestream2EndpointUriFactory extends org.apache.camel.support.comp props.add("proxyProtocol"); props.add("region"); props.add("secretKey"); + props.add("sessionToken"); props.add("trustAllCertificates"); props.add("uriEndpointOverride"); props.add("useDefaultCredentialsProvider"); props.add("useProfileCredentialsProvider"); + props.add("useSessionCredentials"); PROPERTY_NAMES = Collections.unmodifiableSet(props); - Set secretProps = new HashSet<>(2); + Set secretProps = new HashSet<>(3); secretProps.add("accessKey"); secretProps.add("secretKey"); + secretProps.add("sessionToken"); SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps); MULTI_VALUE_PREFIXES = Collections.emptyMap(); } diff --git a/components/camel-aws/camel-aws2-timestream/src/generated/resources/META-INF/org/apache/camel/component/aws2/timestream/aws2-timestream.json b/components/camel-aws/camel-aws2-timestream/src/generated/resources/META-INF/org/apache/camel/component/aws2/timestream/aws2-timestream.json index f723b0f3097a4..cc9f02cf65007 100644 --- a/components/camel-aws/camel-aws2-timestream/src/generated/resources/META-INF/org/apache/camel/component/aws2/timestream/aws2-timestream.json +++ b/components/camel-aws/camel-aws2-timestream/src/generated/resources/META-INF/org/apache/camel/component/aws2/timestream/aws2-timestream.json @@ -44,7 +44,9 @@ "proxyPort": { "index": 17, "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Timestream client" }, "proxyProtocol": { "index": 18, "kind": "property", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Timestream client" }, "accessKey": { "index": 19, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" }, - "secretKey": { "index": 20, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" } + "secretKey": { "index": 20, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, + "sessionToken": { "index": 21, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, + "useSessionCredentials": { "index": 22, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Set whether the Timestream client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Timestream." } }, "headers": { "CamelAwsTimestreamOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation we want to perform", "constantName": "org.apache.camel.component.aws2.timestream.Timestream2Constants#OPERATION" }, @@ -105,6 +107,8 @@ "proxyPort": { "index": 15, "kind": "parameter", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Timestream client" }, "proxyProtocol": { "index": 16, "kind": "parameter", "displayName": "Proxy Protocol", "group": "proxy", "label": "proxy", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Timestream client" }, "accessKey": { "index": 17, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" }, - "secretKey": { "index": 18, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" } + "secretKey": { "index": 18, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }, + "sessionToken": { "index": 19, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume an IAM role" }, + "useSessionCredentials": { "index": 20, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.timestream.Timestream2Configuration", "configurationField": "configuration", "description": "Set whether the Timestream client should expect to use Session Credentials. This is useful in a situation in which the user needs to assume an IAM role for doing operations in Timestream." } } } diff --git a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/Timestream2Configuration.java b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/Timestream2Configuration.java index 04497a2409ddc..91b3da29be79a 100644 --- a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/Timestream2Configuration.java +++ b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/Timestream2Configuration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.timestream; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -26,7 +27,7 @@ import software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClient; @UriParams -public class Timestream2Configuration implements Cloneable { +public class Timestream2Configuration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Type of client - write/query") @Metadata(required = true) @@ -41,6 +42,10 @@ public class Timestream2Configuration implements Cloneable { private String accessKey; @UriParam(label = "security", secret = true) private String secretKey; + @UriParam(label = "security", secret = true) + private String sessionToken; + @UriParam(label = "security") + private boolean useSessionCredentials; @UriParam(enums = "ap-south-2,ap-south-1,eu-south-1,eu-south-2,us-gov-east-1,me-central-1,il-central-1,ca-central-1,eu-central-1,us-iso-west-1,eu-central-2,eu-isoe-west-1,us-west-1,us-west-2,af-south-1,eu-north-1,eu-west-3,eu-west-2,eu-west-1,ap-northeast-3,ap-northeast-2,ap-northeast-1,me-south-1,sa-east-1,ap-east-1,cn-north-1,ca-west-1,us-gov-west-1,ap-southeast-1,ap-southeast-2,us-iso-east-1,ap-southeast-3,ap-southeast-4,us-east-1,us-east-2,cn-northwest-1,us-isob-east-1,aws-global,aws-cn-global,aws-us-gov-global,aws-iso-global,aws-iso-b-global") private String region; @UriParam(label = "proxy", enums = "HTTP,HTTPS", defaultValue = "HTTPS") @@ -118,6 +123,29 @@ public void setSecretKey(String secretKey) { this.secretKey = secretKey; } + public String getSessionToken() { + return sessionToken; + } + + /** + * Amazon AWS Session Token used when the user needs to assume an IAM role + */ + public void setSessionToken(String sessionToken) { + this.sessionToken = sessionToken; + } + + public boolean isUseSessionCredentials() { + return useSessionCredentials; + } + + /** + * Set whether the Timestream client should expect to use Session Credentials. This is useful in a situation in + * which the user needs to assume an IAM role for doing operations in Timestream. + */ + public void setUseSessionCredentials(boolean useSessionCredentials) { + this.useSessionCredentials = useSessionCredentials; + } + public String getRegion() { return region; } @@ -231,7 +259,7 @@ public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvid this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/Timestream2ClientFactory.java b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/Timestream2ClientFactory.java index a62fccd976ac9..0400cd0790fa3 100644 --- a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/Timestream2ClientFactory.java +++ b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/Timestream2ClientFactory.java @@ -16,12 +16,13 @@ */ package org.apache.camel.component.aws2.timestream.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.timestream.Timestream2Configuration; -import org.apache.camel.component.aws2.timestream.client.impl.Timestream2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.timestream.client.impl.Timestream2ClientStandardImpl; +import software.amazon.awssdk.services.timestreamquery.TimestreamQueryClient; +import software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClient; /** - * Factory class to return the correct type of AWS Timestream client. + * Factory class to create AWS Timestream clients using common configuration. */ public final class Timestream2ClientFactory { @@ -29,14 +30,26 @@ private Timestream2ClientFactory() { } /** - * Return the correct AWS Timestream client (based on remote vs local). + * Create a TimestreamWriteClient based on configuration. * - * @param configuration configuration - * @return Timestream + * @param configuration The Timestream configuration + * @return Configured TimestreamWriteClient */ - public static Timestream2InternalClient getTimestreamClient(Timestream2Configuration configuration) { - return Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider()) - ? new Timestream2ClientIAMOptimizedImpl(configuration) : new Timestream2ClientStandardImpl(configuration); + public static TimestreamWriteClient getTimestreamWriteClient(Timestream2Configuration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + TimestreamWriteClient::builder); } + /** + * Create a TimestreamQueryClient based on configuration. + * + * @param configuration The Timestream configuration + * @return Configured TimestreamQueryClient + */ + public static TimestreamQueryClient getTimestreamQueryClient(Timestream2Configuration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + TimestreamQueryClient::builder); + } } diff --git a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/Timestream2InternalClient.java b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/Timestream2InternalClient.java deleted file mode 100644 index 6eeceb0df7bca..0000000000000 --- a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/Timestream2InternalClient.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.aws2.timestream.client; - -import software.amazon.awssdk.services.timestreamquery.TimestreamQueryClient; -import software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClient; - -/** - * Manage the required actions of an Timestream client for either local or remote. - */ -public interface Timestream2InternalClient { - - /** - * Returns an TimestreamWrite client after a factory method determines which one to return. - * - * @return TimestreamWriteClient TimestreamWriteClient - */ - TimestreamWriteClient getTimestreamWriteClient(); - - /** - * Returns an TimestreamQuery client after a factory method determines which one to return. - * - * @return TimestreamQueryClient TimestreamQueryClient - */ - TimestreamQueryClient getTimestreamQueryClient(); - -} diff --git a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/impl/Timestream2ClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/impl/Timestream2ClientIAMOptimizedImpl.java deleted file mode 100644 index 39f9789f09dd8..0000000000000 --- a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/impl/Timestream2ClientIAMOptimizedImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.aws2.timestream.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.timestream.Timestream2Configuration; -import org.apache.camel.component.aws2.timestream.client.Timestream2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.timestreamquery.TimestreamQueryClient; -import software.amazon.awssdk.services.timestreamquery.TimestreamQueryClientBuilder; -import software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClient; -import software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Timestream client for all users to use (enabling temporary creds). This implementation is for remote - * instances to manage the credentials on their own (eliminating credential rotations) - */ -public class Timestream2ClientIAMOptimizedImpl implements Timestream2InternalClient { - - private static final Logger LOG = LoggerFactory.getLogger(Timestream2ClientIAMOptimizedImpl.class); - private Timestream2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Timestream2ClientIAMOptimizedImpl(Timestream2Configuration configuration) { - LOG.trace("Creating an AWS Timestream client for an ec2 instance with IAM temporary credentials (normal for ec2s)."); - this.configuration = configuration; - } - - /** - * Getting the TimestreamWrite aws client that is used. - * - * @return TimestreamWriteClient. - */ - @Override - public TimestreamWriteClient getTimestreamWriteClient() { - TimestreamWriteClient client = null; - TimestreamWriteClientBuilder clientBuilder = TimestreamWriteClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } - - /** - * Getting the TimestreamQuery aws client that is used. - * - * @return TimestreamQueryClient. - */ - @Override - public TimestreamQueryClient getTimestreamQueryClient() { - TimestreamQueryClient client = null; - TimestreamQueryClientBuilder clientBuilder = TimestreamQueryClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/impl/Timestream2ClientStandardImpl.java b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/impl/Timestream2ClientStandardImpl.java deleted file mode 100644 index 8318a1917e721..0000000000000 --- a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/client/impl/Timestream2ClientStandardImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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.aws2.timestream.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.timestream.Timestream2Configuration; -import org.apache.camel.component.aws2.timestream.client.Timestream2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.timestreamquery.TimestreamQueryClient; -import software.amazon.awssdk.services.timestreamquery.TimestreamQueryClientBuilder; -import software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClient; -import software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Timestream client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class Timestream2ClientStandardImpl implements Timestream2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Timestream2ClientStandardImpl.class); - private Timestream2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Timestream2ClientStandardImpl(Timestream2Configuration configuration) { - LOG.trace("Creating an AWS Timestream manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the TimestreamWrite AWS client that is used. - * - * @return Amazon TimestreamWrite Client. - */ - @Override - public TimestreamWriteClient getTimestreamWriteClient() { - TimestreamWriteClient client = null; - TimestreamWriteClientBuilder clientBuilder = TimestreamWriteClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } - - /** - * Getting the TimestreamQuery AWS client that is used. - * - * @return Amazon TimestreamQuery Client. - */ - @Override - public TimestreamQueryClient getTimestreamQueryClient() { - TimestreamQueryClient client = null; - TimestreamQueryClientBuilder clientBuilder = TimestreamQueryClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - clientBuilder.httpClient(ahc); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/query/Timestream2QueryEndpoint.java b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/query/Timestream2QueryEndpoint.java index 41316ed9d072d..4e820518e4b8c 100644 --- a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/query/Timestream2QueryEndpoint.java +++ b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/query/Timestream2QueryEndpoint.java @@ -51,7 +51,7 @@ public void doStart() throws Exception { super.doStart(); awsTimestreamQueryClient = getConfiguration().getAwsTimestreamQueryClient() != null ? getConfiguration().getAwsTimestreamQueryClient() - : Timestream2ClientFactory.getTimestreamClient(getConfiguration()).getTimestreamQueryClient(); + : Timestream2ClientFactory.getTimestreamQueryClient(getConfiguration()); } @Override diff --git a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/write/Timestream2WriteEndpoint.java b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/write/Timestream2WriteEndpoint.java index 61f05fa6dc39d..19adc2804e48c 100644 --- a/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/write/Timestream2WriteEndpoint.java +++ b/components/camel-aws/camel-aws2-timestream/src/main/java/org/apache/camel/component/aws2/timestream/write/Timestream2WriteEndpoint.java @@ -52,7 +52,7 @@ public void doStart() throws Exception { super.doStart(); awsTimestreamWriteClient = getConfiguration().getAwsTimestreamWriteClient() != null ? getConfiguration().getAwsTimestreamWriteClient() - : Timestream2ClientFactory.getTimestreamClient(getConfiguration()).getTimestreamWriteClient(); + : Timestream2ClientFactory.getTimestreamWriteClient(getConfiguration()); } @Override diff --git a/components/camel-aws/camel-aws2-timestream/src/test/java/org/apache/camel/component/aws2/timestream/Timestream2ClientFactoryTest.java b/components/camel-aws/camel-aws2-timestream/src/test/java/org/apache/camel/component/aws2/timestream/Timestream2ClientFactoryTest.java deleted file mode 100644 index 2c5cfa65ae54d..0000000000000 --- a/components/camel-aws/camel-aws2-timestream/src/test/java/org/apache/camel/component/aws2/timestream/Timestream2ClientFactoryTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.aws2.timestream; - -import org.apache.camel.component.aws2.timestream.client.Timestream2ClientFactory; -import org.apache.camel.component.aws2.timestream.client.Timestream2InternalClient; -import org.apache.camel.component.aws2.timestream.client.impl.Timestream2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.timestream.client.impl.Timestream2ClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class Timestream2ClientFactoryTest { - - @Test - public void getStandardTimestreamClientDefault() { - Timestream2Configuration timestream2Configuration = new Timestream2Configuration(); - Timestream2InternalClient timestreamClient = Timestream2ClientFactory.getTimestreamClient(timestream2Configuration); - assertTrue(timestreamClient instanceof Timestream2ClientStandardImpl); - } - - @Test - public void getStandardTimestreamClient() { - Timestream2Configuration timestream2Configuration = new Timestream2Configuration(); - timestream2Configuration.setUseDefaultCredentialsProvider(false); - Timestream2InternalClient timestreamClient = Timestream2ClientFactory.getTimestreamClient(timestream2Configuration); - assertTrue(timestreamClient instanceof Timestream2ClientStandardImpl); - } - - @Test - public void getIAMOptimizedTimestreamClient() { - Timestream2Configuration timestream2Configuration = new Timestream2Configuration(); - timestream2Configuration.setUseDefaultCredentialsProvider(true); - Timestream2InternalClient timestream2InternalClient - = Timestream2ClientFactory.getTimestreamClient(timestream2Configuration); - assertTrue(timestream2InternalClient instanceof Timestream2ClientIAMOptimizedImpl); - } -} diff --git a/components/camel-aws/camel-aws2-transcribe/pom.xml b/components/camel-aws/camel-aws2-transcribe/pom.xml index 2a8f048561695..a8d667cdd6c49 100644 --- a/components/camel-aws/camel-aws2-transcribe/pom.xml +++ b/components/camel-aws/camel-aws2-transcribe/pom.xml @@ -42,6 +42,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + software.amazon.awssdk transcribe diff --git a/components/camel-aws/camel-aws2-transcribe/src/generated/java/org/apache/camel/component/aws2/transcribe/Transcribe2ComponentConfigurer.java b/components/camel-aws/camel-aws2-transcribe/src/generated/java/org/apache/camel/component/aws2/transcribe/Transcribe2ComponentConfigurer.java index e9a9afda65b31..438c1ed039675 100644 --- a/components/camel-aws/camel-aws2-transcribe/src/generated/java/org/apache/camel/component/aws2/transcribe/Transcribe2ComponentConfigurer.java +++ b/components/camel-aws/camel-aws2-transcribe/src/generated/java/org/apache/camel/component/aws2/transcribe/Transcribe2ComponentConfigurer.java @@ -52,7 +52,7 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "proxyport": case "proxyPort": getOrCreateConfiguration(target).setProxyPort(property(camelContext, java.lang.Integer.class, value)); return true; case "proxyprotocol": - case "proxyProtocol": getOrCreateConfiguration(target).setProxyProtocol(property(camelContext, java.lang.String.class, value)); return true; + case "proxyProtocol": getOrCreateConfiguration(target).setProxyProtocol(property(camelContext, software.amazon.awssdk.core.Protocol.class, value)); return true; case "proxyusername": case "proxyUsername": getOrCreateConfiguration(target).setProxyUsername(property(camelContext, java.lang.String.class, value)); return true; case "region": getOrCreateConfiguration(target).setRegion(property(camelContext, java.lang.String.class, value)); return true; @@ -101,7 +101,7 @@ public Class getOptionType(String name, boolean ignoreCase) { case "proxyport": case "proxyPort": return java.lang.Integer.class; case "proxyprotocol": - case "proxyProtocol": return java.lang.String.class; + case "proxyProtocol": return software.amazon.awssdk.core.Protocol.class; case "proxyusername": case "proxyUsername": return java.lang.String.class; case "region": return java.lang.String.class; diff --git a/components/camel-aws/camel-aws2-transcribe/src/generated/java/org/apache/camel/component/aws2/transcribe/Transcribe2EndpointConfigurer.java b/components/camel-aws/camel-aws2-transcribe/src/generated/java/org/apache/camel/component/aws2/transcribe/Transcribe2EndpointConfigurer.java index 8dc845e2dc8e3..4ff3adecb458f 100644 --- a/components/camel-aws/camel-aws2-transcribe/src/generated/java/org/apache/camel/component/aws2/transcribe/Transcribe2EndpointConfigurer.java +++ b/components/camel-aws/camel-aws2-transcribe/src/generated/java/org/apache/camel/component/aws2/transcribe/Transcribe2EndpointConfigurer.java @@ -42,7 +42,7 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "proxyport": case "proxyPort": target.getConfiguration().setProxyPort(property(camelContext, java.lang.Integer.class, value)); return true; case "proxyprotocol": - case "proxyProtocol": target.getConfiguration().setProxyProtocol(property(camelContext, java.lang.String.class, value)); return true; + case "proxyProtocol": target.getConfiguration().setProxyProtocol(property(camelContext, software.amazon.awssdk.core.Protocol.class, value)); return true; case "proxyusername": case "proxyUsername": target.getConfiguration().setProxyUsername(property(camelContext, java.lang.String.class, value)); return true; case "region": target.getConfiguration().setRegion(property(camelContext, java.lang.String.class, value)); return true; @@ -88,7 +88,7 @@ public Class getOptionType(String name, boolean ignoreCase) { case "proxyport": case "proxyPort": return java.lang.Integer.class; case "proxyprotocol": - case "proxyProtocol": return java.lang.String.class; + case "proxyProtocol": return software.amazon.awssdk.core.Protocol.class; case "proxyusername": case "proxyUsername": return java.lang.String.class; case "region": return java.lang.String.class; diff --git a/components/camel-aws/camel-aws2-transcribe/src/generated/resources/META-INF/org/apache/camel/component/aws2/transcribe/aws2-transcribe.json b/components/camel-aws/camel-aws2-transcribe/src/generated/resources/META-INF/org/apache/camel/component/aws2/transcribe/aws2-transcribe.json index a8b1088ede3b7..9da016371f301 100644 --- a/components/camel-aws/camel-aws2-transcribe/src/generated/resources/META-INF/org/apache/camel/component/aws2/transcribe/aws2-transcribe.json +++ b/components/camel-aws/camel-aws2-transcribe/src/generated/resources/META-INF/org/apache/camel/component/aws2/transcribe/aws2-transcribe.json @@ -33,7 +33,7 @@ "protocol": { "index": 6, "kind": "property", "displayName": "Protocol", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, "proxyHost": { "index": 7, "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Transcribe client" }, "proxyPort": { "index": 8, "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Transcribe client" }, - "proxyProtocol": { "index": 9, "kind": "property", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, + "proxyProtocol": { "index": 9, "kind": "property", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, "region": { "index": 10, "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "The region in which Transcribe client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id()" }, "transcribeClient": { "index": 11, "kind": "property", "displayName": "Transcribe Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.transcribe.TranscribeClient", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To use a existing configured AWS Transcribe as client" }, "trustAllCertificates": { "index": 12, "kind": "property", "displayName": "Trust All Certificates", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, @@ -73,7 +73,7 @@ "protocol": { "index": 5, "kind": "parameter", "displayName": "Protocol", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, "proxyHost": { "index": 6, "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the Transcribe client" }, "proxyPort": { "index": 7, "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the Transcribe client" }, - "proxyProtocol": { "index": 8, "kind": "parameter", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, + "proxyProtocol": { "index": 8, "kind": "parameter", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the Transcribe client" }, "region": { "index": 9, "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "The region in which Transcribe client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id()" }, "transcribeClient": { "index": 10, "kind": "parameter", "displayName": "Transcribe Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.transcribe.TranscribeClient", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "To use a existing configured AWS Transcribe as client" }, "trustAllCertificates": { "index": 11, "kind": "parameter", "displayName": "Trust All Certificates", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" }, diff --git a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2ClientFactory.java b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2ClientFactory.java index ba101f40175a1..9d55ee6df53c0 100644 --- a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2ClientFactory.java +++ b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2ClientFactory.java @@ -16,58 +16,26 @@ */ package org.apache.camel.component.aws2.transcribe; -import java.net.URI; - -import org.apache.camel.component.aws2.transcribe.client.Transcribe2InternalClient; -import org.apache.camel.component.aws2.transcribe.client.impl.Transcribe2ClientIAMOptimizedImpl; -import org.apache.camel.component.aws2.transcribe.client.impl.Transcribe2ClientIAMProfileOptimizedImpl; -import org.apache.camel.component.aws2.transcribe.client.impl.Transcribe2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.transcribe.client.impl.Transcribe2ClientStandardImpl; -import org.apache.camel.util.ObjectHelper; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import software.amazon.awssdk.services.transcribe.TranscribeClient; +/** + * Factory class to create AWS Transcribe clients using common configuration. + */ public final class Transcribe2ClientFactory { private Transcribe2ClientFactory() { } + /** + * Create a TranscribeClient based on configuration. + * + * @param configuration The Transcribe configuration + * @return Configured TranscribeClient + */ public static TranscribeClient getTranscribeClient(Transcribe2Configuration configuration) { - TranscribeClient client = null; - Transcribe2InternalClient transcribeInternalClient = null; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - ProxyConfiguration.Builder proxyConfig = ProxyConfiguration.builder(); - proxyConfig = proxyConfig.endpoint(URI.create(configuration.getProxyProtocol() + "://" - + configuration.getProxyHost() + ":" + configuration.getProxyPort())); - if (ObjectHelper.isNotEmpty(configuration.getProxyUsername()) - && ObjectHelper.isNotEmpty(configuration.getProxyPassword())) { - proxyConfig.username(configuration.getProxyUsername()); - proxyConfig.password(configuration.getProxyPassword()); - } - ApacheHttpClient.Builder httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - if (configuration.isUseDefaultCredentialsProvider()) { - transcribeInternalClient = new Transcribe2ClientIAMOptimizedImpl(httpClientBuilder.build(), configuration); - } else if (configuration.isUseProfileCredentialsProvider()) { - transcribeInternalClient - = new Transcribe2ClientIAMProfileOptimizedImpl(httpClientBuilder.build(), configuration); - } else if (configuration.isUseSessionCredentials()) { - transcribeInternalClient = new Transcribe2ClientSessionTokenImpl(httpClientBuilder.build(), configuration); - } else { - transcribeInternalClient = new Transcribe2ClientStandardImpl(httpClientBuilder.build(), configuration); - } - } else { - if (configuration.isUseDefaultCredentialsProvider()) { - transcribeInternalClient = new Transcribe2ClientIAMOptimizedImpl(configuration); - } else if (configuration.isUseProfileCredentialsProvider()) { - transcribeInternalClient = new Transcribe2ClientIAMProfileOptimizedImpl(configuration); - } else if (configuration.isUseSessionCredentials()) { - transcribeInternalClient = new Transcribe2ClientSessionTokenImpl(configuration); - } else { - transcribeInternalClient = new Transcribe2ClientStandardImpl(configuration); - } - } - client = transcribeInternalClient.getTranscribeClient(); - return client; + return AwsClientBuilderUtil.buildClient( + configuration, + TranscribeClient::builder); } } diff --git a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Configuration.java b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Configuration.java index 0b03d638c78bd..2085186dfca8d 100644 --- a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Configuration.java +++ b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/Transcribe2Configuration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.transcribe; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.transcribe.TranscribeClient; @UriParams -public class Transcribe2Configuration implements Cloneable { +public class Transcribe2Configuration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) @@ -64,8 +65,8 @@ public class Transcribe2Configuration implements Cloneable { private String proxyHost; @UriParam private Integer proxyPort; - @UriParam(defaultValue = "HTTPS") - private String proxyProtocol = "HTTPS"; + @UriParam(enums = "HTTP,HTTPS", defaultValue = "HTTPS") + private Protocol proxyProtocol = Protocol.HTTPS; @UriParam(label = "security", secret = true) private String proxyUsername; @UriParam(label = "security", secret = true) @@ -334,14 +335,14 @@ public void setProxyPort(Integer proxyPort) { /** * To define a proxy protocol when instantiating the Transcribe client */ - public String getProxyProtocol() { + public Protocol getProxyProtocol() { return proxyProtocol; } /** * To define a proxy protocol when instantiating the Transcribe client */ - public void setProxyProtocol(String proxyProtocol) { + public void setProxyProtocol(Protocol proxyProtocol) { this.proxyProtocol = proxyProtocol; } diff --git a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/Transcribe2InternalClient.java b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/Transcribe2InternalClient.java deleted file mode 100644 index 3a3bbf2ff8e87..0000000000000 --- a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/Transcribe2InternalClient.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.aws2.transcribe.client; - -import software.amazon.awssdk.services.transcribe.TranscribeClient; - -public interface Transcribe2InternalClient { - - TranscribeClient getTranscribeClient(); -} diff --git a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientIAMOptimizedImpl.java deleted file mode 100644 index 9ef544d17fac0..0000000000000 --- a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientIAMOptimizedImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.aws2.transcribe.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.transcribe.Transcribe2Configuration; -import org.apache.camel.component.aws2.transcribe.client.Transcribe2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.transcribe.TranscribeClient; -import software.amazon.awssdk.services.transcribe.TranscribeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -public class Transcribe2ClientIAMOptimizedImpl implements Transcribe2InternalClient { - - private static final Logger LOG = LoggerFactory.getLogger(Transcribe2ClientIAMOptimizedImpl.class); - private Transcribe2Configuration configuration; - - public Transcribe2ClientIAMOptimizedImpl(Transcribe2Configuration configuration) { - this.configuration = configuration; - } - - public Transcribe2ClientIAMOptimizedImpl(SdkHttpClient httpClient, Transcribe2Configuration configuration) { - this.configuration = configuration; - } - - @Override - public TranscribeClient getTranscribeClient() { - TranscribeClient client = null; - TranscribeClientBuilder clientBuilder = TranscribeClient.builder(); - ApacheHttpClient.Builder httpClientBuilder = ApacheHttpClient.builder(); - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - clientBuilder = clientBuilder.credentialsProvider(DefaultCredentialsProvider.create()); - if (configuration.isTrustAllCertificates()) { - httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - } - clientBuilder.httpClient(httpClientBuilder.build()); - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientIAMProfileOptimizedImpl.java deleted file mode 100644 index 55aacf28b0755..0000000000000 --- a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientIAMProfileOptimizedImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.aws2.transcribe.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.transcribe.Transcribe2Configuration; -import org.apache.camel.component.aws2.transcribe.client.Transcribe2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.transcribe.TranscribeClient; -import software.amazon.awssdk.services.transcribe.TranscribeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -public class Transcribe2ClientIAMProfileOptimizedImpl implements Transcribe2InternalClient { - - private static final Logger LOG = LoggerFactory.getLogger(Transcribe2ClientIAMProfileOptimizedImpl.class); - private Transcribe2Configuration configuration; - - public Transcribe2ClientIAMProfileOptimizedImpl(Transcribe2Configuration configuration) { - this.configuration = configuration; - } - - public Transcribe2ClientIAMProfileOptimizedImpl(SdkHttpClient httpClient, Transcribe2Configuration configuration) { - this.configuration = configuration; - } - - @Override - public TranscribeClient getTranscribeClient() { - TranscribeClient client = null; - TranscribeClientBuilder clientBuilder = TranscribeClient.builder(); - ApacheHttpClient.Builder httpClientBuilder = ApacheHttpClient.builder(); - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (ObjectHelper.isNotEmpty(configuration.getProfileCredentialsName())) { - clientBuilder = clientBuilder - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } else { - clientBuilder = clientBuilder.credentialsProvider(ProfileCredentialsProvider.create()); - } - if (configuration.isTrustAllCertificates()) { - httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - } - clientBuilder.httpClient(httpClientBuilder.build()); - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientSessionTokenImpl.java deleted file mode 100644 index b9ed60bd5c067..0000000000000 --- a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientSessionTokenImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.aws2.transcribe.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.transcribe.Transcribe2Configuration; -import org.apache.camel.component.aws2.transcribe.client.Transcribe2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.transcribe.TranscribeClient; -import software.amazon.awssdk.services.transcribe.TranscribeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -public class Transcribe2ClientSessionTokenImpl implements Transcribe2InternalClient { - - private static final Logger LOG = LoggerFactory.getLogger(Transcribe2ClientSessionTokenImpl.class); - private Transcribe2Configuration configuration; - - public Transcribe2ClientSessionTokenImpl(Transcribe2Configuration configuration) { - this.configuration = configuration; - } - - public Transcribe2ClientSessionTokenImpl(SdkHttpClient httpClient, Transcribe2Configuration configuration) { - this.configuration = configuration; - } - - @Override - public TranscribeClient getTranscribeClient() { - TranscribeClient client = null; - TranscribeClientBuilder clientBuilder = TranscribeClient.builder(); - ApacheHttpClient.Builder httpClientBuilder = ApacheHttpClient.builder(); - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (ObjectHelper.isNotEmpty(configuration.getAccessKey()) && ObjectHelper.isNotEmpty(configuration.getSecretKey()) - && ObjectHelper.isNotEmpty(configuration.getSessionToken())) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - if (configuration.isTrustAllCertificates()) { - httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - } - clientBuilder.httpClient(httpClientBuilder.build()); - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientStandardImpl.java b/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientStandardImpl.java deleted file mode 100644 index 5818355ee48e6..0000000000000 --- a/components/camel-aws/camel-aws2-transcribe/src/main/java/org/apache/camel/component/aws2/transcribe/client/impl/Transcribe2ClientStandardImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.aws2.transcribe.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.transcribe.Transcribe2Configuration; -import org.apache.camel.component.aws2.transcribe.client.Transcribe2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.transcribe.TranscribeClient; -import software.amazon.awssdk.services.transcribe.TranscribeClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -public class Transcribe2ClientStandardImpl implements Transcribe2InternalClient { - - private static final Logger LOG = LoggerFactory.getLogger(Transcribe2ClientStandardImpl.class); - private Transcribe2Configuration configuration; - - public Transcribe2ClientStandardImpl(Transcribe2Configuration configuration) { - this.configuration = configuration; - } - - public Transcribe2ClientStandardImpl(SdkHttpClient httpClient, Transcribe2Configuration configuration) { - this.configuration = configuration; - } - - @Override - public TranscribeClient getTranscribeClient() { - TranscribeClient client = null; - TranscribeClientBuilder clientBuilder = TranscribeClient.builder(); - ApacheHttpClient.Builder httpClientBuilder = ApacheHttpClient.builder(); - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (ObjectHelper.isNotEmpty(configuration.getAccessKey()) && ObjectHelper.isNotEmpty(configuration.getSecretKey())) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - if (configuration.isTrustAllCertificates()) { - httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - } - clientBuilder.httpClient(httpClientBuilder.build()); - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-transcribe/src/test/java/org/apache/camel/component/aws2/transcribe/Transcribe2ClientFactoryTest.java b/components/camel-aws/camel-aws2-transcribe/src/test/java/org/apache/camel/component/aws2/transcribe/Transcribe2ClientFactoryTest.java deleted file mode 100644 index 240bb0aefb32a..0000000000000 --- a/components/camel-aws/camel-aws2-transcribe/src/test/java/org/apache/camel/component/aws2/transcribe/Transcribe2ClientFactoryTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.aws2.transcribe; - -import org.junit.jupiter.api.Test; -import software.amazon.awssdk.services.transcribe.TranscribeClient; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class Transcribe2ClientFactoryTest { - - @Test - public void getStandardTranscribeClientIsNotNull() { - Transcribe2Configuration transcribe2Configuration = new Transcribe2Configuration(); - transcribe2Configuration.setAccessKey("accesskey"); - transcribe2Configuration.setSecretKey("secretkey"); - transcribe2Configuration.setRegion("eu-west-1"); - TranscribeClient transcribeClient = Transcribe2ClientFactory.getTranscribeClient(transcribe2Configuration); - assertNotNull(transcribeClient); - } - - @Test - public void getIAMOptimizedTranscribeClientIsNotNull() { - Transcribe2Configuration transcribe2Configuration = new Transcribe2Configuration(); - transcribe2Configuration.setUseDefaultCredentialsProvider(true); - transcribe2Configuration.setRegion("eu-west-1"); - TranscribeClient transcribeClient = Transcribe2ClientFactory.getTranscribeClient(transcribe2Configuration); - assertNotNull(transcribeClient); - } - - @Test - public void getIAMProfileOptimizedTranscribeClientIsNotNull() { - Transcribe2Configuration transcribe2Configuration = new Transcribe2Configuration(); - transcribe2Configuration.setUseProfileCredentialsProvider(true); - transcribe2Configuration.setProfileCredentialsName("default"); - transcribe2Configuration.setRegion("eu-west-1"); - TranscribeClient transcribeClient = Transcribe2ClientFactory.getTranscribeClient(transcribe2Configuration); - assertNotNull(transcribeClient); - } - - @Test - public void getSessionTokenTranscribeClientIsNotNull() { - Transcribe2Configuration transcribe2Configuration = new Transcribe2Configuration(); - transcribe2Configuration.setAccessKey("accesskey"); - transcribe2Configuration.setSecretKey("secretkey"); - transcribe2Configuration.setSessionToken("sessionToken"); - transcribe2Configuration.setUseSessionCredentials(true); - transcribe2Configuration.setRegion("eu-west-1"); - TranscribeClient transcribeClient = Transcribe2ClientFactory.getTranscribeClient(transcribe2Configuration); - assertNotNull(transcribeClient); - } - - @Test - public void getStandardTranscribeClientWithProxyIsNotNull() { - Transcribe2Configuration transcribe2Configuration = new Transcribe2Configuration(); - transcribe2Configuration.setAccessKey("accesskey"); - transcribe2Configuration.setSecretKey("secretkey"); - transcribe2Configuration.setRegion("eu-west-1"); - transcribe2Configuration.setProxyHost("localhost"); - transcribe2Configuration.setProxyPort(9000); - transcribe2Configuration.setProxyProtocol("HTTP"); - TranscribeClient transcribeClient = Transcribe2ClientFactory.getTranscribeClient(transcribe2Configuration); - assertNotNull(transcribeClient); - } - - @Test - public void getStandardTranscribeClientWithProxyAndAuthIsNotNull() { - Transcribe2Configuration transcribe2Configuration = new Transcribe2Configuration(); - transcribe2Configuration.setAccessKey("accesskey"); - transcribe2Configuration.setSecretKey("secretkey"); - transcribe2Configuration.setRegion("eu-west-1"); - transcribe2Configuration.setProxyHost("localhost"); - transcribe2Configuration.setProxyPort(9000); - transcribe2Configuration.setProxyProtocol("HTTP"); - transcribe2Configuration.setProxyUsername("proxyuser"); - transcribe2Configuration.setProxyPassword("proxypass"); - TranscribeClient transcribeClient = Transcribe2ClientFactory.getTranscribeClient(transcribe2Configuration); - assertNotNull(transcribeClient); - } -} diff --git a/components/camel-aws/camel-aws2-translate/pom.xml b/components/camel-aws/camel-aws2-translate/pom.xml index b31672973a5f2..9300085c52149 100644 --- a/components/camel-aws/camel-aws2-translate/pom.xml +++ b/components/camel-aws/camel-aws2-translate/pom.xml @@ -40,6 +40,10 @@ org.apache.camel camel-support + + org.apache.camel + camel-aws-common + software.amazon.awssdk translate diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Configuration.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Configuration.java index b66581ac3af2a..ac60a4ea6e271 100644 --- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Configuration.java +++ b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Configuration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.translate; import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.aws.common.AwsCommonConfiguration; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -25,7 +26,7 @@ import software.amazon.awssdk.services.translate.TranslateClient; @UriParams -public class Translate2Configuration implements Cloneable { +public class Translate2Configuration implements Cloneable, AwsCommonConfiguration { @UriPath(description = "Logical name") @Metadata(required = true) @@ -259,7 +260,7 @@ public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvid this.useDefaultCredentialsProvider = useDefaultCredentialsProvider; } - public Boolean isUseDefaultCredentialsProvider() { + public boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Endpoint.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Endpoint.java index 805546c2967d8..989f9c851b4c1 100644 --- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Endpoint.java +++ b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Endpoint.java @@ -68,7 +68,7 @@ public void doStart() throws Exception { translateClient = configuration.getTranslateClient() != null ? configuration.getTranslateClient() - : Translate2ClientFactory.getTranslateClient(configuration).getTranslateClient(); + : Translate2ClientFactory.getTranslateClient(configuration); } @Override diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/Translate2ClientFactory.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/Translate2ClientFactory.java index 79c2898a65867..10be22979963e 100644 --- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/Translate2ClientFactory.java +++ b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/Translate2ClientFactory.java @@ -16,14 +16,12 @@ */ package org.apache.camel.component.aws2.translate.client; +import org.apache.camel.component.aws.common.AwsClientBuilderUtil; import org.apache.camel.component.aws2.translate.Translate2Configuration; -import org.apache.camel.component.aws2.translate.client.impl.Translate2ClientIAMOptimized; -import org.apache.camel.component.aws2.translate.client.impl.Translate2ClientIAMProfileOptimized; -import org.apache.camel.component.aws2.translate.client.impl.Translate2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.translate.client.impl.Translate2ClientStandardImpl; +import software.amazon.awssdk.services.translate.TranslateClient; /** - * Factory class to return the correct type of AWS Translate aws. + * Factory class to create AWS Translate clients using common configuration. */ public final class Translate2ClientFactory { @@ -31,20 +29,14 @@ private Translate2ClientFactory() { } /** - * Return the correct aws Translate client (based on remote vs local). + * Create a TranslateClient based on configuration. * - * @param configuration configuration - * @return TranslateClient + * @param configuration The Translate configuration + * @return Configured TranslateClient */ - public static Translate2InternalClient getTranslateClient(Translate2Configuration configuration) { - if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) { - return new Translate2ClientIAMOptimized(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) { - return new Translate2ClientIAMProfileOptimized(configuration); - } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) { - return new Translate2ClientSessionTokenImpl(configuration); - } else { - return new Translate2ClientStandardImpl(configuration); - } + public static TranslateClient getTranslateClient(Translate2Configuration configuration) { + return AwsClientBuilderUtil.buildClient( + configuration, + TranslateClient::builder); } } diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/Translate2InternalClient.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/Translate2InternalClient.java deleted file mode 100644 index 72556255ebda3..0000000000000 --- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/Translate2InternalClient.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.aws2.translate.client; - -import software.amazon.awssdk.services.translate.TranslateClient; - -public interface Translate2InternalClient { - - /** - * Returns an sts client after a factory method determines which one to return. - * - * @return TranslateClient stsClient - */ - TranslateClient getTranslateClient(); - -} diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientIAMOptimized.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientIAMOptimized.java deleted file mode 100644 index a397b9878f887..0000000000000 --- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientIAMOptimized.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.aws2.translate.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.translate.Translate2Configuration; -import org.apache.camel.component.aws2.translate.client.Translate2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.translate.TranslateClient; -import software.amazon.awssdk.services.translate.TranslateClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Translate client for all users to use. This implementation is for remote instances to manage the - * credentials on their own (eliminating credential rotations) - */ -public class Translate2ClientIAMOptimized implements Translate2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Translate2ClientIAMOptimized.class); - private Translate2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Translate2ClientIAMOptimized(Translate2Configuration configuration) { - LOG.trace("Creating an AWS Translate client for working on AWS Services"); - this.configuration = configuration; - } - - /** - * Getting the Translate aws client that is used. - * - * @return Amazon Translate Client. - */ - @Override - public TranslateClient getTranslateClient() { - TranslateClient client = null; - TranslateClientBuilder clientBuilder = TranslateClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientIAMProfileOptimized.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientIAMProfileOptimized.java deleted file mode 100644 index f4de9a1ff7923..0000000000000 --- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientIAMProfileOptimized.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.aws2.translate.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.translate.Translate2Configuration; -import org.apache.camel.component.aws2.translate.client.Translate2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.translate.TranslateClient; -import software.amazon.awssdk.services.translate.TranslateClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Translate client for all users to use. This implementation is for remote instances to manage the - * credentials on their own (eliminating credential rotations) - */ -public class Translate2ClientIAMProfileOptimized implements Translate2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Translate2ClientIAMProfileOptimized.class); - private Translate2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Translate2ClientIAMProfileOptimized(Translate2Configuration configuration) { - LOG.trace("Creating an AWS Translate client for working on AWS Services"); - this.configuration = configuration; - } - - /** - * Getting the Translate aws client that is used. - * - * @return Amazon Translate Client. - */ - @Override - public TranslateClient getTranslateClient() { - TranslateClient client = null; - TranslateClientBuilder clientBuilder = TranslateClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - if (configuration.getProfileCredentialsName() != null) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName())); - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientSessionTokenImpl.java deleted file mode 100644 index 226655b8f4778..0000000000000 --- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientSessionTokenImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.aws2.translate.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.translate.Translate2Configuration; -import org.apache.camel.component.aws2.translate.client.Translate2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.translate.TranslateClient; -import software.amazon.awssdk.services.translate.TranslateClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Translate client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class Translate2ClientSessionTokenImpl implements Translate2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Translate2ClientSessionTokenImpl.class); - private Translate2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Translate2ClientSessionTokenImpl(Translate2Configuration configuration) { - LOG.trace("Creating an AWS Translate manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Translate aws client that is used. - * - * @return Amazon Translate Client. - */ - @Override - public TranslateClient getTranslateClient() { - TranslateClient client = null; - TranslateClientBuilder clientBuilder = TranslateClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null - && configuration.getSessionToken() != null) { - AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(), - configuration.getSecretKey(), configuration.getSessionToken()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientStandardImpl.java b/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientStandardImpl.java deleted file mode 100644 index 6372612de9196..0000000000000 --- a/components/camel-aws/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/client/impl/Translate2ClientStandardImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.aws2.translate.client.impl; - -import java.net.URI; - -import org.apache.camel.component.aws2.translate.Translate2Configuration; -import org.apache.camel.component.aws2.translate.client.Translate2InternalClient; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; -import software.amazon.awssdk.http.apache.ProxyConfiguration; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.translate.TranslateClient; -import software.amazon.awssdk.services.translate.TranslateClientBuilder; -import software.amazon.awssdk.utils.AttributeMap; - -/** - * Manage an AWS Translate client for all users to use. This implementation is for local instances to use a static and - * solid credential set. - */ -public class Translate2ClientStandardImpl implements Translate2InternalClient { - private static final Logger LOG = LoggerFactory.getLogger(Translate2ClientStandardImpl.class); - private Translate2Configuration configuration; - - /** - * Constructor that uses the config file. - */ - public Translate2ClientStandardImpl(Translate2Configuration configuration) { - LOG.trace("Creating an AWS Translate manager using static credentials."); - this.configuration = configuration; - } - - /** - * Getting the Translate aws client that is used. - * - * @return Amazon Translate Client. - */ - @Override - public TranslateClient getTranslateClient() { - TranslateClient client = null; - TranslateClientBuilder clientBuilder = TranslateClient.builder(); - ProxyConfiguration.Builder proxyConfig = null; - ApacheHttpClient.Builder httpClientBuilder = null; - boolean isClientConfigFound = false; - if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) { - proxyConfig = ProxyConfiguration.builder(); - URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" - + configuration.getProxyPort()); - proxyConfig.endpoint(proxyEndpoint); - httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build()); - isClientConfigFound = true; - } - if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) { - AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey()); - if (isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder) - .credentialsProvider(StaticCredentialsProvider.create(cred)); - } else { - clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)); - } - } else { - if (!isClientConfigFound) { - clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder); - } - } - if (ObjectHelper.isNotEmpty(configuration.getRegion())) { - clientBuilder = clientBuilder.region(Region.of(configuration.getRegion())); - } - if (configuration.isOverrideEndpoint()) { - clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride())); - } - if (configuration.isTrustAllCertificates()) { - if (httpClientBuilder == null) { - httpClientBuilder = ApacheHttpClient.builder(); - } - SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap - .builder() - .put( - SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, - Boolean.TRUE) - .build()); - // set created http client to use instead of builder - clientBuilder.httpClient(ahc); - clientBuilder.httpClientBuilder(null); - } - client = clientBuilder.build(); - return client; - } -} diff --git a/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ClientFactoryTest.java b/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ClientFactoryTest.java deleted file mode 100644 index 02a22e04f7b01..0000000000000 --- a/components/camel-aws/camel-aws2-translate/src/test/java/org/apache/camel/component/aws2/translate/Translate2ClientFactoryTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.aws2.translate; - -import org.apache.camel.component.aws2.translate.client.Translate2ClientFactory; -import org.apache.camel.component.aws2.translate.client.Translate2InternalClient; -import org.apache.camel.component.aws2.translate.client.impl.Translate2ClientIAMOptimized; -import org.apache.camel.component.aws2.translate.client.impl.Translate2ClientSessionTokenImpl; -import org.apache.camel.component.aws2.translate.client.impl.Translate2ClientStandardImpl; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class Translate2ClientFactoryTest { - - @Test - public void getStandardTranslateClientDefault() { - Translate2Configuration translate2Configuration = new Translate2Configuration(); - Translate2InternalClient translateClient = Translate2ClientFactory.getTranslateClient(translate2Configuration); - assertTrue(translateClient instanceof Translate2ClientStandardImpl); - } - - @Test - public void getStandardTranslateClient() { - Translate2Configuration translate2Configuration = new Translate2Configuration(); - translate2Configuration.setUseDefaultCredentialsProvider(false); - Translate2InternalClient translateClient = Translate2ClientFactory.getTranslateClient(translate2Configuration); - assertTrue(translateClient instanceof Translate2ClientStandardImpl); - } - - @Test - public void getTranslateOptimizedIAMClient() { - Translate2Configuration translate2Configuration = new Translate2Configuration(); - translate2Configuration.setUseDefaultCredentialsProvider(true); - Translate2InternalClient translateClient = Translate2ClientFactory.getTranslateClient(translate2Configuration); - assertTrue(translateClient instanceof Translate2ClientIAMOptimized); - } - - @Test - public void getTranslateSessionTokenClient() { - Translate2Configuration translate2Configuration = new Translate2Configuration(); - translate2Configuration.setUseSessionCredentials(true); - Translate2InternalClient translateClient = Translate2ClientFactory.getTranslateClient(translate2Configuration); - assertTrue(translateClient instanceof Translate2ClientSessionTokenImpl); - } -} diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2AthenaComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2AthenaComponentBuilderFactory.java index 2c7eb8e832b7c..2b475ba834094 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2AthenaComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2AthenaComponentBuilderFactory.java @@ -253,6 +253,24 @@ default Aws2AthenaComponentBuilder outputType(org.apache.camel.component.aws2.at return this; } + + /** + * Set the need for overriding the endpoint. This option needs to be + * used in combination with the uriEndpointOverride option. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: producer + * + * @param overrideEndpoint the value to set + * @return the dsl builder + */ + default Aws2AthenaComponentBuilder overrideEndpoint(boolean overrideEndpoint) { + doSetProperty("overrideEndpoint", overrideEndpoint); + return this; + } + /** * The unique ID identifying the query execution. * @@ -347,6 +365,22 @@ default Aws2AthenaComponentBuilder retry(java.lang.String retry) { return this; } + /** + * Set the overriding uri endpoint. This option needs to be used in + * combination with overrideEndpoint option. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: producer + * + * @param uriEndpointOverride the value to set + * @return the dsl builder + */ + default Aws2AthenaComponentBuilder uriEndpointOverride(java.lang.String uriEndpointOverride) { + doSetProperty("uriEndpointOverride", uriEndpointOverride); + return this; + } + /** * Optional max wait time in millis to wait for a successful query * completion. See the section Waiting for Query Completion and Retrying @@ -632,6 +666,24 @@ default Aws2AthenaComponentBuilder sessionToken(java.lang.String sessionToken) { } + /** + * If we want to trust all certificates in case of overriding the + * endpoint. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: security + * + * @param trustAllCertificates the value to set + * @return the dsl builder + */ + default Aws2AthenaComponentBuilder trustAllCertificates(boolean trustAllCertificates) { + doSetProperty("trustAllCertificates", trustAllCertificates); + return this; + } + + /** * Set whether the Athena client should expect to load credentials * through a default credentials provider or to expect static @@ -718,11 +770,13 @@ protected boolean setPropertyOnComponent( case "operation": getOrCreateConfiguration((Athena2Component) component).setOperation((org.apache.camel.component.aws2.athena.Athena2Operations) value); return true; case "outputLocation": getOrCreateConfiguration((Athena2Component) component).setOutputLocation((java.lang.String) value); return true; case "outputType": getOrCreateConfiguration((Athena2Component) component).setOutputType((org.apache.camel.component.aws2.athena.Athena2OutputType) value); return true; + case "overrideEndpoint": getOrCreateConfiguration((Athena2Component) component).setOverrideEndpoint((boolean) value); return true; case "queryExecutionId": getOrCreateConfiguration((Athena2Component) component).setQueryExecutionId((java.lang.String) value); return true; case "queryString": getOrCreateConfiguration((Athena2Component) component).setQueryString((java.lang.String) value); return true; case "region": getOrCreateConfiguration((Athena2Component) component).setRegion((java.lang.String) value); return true; case "resetWaitTimeoutOnRetry": getOrCreateConfiguration((Athena2Component) component).setResetWaitTimeoutOnRetry((boolean) value); return true; case "retry": getOrCreateConfiguration((Athena2Component) component).setRetry((java.lang.String) value); return true; + case "uriEndpointOverride": getOrCreateConfiguration((Athena2Component) component).setUriEndpointOverride((java.lang.String) value); return true; case "waitTimeout": getOrCreateConfiguration((Athena2Component) component).setWaitTimeout((long) value); return true; case "workGroup": getOrCreateConfiguration((Athena2Component) component).setWorkGroup((java.lang.String) value); return true; case "amazonAthenaClient": getOrCreateConfiguration((Athena2Component) component).setAmazonAthenaClient((software.amazon.awssdk.services.athena.AthenaClient) value); return true; @@ -740,6 +794,7 @@ protected boolean setPropertyOnComponent( case "profileCredentialsName": getOrCreateConfiguration((Athena2Component) component).setProfileCredentialsName((java.lang.String) value); return true; case "secretKey": getOrCreateConfiguration((Athena2Component) component).setSecretKey((java.lang.String) value); return true; case "sessionToken": getOrCreateConfiguration((Athena2Component) component).setSessionToken((java.lang.String) value); return true; + case "trustAllCertificates": getOrCreateConfiguration((Athena2Component) component).setTrustAllCertificates((boolean) value); return true; case "useDefaultCredentialsProvider": getOrCreateConfiguration((Athena2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true; case "useProfileCredentialsProvider": getOrCreateConfiguration((Athena2Component) component).setUseProfileCredentialsProvider((boolean) value); return true; case "useSessionCredentials": getOrCreateConfiguration((Athena2Component) component).setUseSessionCredentials((boolean) value); return true; diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TimestreamComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TimestreamComponentBuilderFactory.java index 18c67a414c452..b88280f330d98 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TimestreamComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TimestreamComponentBuilderFactory.java @@ -418,6 +418,41 @@ default Aws2TimestreamComponentBuilder secretKey(java.lang.String secretKey) { doSetProperty("secretKey", secretKey); return this; } + + /** + * Amazon AWS Session Token used when the user needs to assume an IAM + * role. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param sessionToken the value to set + * @return the dsl builder + */ + default Aws2TimestreamComponentBuilder sessionToken(java.lang.String sessionToken) { + doSetProperty("sessionToken", sessionToken); + return this; + } + + + /** + * Set whether the Timestream client should expect to use Session + * Credentials. This is useful in a situation in which the user needs to + * assume an IAM role for doing operations in Timestream. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: security + * + * @param useSessionCredentials the value to set + * @return the dsl builder + */ + default Aws2TimestreamComponentBuilder useSessionCredentials(boolean useSessionCredentials) { + doSetProperty("useSessionCredentials", useSessionCredentials); + return this; + } } class Aws2TimestreamComponentBuilderImpl @@ -460,6 +495,8 @@ protected boolean setPropertyOnComponent( case "proxyProtocol": getOrCreateConfiguration((Timestream2Component) component).setProxyProtocol((software.amazon.awssdk.core.Protocol) value); return true; case "accessKey": getOrCreateConfiguration((Timestream2Component) component).setAccessKey((java.lang.String) value); return true; case "secretKey": getOrCreateConfiguration((Timestream2Component) component).setSecretKey((java.lang.String) value); return true; + case "sessionToken": getOrCreateConfiguration((Timestream2Component) component).setSessionToken((java.lang.String) value); return true; + case "useSessionCredentials": getOrCreateConfiguration((Timestream2Component) component).setUseSessionCredentials((boolean) value); return true; default: return false; } } diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranscribeComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranscribeComponentBuilderFactory.java index 76a03da4cec26..a5df74ab294bb 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranscribeComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2TranscribeComponentBuilderFactory.java @@ -210,7 +210,8 @@ default Aws2TranscribeComponentBuilder proxyPort(java.lang.Integer proxyPort) { /** * To define a proxy protocol when instantiating the Transcribe client. * - * The option is a: <code>java.lang.String</code> type. + * The option is a: + * <code>software.amazon.awssdk.core.Protocol</code> type. * * Default: HTTPS * Group: producer @@ -218,7 +219,7 @@ default Aws2TranscribeComponentBuilder proxyPort(java.lang.Integer proxyPort) { * @param proxyProtocol the value to set * @return the dsl builder */ - default Aws2TranscribeComponentBuilder proxyProtocol(java.lang.String proxyProtocol) { + default Aws2TranscribeComponentBuilder proxyProtocol(software.amazon.awssdk.core.Protocol proxyProtocol) { doSetProperty("proxyProtocol", proxyProtocol); return this; } @@ -474,7 +475,7 @@ protected boolean setPropertyOnComponent( case "protocol": getOrCreateConfiguration((Transcribe2Component) component).setProtocol((software.amazon.awssdk.core.Protocol) value); return true; case "proxyHost": getOrCreateConfiguration((Transcribe2Component) component).setProxyHost((java.lang.String) value); return true; case "proxyPort": getOrCreateConfiguration((Transcribe2Component) component).setProxyPort((java.lang.Integer) value); return true; - case "proxyProtocol": getOrCreateConfiguration((Transcribe2Component) component).setProxyProtocol((java.lang.String) value); return true; + case "proxyProtocol": getOrCreateConfiguration((Transcribe2Component) component).setProxyProtocol((software.amazon.awssdk.core.Protocol) value); return true; case "region": getOrCreateConfiguration((Transcribe2Component) component).setRegion((java.lang.String) value); return true; case "transcribeClient": getOrCreateConfiguration((Transcribe2Component) component).setTranscribeClient((software.amazon.awssdk.services.transcribe.TranscribeClient) value); return true; case "trustAllCertificates": getOrCreateConfiguration((Transcribe2Component) component).setTrustAllCertificates((boolean) value); return true; diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsSecretsManagerComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsSecretsManagerComponentBuilderFactory.java index 55abc494ace10..cbcea6a15ea43 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsSecretsManagerComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsSecretsManagerComponentBuilderFactory.java @@ -418,9 +418,9 @@ default AwsSecretsManagerComponentBuilder trustAllCertificates(boolean trustAllC /** - * Set whether the Translate client should expect to load credentials - * through a default credentials provider or to expect static - * credentials to be passed in. + * Set whether the Secrets Manager client should expect to load + * credentials through a default credentials provider or to expect + * static credentials to be passed in. * * The option is a: <code>boolean</code> type. * diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Athena2EndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Athena2EndpointBuilderFactory.java index 40adadd3ba6a0..90d00e3cdb511 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Athena2EndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Athena2EndpointBuilderFactory.java @@ -300,6 +300,38 @@ default Athena2EndpointBuilder outputType(String outputType) { doSetProperty("outputType", outputType); return this; } + /** + * Set the need for overriding the endpoint. This option needs to be + * used in combination with the uriEndpointOverride option. + * + * The option is a: boolean type. + * + * Default: false + * Group: producer + * + * @param overrideEndpoint the value to set + * @return the dsl builder + */ + default Athena2EndpointBuilder overrideEndpoint(boolean overrideEndpoint) { + doSetProperty("overrideEndpoint", overrideEndpoint); + return this; + } + /** + * Set the need for overriding the endpoint. This option needs to be + * used in combination with the uriEndpointOverride option. + * + * The option will be converted to a boolean type. + * + * Default: false + * Group: producer + * + * @param overrideEndpoint the value to set + * @return the dsl builder + */ + default Athena2EndpointBuilder overrideEndpoint(String overrideEndpoint) { + doSetProperty("overrideEndpoint", overrideEndpoint); + return this; + } /** * The unique ID identifying the query execution. * @@ -405,6 +437,21 @@ default Athena2EndpointBuilder retry(String retry) { doSetProperty("retry", retry); return this; } + /** + * Set the overriding uri endpoint. This option needs to be used in + * combination with overrideEndpoint option. + * + * The option is a: java.lang.String type. + * + * Group: producer + * + * @param uriEndpointOverride the value to set + * @return the dsl builder + */ + default Athena2EndpointBuilder uriEndpointOverride(String uriEndpointOverride) { + doSetProperty("uriEndpointOverride", uriEndpointOverride); + return this; + } /** * Optional max wait time in millis to wait for a successful query * completion. See the section Waiting for Query Completion and Retrying @@ -632,6 +679,38 @@ default Athena2EndpointBuilder sessionToken(String sessionToken) { doSetProperty("sessionToken", sessionToken); return this; } + /** + * If we want to trust all certificates in case of overriding the + * endpoint. + * + * The option is a: boolean type. + * + * Default: false + * Group: security + * + * @param trustAllCertificates the value to set + * @return the dsl builder + */ + default Athena2EndpointBuilder trustAllCertificates(boolean trustAllCertificates) { + doSetProperty("trustAllCertificates", trustAllCertificates); + return this; + } + /** + * If we want to trust all certificates in case of overriding the + * endpoint. + * + * The option will be converted to a boolean type. + * + * Default: false + * Group: security + * + * @param trustAllCertificates the value to set + * @return the dsl builder + */ + default Athena2EndpointBuilder trustAllCertificates(String trustAllCertificates) { + doSetProperty("trustAllCertificates", trustAllCertificates); + return this; + } /** * Set whether the Athena client should expect to load credentials * through a default credentials provider or to expect static diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SecretsManagerEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SecretsManagerEndpointBuilderFactory.java index 9a11571274eef..920099c13c15a 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SecretsManagerEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SecretsManagerEndpointBuilderFactory.java @@ -400,9 +400,9 @@ default SecretsManagerEndpointBuilder trustAllCertificates(String trustAllCertif return this; } /** - * Set whether the Translate client should expect to load credentials - * through a default credentials provider or to expect static - * credentials to be passed in. + * Set whether the Secrets Manager client should expect to load + * credentials through a default credentials provider or to expect + * static credentials to be passed in. * * The option is a: boolean type. * @@ -417,9 +417,9 @@ default SecretsManagerEndpointBuilder useDefaultCredentialsProvider(boolean useD return this; } /** - * Set whether the Translate client should expect to load credentials - * through a default credentials provider or to expect static - * credentials to be passed in. + * Set whether the Secrets Manager client should expect to load + * credentials through a default credentials provider or to expect + * static credentials to be passed in. * * The option will be converted to a boolean type. * diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Timestream2EndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Timestream2EndpointBuilderFactory.java index 462336589edb8..c79e2cf905f58 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Timestream2EndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Timestream2EndpointBuilderFactory.java @@ -390,6 +390,55 @@ default Timestream2EndpointBuilder secretKey(String secretKey) { doSetProperty("secretKey", secretKey); return this; } + /** + * Amazon AWS Session Token used when the user needs to assume an IAM + * role. + * + * The option is a: java.lang.String type. + * + * Group: security + * + * @param sessionToken the value to set + * @return the dsl builder + */ + default Timestream2EndpointBuilder sessionToken(String sessionToken) { + doSetProperty("sessionToken", sessionToken); + return this; + } + /** + * Set whether the Timestream client should expect to use Session + * Credentials. This is useful in a situation in which the user needs to + * assume an IAM role for doing operations in Timestream. + * + * The option is a: boolean type. + * + * Default: false + * Group: security + * + * @param useSessionCredentials the value to set + * @return the dsl builder + */ + default Timestream2EndpointBuilder useSessionCredentials(boolean useSessionCredentials) { + doSetProperty("useSessionCredentials", useSessionCredentials); + return this; + } + /** + * Set whether the Timestream client should expect to use Session + * Credentials. This is useful in a situation in which the user needs to + * assume an IAM role for doing operations in Timestream. + * + * The option will be converted to a boolean type. + * + * Default: false + * Group: security + * + * @param useSessionCredentials the value to set + * @return the dsl builder + */ + default Timestream2EndpointBuilder useSessionCredentials(String useSessionCredentials) { + doSetProperty("useSessionCredentials", useSessionCredentials); + return this; + } } /** diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Transcribe2EndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Transcribe2EndpointBuilderFactory.java index cf89939a2036f..da8d385a4bff4 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Transcribe2EndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Transcribe2EndpointBuilderFactory.java @@ -229,7 +229,24 @@ default Transcribe2EndpointBuilder proxyPort(String proxyPort) { /** * To define a proxy protocol when instantiating the Transcribe client. * - * The option is a: java.lang.String type. + * The option is a: software.amazon.awssdk.core.Protocol + * type. + * + * Default: HTTPS + * Group: producer + * + * @param proxyProtocol the value to set + * @return the dsl builder + */ + default Transcribe2EndpointBuilder proxyProtocol(software.amazon.awssdk.core.Protocol proxyProtocol) { + doSetProperty("proxyProtocol", proxyProtocol); + return this; + } + /** + * To define a proxy protocol when instantiating the Transcribe client. + * + * The option will be converted to a + * software.amazon.awssdk.core.Protocol type. * * Default: HTTPS * Group: producer