lordgamez commented on a change in pull request #931:
URL: https://github.com/apache/nifi-minifi-cpp/pull/931#discussion_r540874499



##########
File path: extensions/aws/processors/S3Processor.cpp
##########
@@ -0,0 +1,263 @@
+/**
+ * @file S3Processor.cpp
+ * Base S3 processor class implementation
+ *
+ * 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.
+ */
+
+#include "S3Processor.h"
+
+#include <string>
+#include <set>
+#include <memory>
+
+#include "S3Wrapper.h"
+#include "AWSCredentialsService.h"
+#include "properties/Properties.h"
+#include "utils/StringUtils.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace aws {
+namespace processors {
+
+const std::set<std::string> S3Processor::REGIONS({region::AF_SOUTH_1, 
region::AP_EAST_1, region::AP_NORTHEAST_1,
+  region::AP_NORTHEAST_2, region::AP_NORTHEAST_3, region::AP_SOUTH_1, 
region::AP_SOUTHEAST_1, region::AP_SOUTHEAST_2,
+  region::CA_CENTRAL_1, region::CN_NORTH_1, region::CN_NORTHWEST_1, 
region::EU_CENTRAL_1, region::EU_NORTH_1,
+  region::EU_SOUTH_1, region::EU_WEST_1, region::EU_WEST_2, region::EU_WEST_3, 
region::ME_SOUTH_1, region::SA_EAST_1,
+  region::US_EAST_1, region::US_EAST_2, region::US_GOV_EAST_1, 
region::US_GOV_WEST_1, region::US_WEST_1, region::US_WEST_2});
+
+const core::Property S3Processor::ObjectKey(
+  core::PropertyBuilder::createProperty("Object Key")
+    ->withDescription("The key of the S3 object. If none is given the filename 
attribute will be used by default.")
+    ->supportsExpressionLanguage(true)
+    ->build());
+const core::Property S3Processor::Bucket(
+  core::PropertyBuilder::createProperty("Bucket")
+    ->withDescription("The S3 bucket")
+    ->isRequired(true)
+    ->supportsExpressionLanguage(true)
+    ->build());
+const core::Property S3Processor::AccessKey(
+  core::PropertyBuilder::createProperty("Access Key")
+    ->withDescription("AWS account access key")
+    ->supportsExpressionLanguage(true)
+    ->build());
+const core::Property S3Processor::SecretKey(
+  core::PropertyBuilder::createProperty("Secret Key")
+    ->withDescription("AWS account secret key")
+    ->supportsExpressionLanguage(true)
+    ->build());
+const core::Property S3Processor::CredentialsFile(
+  core::PropertyBuilder::createProperty("Credentials File")
+    ->withDescription("Path to a file containing AWS access key and secret key 
in properties file format. Properties used: accessKey and secretKey")
+    ->build());
+const core::Property S3Processor::AWSCredentialsProviderService(
+  core::PropertyBuilder::createProperty("AWS Credentials Provider service")
+    ->withDescription("The name of the AWS Credentials Provider controller 
service that is used to obtain AWS credentials.")
+    ->build());
+const core::Property S3Processor::Region(
+  core::PropertyBuilder::createProperty("Region")
+    ->isRequired(true)
+    ->withDefaultValue<std::string>(region::US_WEST_2)
+    ->withAllowableValues<std::string>(S3Processor::REGIONS)
+    ->withDescription("AWS Region")
+    ->build());
+const core::Property S3Processor::CommunicationsTimeout(
+  core::PropertyBuilder::createProperty("Communications Timeout")
+    ->isRequired(true)
+    ->withDefaultValue<core::TimePeriodValue>("30 sec")
+    ->withDescription("")
+    ->build());
+const core::Property S3Processor::EndpointOverrideURL(
+  core::PropertyBuilder::createProperty("Endpoint Override URL")
+    ->withDescription("Endpoint URL to use instead of the AWS default 
including scheme, host, "
+                      "port, and path. The AWS libraries select an endpoint 
URL based on the AWS "
+                      "region, but this property overrides the selected 
endpoint URL, allowing use "
+                      "with other S3-compatible endpoints.")
+    ->supportsExpressionLanguage(true)
+    ->build());
+const core::Property S3Processor::ProxyHost(
+  core::PropertyBuilder::createProperty("Proxy Host")
+    ->withDescription("Proxy host name or IP")
+    ->supportsExpressionLanguage(true)
+    ->build());
+const core::Property S3Processor::ProxyPort(
+  core::PropertyBuilder::createProperty("Proxy Port")
+    ->withDescription("The port number of the proxy host")
+    ->supportsExpressionLanguage(true)
+    ->build());
+const core::Property S3Processor::ProxyUsername(
+    core::PropertyBuilder::createProperty("Proxy Username")
+    ->withDescription("Username to set when authenticating against proxy")
+    ->supportsExpressionLanguage(true)
+    ->build());
+const core::Property S3Processor::ProxyPassword(
+  core::PropertyBuilder::createProperty("Proxy Password")
+    ->withDescription("Password to set when authenticating against proxy")
+    ->supportsExpressionLanguage(true)
+    ->build());
+const core::Property S3Processor::UseDefaultCredentials(
+    core::PropertyBuilder::createProperty("Use Default Credentials")
+    ->withDescription("If true, uses the Default Credential chain, including 
EC2 instance profiles or roles, environment variables, default user 
credentials, etc.")
+    ->withDefaultValue<bool>(false)
+    ->isRequired(true)
+    ->build());
+
+S3Processor::S3Processor(std::string name, minifi::utils::Identifier uuid, 
const std::shared_ptr<logging::Logger> &logger)
+  : core::Processor(std::move(name), uuid)
+  , logger_(logger)
+  , s3_wrapper_(minifi::utils::make_unique<aws::s3::S3Wrapper>()) {
+}
+
+S3Processor::S3Processor(std::string name, minifi::utils::Identifier uuid, 
const std::shared_ptr<logging::Logger> &logger, 
std::unique_ptr<aws::s3::S3WrapperBase> s3_wrapper)
+  : core::Processor(std::move(name), uuid)
+  , logger_(logger)
+  , s3_wrapper_(std::move(s3_wrapper)) {
+}
+
+const std::set<core::Property> S3Processor::getSupportedProperties() {
+  return {ObjectKey, Bucket, AccessKey, SecretKey, CredentialsFile, 
CredentialsFile, AWSCredentialsProviderService, Region, CommunicationsTimeout,
+    EndpointOverrideURL, ProxyHost, ProxyPort, ProxyUsername, ProxyPassword, 
UseDefaultCredentials};
+}
+
+minifi::utils::optional<Aws::Auth::AWSCredentials> 
S3Processor::getAWSCredentialsFromControllerService(const 
std::shared_ptr<core::ProcessContext> &context) const {

Review comment:
       It is needed in this case, as we introduced minifi::aws::utils and this 
class is in the scope of the aws namespace.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to