43
43
help = "Clone the assets asynchronously." )
44
44
@option ("-nu" , "--notification_url" ,
45
45
help = "Webhook notification URL." )
46
- @option ("-t " , "--ttl " , type = int , default = 3600 ,
46
+ @option ("-ue " , "--url_expiry " , type = int , default = 3600 ,
47
47
help = ("URL expiration duration in seconds. Only relevant if cloning "
48
48
"restricted assets. If you do not provide an auth_key, "
49
49
"a private download URL is generated which may incur additional "
50
50
"bandwidth costs." ))
51
51
def clone (target , force , overwrite , concurrent_workers , fields ,
52
- search_exp , async_ , notification_url , ttl ):
52
+ search_exp , async_ , notification_url , url_expiry ):
53
53
target_config , auth_token = _validate_clone_inputs (target )
54
54
if not target_config :
55
55
return False
@@ -63,7 +63,7 @@ def clone(target, force, overwrite, concurrent_workers, fields,
63
63
64
64
upload_list = _prepare_upload_list (
65
65
source_assets , target_config , overwrite , async_ ,
66
- notification_url , auth_token , ttl , fields
66
+ notification_url , auth_token , url_expiry , fields
67
67
)
68
68
69
69
logger .info (style (f"Copying { len (upload_list )} asset(s) from "
@@ -107,12 +107,12 @@ def _validate_clone_inputs(target):
107
107
108
108
109
109
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 ):
111
111
upload_list = []
112
112
for r in source_assets .get ('resources' ):
113
113
updated_options , asset_url = process_metadata (r , overwrite , async_ ,
114
114
notification_url ,
115
- auth_token , ttl ,
115
+ auth_token , url_expiry ,
116
116
normalize_list_params (fields ))
117
117
updated_options .update (config_to_dict (target_config ))
118
118
upload_list .append ((asset_url , {** updated_options }))
@@ -170,16 +170,16 @@ def _normalize_search_expression(search_exp):
170
170
return search_exp
171
171
172
172
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 ):
174
174
if copy_fields is None :
175
175
copy_fields = []
176
- asset_url = _get_asset_url (res , auth_token , ttl )
176
+ asset_url = _get_asset_url (res , auth_token , url_expiry )
177
177
cloned_options = _build_cloned_options (res , overwrite , async_ , notification_url , copy_fields )
178
178
179
179
return cloned_options , asset_url
180
180
181
181
182
- def _get_asset_url (res , auth_token , ttl ):
182
+ def _get_asset_url (res , auth_token , url_expiry ):
183
183
if not (isinstance (res .get ('access_control' ), list ) and
184
184
len (res .get ('access_control' )) > 0 and
185
185
isinstance (res ['access_control' ][0 ], dict ) and
@@ -198,7 +198,7 @@ def _get_asset_url(res, auth_token, ttl):
198
198
pub_id_format ,
199
199
type = del_type ,
200
200
resource_type = reso_type ,
201
- auth_token = {"duration" : ttl },
201
+ auth_token = {"duration" : url_expiry },
202
202
secure = True ,
203
203
sign_url = True
204
204
)
@@ -209,7 +209,7 @@ def _get_asset_url(res, auth_token, ttl):
209
209
file_format ,
210
210
resource_type = reso_type ,
211
211
type = del_type ,
212
- expires_at = int (time .time ()) + ttl
212
+ expires_at = int (time .time ()) + url_expiry
213
213
)
214
214
215
215
0 commit comments