Re: [PR] NIFI-12672 Added Azure specific versions of FileResourceService [nifi]

2024-02-26 Thread via GitHub


asfgit closed pull request #8359: NIFI-12672 Added Azure specific versions of 
FileResourceService
URL: https://github.com/apache/nifi/pull/8359


-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] NIFI-12672 Added Azure specific versions of FileResourceService [nifi]

2024-02-23 Thread via GitHub


turcsanyip commented on code in PR #8359:
URL: https://github.com/apache/nifi/pull/8359#discussion_r1500389209


##
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/storage/AzureDataLakeStorageFileResourceService.java:
##
@@ -0,0 +1,139 @@
+/*
+ * 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.nifi.services.azure.storage;
+
+import com.azure.storage.file.datalake.DataLakeDirectoryClient;
+import com.azure.storage.file.datalake.DataLakeFileClient;
+import com.azure.storage.file.datalake.DataLakeFileSystemClient;
+import com.azure.storage.file.datalake.DataLakeServiceClient;
+import com.azure.storage.file.datalake.models.DataLakeStorageException;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.SeeAlso;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.documentation.UseCase;
+import org.apache.nifi.annotation.lifecycle.OnDisabled;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.fileresource.service.api.FileResource;
+import org.apache.nifi.fileresource.service.api.FileResourceService;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processors.azure.storage.FetchAzureDataLakeStorage;
+import 
org.apache.nifi.processors.azure.storage.utils.DataLakeServiceClientFactory;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils.ADLS_CREDENTIALS_SERVICE;
+import static 
org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils.DIRECTORY;
+import static 
org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils.FILE;
+import static 
org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils.FILESYSTEM;
+import static 
org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils.getProxyOptions;
+import static 
org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils.validateDirectoryProperty;
+import static 
org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils.validateFileProperty;
+import static 
org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils.validateFileSystemProperty;
+
+@Tags({"azure", "microsoft", "cloud", "storage", "adlsgen2", "file", 
"resource", "datalake"})
+@SeeAlso({FetchAzureDataLakeStorage.class})
+@CapabilityDescription("Provides an Azure Data Lake Storage (ADLS) file 
resource for other components.")
+@UseCase(
+description = "Fetch the specified file from Azure Data Lake Storage." 
+
+" The service provides higher performance compared to fetch 
processors when the data should be moved between different storages without any 
transformation.",
+configuration = """
+"Filesystem Name" = "${azure.filesystem}"
+"Directory Name" = "${azure.directory}"
+"File Name" = "${azure.filename}"
+
+The "ADLS Credentials" property should specify an instance of 
the ADLSCredentialsService in order to provide credentials for accessing the 
filesystem.
+"""
+)
+public class AzureDataLakeStorageFileResourceService extends 
AbstractControllerService implements FileResourceService {
+
+private static final List PROPERTIES = List.of(
+ADLS_CREDENTIALS_SERVICE,
+FILESYSTEM,
+DIRECTORY,

Review Comment:
   Please add default values for these properties (`${azure.filesystem}` and 
`${azure.directory}`, respectively). The defaults should be the attributes 
emitted by `ListAzureDataLakeStorage` (as in case of `ListAzureBlobStorage_v12` 
and `AzureBlobStorageFileResourceService`).



##
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/storage/AzureBlobStorageFileResourceService.java:
##
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) 

Re: [PR] NIFI-12672 Added Azure specific versions of FileResourceService [nifi]

2024-02-09 Thread via GitHub


mark-bathori commented on code in PR #8359:
URL: https://github.com/apache/nifi/pull/8359#discussion_r1484035099


##
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/storage/AzureBlobStorageFileResourceService.java:
##
@@ -0,0 +1,147 @@
+/*
+ * 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.nifi.services.azure.storage;
+
+import com.azure.storage.blob.BlobClient;
+import com.azure.storage.blob.BlobContainerClient;
+import com.azure.storage.blob.BlobServiceClient;
+import com.azure.storage.blob.models.BlobStorageException;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.SeeAlso;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.documentation.UseCase;
+import org.apache.nifi.annotation.lifecycle.OnDisabled;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.fileresource.service.api.FileResource;
+import org.apache.nifi.fileresource.service.api.FileResourceService;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processors.azure.AbstractAzureBlobProcessor_v12;
+import org.apache.nifi.processors.azure.storage.FetchAzureBlobStorage_v12;
+import org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils;
+import org.apache.nifi.processors.azure.storage.utils.BlobServiceClientFactory;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils.getProxyOptions;
+import static 
org.apache.nifi.processors.azure.storage.utils.BlobAttributes.ATTR_NAME_BLOBNAME;
+import static 
org.apache.nifi.processors.azure.storage.utils.BlobAttributes.ATTR_NAME_CONTAINER;
+import static org.apache.nifi.util.StringUtils.isBlank;
+
+@Tags({"azure", "microsoft", "cloud", "storage", "file", "resource", "blob"})
+@SeeAlso({FetchAzureBlobStorage_v12.class})
+@CapabilityDescription("Provides an Azure Blob Storage file resource for other 
components.")
+@UseCase(
+description = "Fetch a specific file from Azure Blob Storage." +
+" The service provides higher performance compared to fetch 
processors when the data should be moved between different storages without any 
transformation.",
+configuration = """
+"Container Name" = "${azure.container}"
+"Blob Name" = "${azure.blobname}"
+
+The "Storage Credentials" property should specify an instance 
of the AzureStorageCredentialsService_v12 in order to provide credentials for 
accessing the storage container.
+"""
+)
+public class AzureBlobStorageFileResourceService extends 
AbstractControllerService implements FileResourceService {
+
+public static final PropertyDescriptor CONTAINER = new 
PropertyDescriptor.Builder()
+.fromPropertyDescriptor(AzureStorageUtils.CONTAINER)
+.defaultValue(String.format("${%s}", ATTR_NAME_CONTAINER))
+.build();
+
+public static final PropertyDescriptor BLOB_NAME = new 
PropertyDescriptor.Builder()
+.fromPropertyDescriptor(AbstractAzureBlobProcessor_v12.BLOB_NAME)
+.defaultValue(String.format("${%s}", ATTR_NAME_BLOBNAME))
+.build();
+
+public static final PropertyDescriptor STORAGE_CREDENTIALS_SERVICE = new 
PropertyDescriptor.Builder()
+.name("storage-credentials-service")
+.displayName("Storage Credentials")
+.description("Controller Service used to obtain Azure Blob Storage 
Credentials.")
+
.identifiesControllerService(AzureStorageCredentialsService_v12.class)
+.required(true)
+.build();
+
+private static final List PROPERTIES = List.of(
+CONTAINER,
+BLOB_NAME,
+STORAGE_CREDENTIALS_SERVICE
+);
+
+private volatile BlobServiceClientFactory clientFactory;
+private volatile