in azure/datalake/store/core.py [0:0]
def set_expiry(self, path, expiry_option, expire_time=None):
"""
Set or remove the expiration time on the specified file.
This operation can only be executed against files.
Note: Folders are not supported.
Parameters
----------
path: str
File path to set or remove expiration time
expire_time: int
The time that the file will expire, corresponding to the expiry_option that was set
expiry_option: str
Indicates the type of expiration to use for the file:
1. NeverExpire: ExpireTime is ignored.
2. RelativeToNow: ExpireTime is an integer in milliseconds representing the expiration date relative to when file expiration is updated.
3. RelativeToCreationDate: ExpireTime is an integer in milliseconds representing the expiration date relative to file creation.
4. Absolute: ExpireTime is an integer in milliseconds, as a Unix timestamp relative to 1/1/1970 00:00:00.
"""
parms = {}
value_to_use = [x for x in valid_expire_types if x.lower() == expiry_option.lower()]
if len(value_to_use) != 1:
raise ValueError(
'expiry_option must be one of: {}. Value given: {}'.format(valid_expire_types, expiry_option))
if value_to_use[0] != ExpiryOptionType.never_expire.value and not expire_time:
raise ValueError(
'expire_time must be specified if the expiry_option is not NeverExpire. Value of expiry_option: {}'.format(
expiry_option))
path = AzureDLPath(path).trim()
parms['expiryOption'] = value_to_use[0]
if expire_time:
parms['expireTime'] = int(expire_time)
self.azure.call('SETEXPIRY', path.as_posix(), is_extended=True, **parms)
self.invalidate_cache(path.as_posix())