diff --git a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java index ddd4373935..d41902866d 100644 --- a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java +++ b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java @@ -212,19 +212,22 @@ public abstract class AbstractGCPProcessor< */ protected TransportOptions getTransportOptions(ProcessContext context) { final ProxyConfiguration proxyConfiguration = ProxyConfiguration.getConfiguration(context, () -> { - final String proxyHost = context.getProperty(PROXY_HOST).evaluateAttributeExpressions().getValue(); - final Integer proxyPort = context.getProperty(PROXY_PORT).evaluateAttributeExpressions().asInteger(); - if (proxyHost != null && proxyPort != null && proxyPort > 0) { - final ProxyConfiguration componentProxyConfig = new ProxyConfiguration(); - final String proxyUser = context.getProperty(HTTP_PROXY_USERNAME).evaluateAttributeExpressions().getValue(); - final String proxyPassword = context.getProperty(HTTP_PROXY_PASSWORD).evaluateAttributeExpressions().getValue(); - componentProxyConfig.setProxyType(Proxy.Type.HTTP); - componentProxyConfig.setProxyServerHost(proxyHost); - componentProxyConfig.setProxyServerPort(proxyPort); - componentProxyConfig.setProxyUserName(proxyUser); - componentProxyConfig.setProxyUserPassword(proxyPassword); - return componentProxyConfig; + if (context.getProperty(PROXY_HOST).isSet() && context.getProperty(PROXY_PORT).isSet()) { + final String proxyHost = context.getProperty(PROXY_HOST).evaluateAttributeExpressions().getValue(); + final Integer proxyPort = context.getProperty(PROXY_PORT).evaluateAttributeExpressions().asInteger(); + if (proxyHost != null && proxyPort != null && proxyPort > 0) { + final ProxyConfiguration componentProxyConfig = new ProxyConfiguration(); + final String proxyUser = context.getProperty(HTTP_PROXY_USERNAME).evaluateAttributeExpressions().getValue(); + final String proxyPassword = context.getProperty(HTTP_PROXY_PASSWORD).evaluateAttributeExpressions().getValue(); + componentProxyConfig.setProxyType(Proxy.Type.HTTP); + componentProxyConfig.setProxyServerHost(proxyHost); + componentProxyConfig.setProxyServerPort(proxyPort); + componentProxyConfig.setProxyUserName(proxyUser); + componentProxyConfig.setProxyUserPassword(proxyPassword); + return componentProxyConfig; + } } + return ProxyConfiguration.DIRECT_CONFIGURATION; }); diff --git a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery/PutBigQuery.java b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery/PutBigQuery.java index 1decd1f19d..426d3c04c7 100644 --- a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery/PutBigQuery.java +++ b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery/PutBigQuery.java @@ -17,6 +17,9 @@ package org.apache.nifi.processors.gcp.bigquery; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toList; + import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutureCallback; import com.google.api.core.ApiFutures; @@ -42,6 +45,7 @@ import com.google.protobuf.Descriptors; import com.google.protobuf.DynamicMessage; import io.grpc.Status; import java.time.LocalTime; +import java.util.stream.Stream; import org.apache.nifi.annotation.behavior.EventDriven; import org.apache.nifi.annotation.behavior.InputRequirement; import org.apache.nifi.annotation.behavior.TriggerSerially; @@ -119,6 +123,11 @@ public class PutBigQuery extends AbstractBigQueryProcessor { private int recordBatchCount; private boolean skipInvalidRows; + public static final PropertyDescriptor PROJECT_ID = new PropertyDescriptor.Builder() + .fromPropertyDescriptor(AbstractBigQueryProcessor.PROJECT_ID) + .required(true) + .build(); + static final PropertyDescriptor TRANSFER_TYPE = new PropertyDescriptor.Builder() .name(TRANSFER_TYPE_NAME) .displayName("Transfer Type") @@ -155,16 +164,21 @@ public class PutBigQuery extends AbstractBigQueryProcessor { .defaultValue("false") .build(); + private static final List DESCRIPTORS = Stream.of( + GCP_CREDENTIALS_PROVIDER_SERVICE, + PROJECT_ID, + DATASET, + TABLE_NAME, + RECORD_READER, + TRANSFER_TYPE, + APPEND_RECORD_COUNT, + RETRY_COUNT, + SKIP_INVALID_ROWS + ).collect(collectingAndThen(toList(), Collections::unmodifiableList)); + @Override public List getSupportedPropertyDescriptors() { - List descriptors = new ArrayList<>(super.getSupportedPropertyDescriptors()); - descriptors.add(TRANSFER_TYPE); - descriptors.add(RECORD_READER); - descriptors.add(APPEND_RECORD_COUNT); - descriptors.add(SKIP_INVALID_ROWS); - descriptors.remove(IGNORE_UNKNOWN); - - return Collections.unmodifiableList(descriptors); + return DESCRIPTORS; } @Override