File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,11 +17,6 @@ def __init__(self, lightbeam=None):
1717
1818 # Deletes data matching payloads in config.data_dir for selected endpoints
1919 def delete (self ):
20- # prompt to confirm this destructive operation
21- if not self .lightbeam .config .get ("force_delete" , False ):
22- if input ('Type "yes" to confirm you want to delete payloads for the selected endpoints? ' )!= "yes" :
23- exit ('You did not type "yes" - exiting.' )
24-
2520 # load swagger docs, so we can find natural keys for each resource and query the API for existing records to delete
2621 self .lightbeam .api .load_swagger_docs ()
2722
@@ -37,6 +32,9 @@ def delete(self):
3732 endpoints = copy .deepcopy (endpoints )
3833 endpoints .reverse ()
3934
35+ # prompt to confirm this destructive operation
36+ self .lightbeam .confirm_delete (endpoints )
37+
4038 for endpoint in endpoints :
4139 # it doesn't seem possible to delete students once you've sent them
4240 # (I think because other entities may have referenced them in the meantime)
Original file line number Diff line number Diff line change @@ -141,7 +141,21 @@ def meets_process_criteria(self, tuple):
141141 or (self .newer_than and tuple [0 ]> self .newer_than )
142142 or (len (self .resend_status_codes )> 0 and tuple [1 ] in self .resend_status_codes )
143143 )
144+
145+ def _confirm_delete_op (self , endpoints , verbiage ):
146+ if self .config .get ("force_delete" , False ):
147+ return
148+
149+ endpoint_list = "\n \t - " .join (endpoints )
150+ print (f'Preparing to delete the following endpoints:\n \t • { endpoint_list } ' )
151+ if input (f'Type "yes" to confirm you want to { verbiage } payloads for the selected endpoints? ' )!= "yes" :
152+ exit ('You did not type "yes" - exiting.' )
153+
154+ def confirm_delete (self , endpoints ):
155+ self ._confirm_delete_op (endpoints , "delete" )
144156
157+ def confirm_truncate (self , endpoints ):
158+ self ._confirm_delete_op (endpoints , "TRUNCATE ALL DATA" )
145159
146160 ################### Data discovery and loading methods ####################
147161
Original file line number Diff line number Diff line change @@ -17,18 +17,16 @@ def __init__(self, lightbeam=None):
1717
1818 # Deletes all data in the Ed-Fi API for selected endpoints
1919 def truncate (self ):
20- # prompt to confirm this destructive operation
21- if not self .lightbeam .config .get ("force_delete" , False ):
22- if input ('Type "yes" to confirm you want to TRUNCATE ALL DATA payloads for the selected endpoints? ' )!= "yes" :
23- exit ('You did not type "yes" - exiting.' )
24-
2520 # get token with which to send requests
2621 self .lightbeam .api .do_oauth ()
2722
2823 # process endpoints in reverse-dependency order, so we don't get dependency errors
2924 endpoints = self .lightbeam .endpoints
3025 endpoints .reverse ()
3126
27+ # prompt to confirm this destructive operation
28+ self .lightbeam .confirm_truncate (endpoints )
29+
3230 for endpoint in endpoints :
3331 # it doesn't seem possible to delete students once you've sent them
3432 # (I think because other entities may have referenced them in the meantime)
You can’t perform that action at this time.
0 commit comments