Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage] az storage fs file set-expiry: New command to support setting expiry for files in ADLS Gen2 file system #23395

Merged
merged 3 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/azure-cli/azure/cli/command_modules/storage/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2417,7 +2417,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
help='Show nextMarker in result when specified.')

for item in ['create', 'show', 'delete', 'exists', 'upload', 'append', 'download', 'show', 'metadata update',
'metadata show']:
'metadata show', 'set-expiry']:
with self.argument_context('storage fs file {}'.format(item)) as c:
c.extra('file_system_name', options_list=['-f', '--file-system'],
help='File system name (i.e. container name).', required=True)
Expand Down Expand Up @@ -2473,6 +2473,16 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('permissions', permissions_type)
c.argument('umask', umask_type)

with self.argument_context('storage fs file set-expiry') as c:
t_expiry_option_type = self.get_models('_generated.models#PathExpiryOptions',
resource_type=ResourceType.DATA_STORAGE_FILEDATALAKE)
c.argument('expiry_options', required=True, arg_type=get_enum_type(t_expiry_option_type))
from ._validators import validate_fs_file_set_expiry
c.argument('expires_on', validator=validate_fs_file_set_expiry,
help='The time to set the file to expiry. When expiry_options is '
'RelativeTo*, expires_on should be an int in milliseconds. If the '
'type of expires_on is datetime, it should be in UTC time.')

for item in ['set', 'show']:
with self.argument_context('storage fs access {}'.format(item)) as c:
from ._validators import validate_access_control
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2211,3 +2211,10 @@ def validate_blob_arguments(namespace):
def encode_deleted_path(namespace):
from urllib.parse import quote
namespace.deleted_path_name = quote(namespace.deleted_path_name)


def validate_fs_file_set_expiry(namespace):
try:
namespace.expires_on = get_datetime_type(False)(namespace.expires_on)
except ValueError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
g.storage_command_oauth('metadata update', 'set_metadata')
g.storage_command_oauth('metadata show', 'get_file_properties', exception_handler=show_exception_handler,
transform=transform_metadata)
g.storage_command_oauth('set-expiry', "set_file_expiry")

with self.command_group('storage fs access', adls_directory_sdk, custom_command_type=custom_adls_directory_sdk,
resource_type=ResourceType.DATA_STORAGE_FILEDATALAKE, min_api='2018-11-09') as g:
Expand Down
Loading