-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(file-based): sync file acl permissions and identities (#260)
We will leverage DefaultFileBased stream and stream reader to reuse most of the logic for scrapping files and let connectors implement the logic from the domain they handle. In the UI we will add a new Transfer Mode to Replicate Permissions ACL - Enhanced file transfer options now support permissions replication, enabling delivery of access permissions along with identity data. - Introduced an additional delivery method option to mirror source file permission restrictions and identity stream inclusion.
- Loading branch information
1 parent
d44aea8
commit 10c1085
Showing
14 changed files
with
775 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
airbyte_cdk/sources/file_based/config/validate_config_transfer_modes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# | ||
# Copyright (c) 2025 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
from airbyte_cdk.sources.file_based.config.abstract_file_based_spec import ( | ||
AbstractFileBasedSpec, | ||
DeliverRawFiles, | ||
) | ||
from airbyte_cdk.sources.specs.transfer_modes import DeliverPermissions | ||
|
||
DELIVERY_TYPE_KEY = "delivery_type" | ||
DELIVERY_TYPE_PERMISSION_TRANSFER_MODE_VALUE = "use_permissions_transfer" | ||
DELIVERY_TYPE_FILES_TRANSFER_MODE_VALUE = "use_file_transfer" | ||
PRESERVE_DIRECTORY_STRUCTURE_KEY = "preserve_directory_structure" | ||
INCLUDE_IDENTITIES_STREAM_KEY = "include_identities_stream" | ||
|
||
|
||
def use_file_transfer(parsed_config: AbstractFileBasedSpec) -> bool: | ||
"""Returns `True` if the configuration uses file transfer mode.""" | ||
return ( | ||
hasattr(parsed_config.delivery_method, DELIVERY_TYPE_KEY) | ||
and parsed_config.delivery_method.delivery_type == DELIVERY_TYPE_FILES_TRANSFER_MODE_VALUE | ||
) | ||
|
||
|
||
def preserve_directory_structure(parsed_config: AbstractFileBasedSpec) -> bool: | ||
""" | ||
Determines whether to preserve directory structure during file transfer. | ||
When enabled, files maintain their subdirectory paths in the destination. | ||
When disabled, files are flattened to the root of the destination. | ||
Args: | ||
parsed_config: The parsed configuration containing delivery method settings | ||
Returns: | ||
True if directory structure should be preserved (default), False otherwise | ||
""" | ||
if ( | ||
use_file_transfer(parsed_config) | ||
and hasattr(parsed_config.delivery_method, PRESERVE_DIRECTORY_STRUCTURE_KEY) | ||
and isinstance(parsed_config.delivery_method, DeliverRawFiles) | ||
): | ||
return parsed_config.delivery_method.preserve_directory_structure | ||
return True | ||
|
||
|
||
def use_permissions_transfer(parsed_config: AbstractFileBasedSpec) -> bool: | ||
""" | ||
Determines whether to use permissions transfer to sync ACLs and Identities | ||
Args: | ||
parsed_config: The parsed configuration containing delivery method settings | ||
Returns: | ||
True if permissions transfer should be enabled, False otherwise | ||
""" | ||
return ( | ||
hasattr(parsed_config.delivery_method, DELIVERY_TYPE_KEY) | ||
and parsed_config.delivery_method.delivery_type | ||
== DELIVERY_TYPE_PERMISSION_TRANSFER_MODE_VALUE | ||
) | ||
|
||
|
||
def include_identities_stream(parsed_config: AbstractFileBasedSpec) -> bool: | ||
""" | ||
There are scenarios where user may not have access to identities but still is valuable to get ACLs | ||
Args: | ||
parsed_config: The parsed configuration containing delivery method settings | ||
Returns: | ||
True if we should include Identities stream. | ||
""" | ||
if ( | ||
use_permissions_transfer(parsed_config) | ||
and hasattr(parsed_config.delivery_method, INCLUDE_IDENTITIES_STREAM_KEY) | ||
and isinstance(parsed_config.delivery_method, DeliverPermissions) | ||
): | ||
return parsed_config.delivery_method.include_identities_stream | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.