@@ -214,7 +214,7 @@ def key_exists(self, in_dict: dict, key: str):
214214 else :
215215 return False
216216
217- def backup_policies (self , backups_path : str ):
217+ def backup_policies (self , backups_path : str , type : str = None ):
218218 """
219219 Back up all OneFuse policies from the OneFuse instance used when
220220 instantiating the OneFuseBackups class
@@ -225,9 +225,21 @@ def backup_policies(self, backups_path: str):
225225 Path to back the files up to. Examples:
226226 Windows: 'C:\\ temp\\ onefuse_backups\\ '
227227 Linux: '/tmp/onefuse_backups/'
228+ type: str
229+ Optional type. Will backup all "policies" of the given type
230+ or raise an error if the parameter passed is not valid.
228231 """
229232 # Gather policies from OneFuse, store them under BACKUPS_PATH
230- for policy_type in self .policy_types :
233+ policy_types = self .policy_types
234+ if type :
235+ if type in policy_types :
236+ policy_types = [type ]
237+ else :
238+ error_string = (
239+ f"Type not found. Type '{ type } ' should be oe of { policy_types } "
240+ )
241+ raise OneFuseError (error_string )
242+ for policy_type in policy_types :
231243 self .ofm .logger .info (f'Backing up policy_type: { policy_type } ' )
232244 response = self .ofm .get (f'/{ policy_type } /' )
233245 next_exists = self .create_json_files (response , policy_type ,
0 commit comments