File tree 1 file changed +16
-4
lines changed
osbot_aws/aws/cloud_front 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 1
- from osbot_aws .apis .Session import Session
2
-
3
- from osbot_utils .base_classes .Kwargs_To_Self import Kwargs_To_Self
4
-
1
+ import time
2
+ from typing import List
3
+ from osbot_utils .decorators .methods .type_safe import type_safe
4
+ from osbot_aws .apis .Session import Session
5
+ from osbot_utils .base_classes .Kwargs_To_Self import Kwargs_To_Self
5
6
6
7
class Cloud_Front (Kwargs_To_Self ):
7
8
@@ -14,3 +15,14 @@ def distributions(self):
14
15
items = response .get ('DistributionList' , {}).get ('Items' , [])
15
16
return items
16
17
18
+ def invalidate_path (self , distribution_id : str , paths : str ):
19
+ return self .invalidate_paths (distribution_id , [paths ])
20
+
21
+ @type_safe
22
+ def invalidate_paths (self , distribution_id :str , paths : List [str ]):
23
+ kwargs = dict (DistributionId = distribution_id ,
24
+ InvalidationBatch = { 'Paths' : { 'Quantity' : len (paths ) ,
25
+ 'Items' : paths },
26
+ 'CallerReference' : f'invalidation-{ int (time .time ()) } ' }) # Unique reference
27
+ response = self .client ().create_invalidation (** kwargs )
28
+ return response
You can’t perform that action at this time.
0 commit comments