Skip to content

Commit 03956fc

Browse files
committed
Changing ttl flag to url_expiry
1 parent 1d5b036 commit 03956fc

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

cloudinary_cli/modules/clone.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@
4343
help="Clone the assets asynchronously.")
4444
@option("-nu", "--notification_url",
4545
help="Webhook notification URL.")
46-
@option("-t", "--ttl", type=int, default=3600,
46+
@option("-ue", "--url_expiry", type=int, default=3600,
4747
help=("URL expiration duration in seconds. Only relevant if cloning "
4848
"restricted assets. If you do not provide an auth_key, "
4949
"a private download URL is generated which may incur additional "
5050
"bandwidth costs."))
5151
def clone(target, force, overwrite, concurrent_workers, fields,
52-
search_exp, async_, notification_url, ttl):
52+
search_exp, async_, notification_url, url_expiry):
5353
target_config, auth_token = _validate_clone_inputs(target)
5454
if not target_config:
5555
return False
@@ -63,7 +63,7 @@ def clone(target, force, overwrite, concurrent_workers, fields,
6363

6464
upload_list = _prepare_upload_list(
6565
source_assets, target_config, overwrite, async_,
66-
notification_url, auth_token, ttl, fields
66+
notification_url, auth_token, url_expiry, fields
6767
)
6868

6969
logger.info(style(f"Copying {len(upload_list)} asset(s) from "
@@ -107,12 +107,12 @@ def _validate_clone_inputs(target):
107107

108108

109109
def _prepare_upload_list(source_assets, target_config, overwrite, async_,
110-
notification_url, auth_token, ttl, fields):
110+
notification_url, auth_token, url_expiry, fields):
111111
upload_list = []
112112
for r in source_assets.get('resources'):
113113
updated_options, asset_url = process_metadata(r, overwrite, async_,
114114
notification_url,
115-
auth_token, ttl,
115+
auth_token, url_expiry,
116116
normalize_list_params(fields))
117117
updated_options.update(config_to_dict(target_config))
118118
upload_list.append((asset_url, {**updated_options}))
@@ -170,16 +170,16 @@ def _normalize_search_expression(search_exp):
170170
return search_exp
171171

172172

173-
def process_metadata(res, overwrite, async_, notification_url, auth_token, ttl, copy_fields=None):
173+
def process_metadata(res, overwrite, async_, notification_url, auth_token, url_expiry, copy_fields=None):
174174
if copy_fields is None:
175175
copy_fields = []
176-
asset_url = _get_asset_url(res, auth_token, ttl)
176+
asset_url = _get_asset_url(res, auth_token, url_expiry)
177177
cloned_options = _build_cloned_options(res, overwrite, async_, notification_url, copy_fields)
178178

179179
return cloned_options, asset_url
180180

181181

182-
def _get_asset_url(res, auth_token, ttl):
182+
def _get_asset_url(res, auth_token, url_expiry):
183183
if not (isinstance(res.get('access_control'), list) and
184184
len(res.get('access_control')) > 0 and
185185
isinstance(res['access_control'][0], dict) and
@@ -198,7 +198,7 @@ def _get_asset_url(res, auth_token, ttl):
198198
pub_id_format,
199199
type=del_type,
200200
resource_type=reso_type,
201-
auth_token={"duration": ttl},
201+
auth_token={"duration": url_expiry},
202202
secure=True,
203203
sign_url=True
204204
)
@@ -209,7 +209,7 @@ def _get_asset_url(res, auth_token, ttl):
209209
file_format,
210210
resource_type=reso_type,
211211
type=del_type,
212-
expires_at=int(time.time()) + ttl
212+
expires_at=int(time.time()) + url_expiry
213213
)
214214

215215

0 commit comments

Comments
 (0)