@@ -473,7 +473,7 @@ def export_pluggable_module(self, module_name: str, save_path: str,
473473 os .remove (file_path )
474474 else :
475475 raise OneFuseError (f'Zip file already exists for module_name: '
476- f'{ module_name } in save_path: { save_path } ' )
476+ f'{ module_name } in save_path: { save_path } ' )
477477 with open (file_path , 'wb' ) as fd :
478478 for chunk in response .iter_content (chunk_size = 128 ):
479479 fd .write (chunk )
@@ -1339,6 +1339,56 @@ def get_onefuse_instance_id(self):
13391339 f'1.4' )
13401340 return None
13411341
1342+ def ingest_name (self , policy_name : str , name : str ,
1343+ dns_suffix : str = "" , tracking_id : str = "" ):
1344+ """
1345+ Ingest an existing name to OneFuse - the policy will not execute but
1346+ an object will be added to the OneFuse database.
1347+
1348+ Parameters
1349+ ----------
1350+ policy_name : str
1351+ OneFuse Custom Naming Policy Name
1352+ name : str
1353+ Name for the Name object, typically a hostname
1354+ dns_suffix : str
1355+ Value for the DNS Suffix. Ex: 'example.com'
1356+ tracking_id : str - optional
1357+ OneFuse Tracking ID. If not passed, one will be returned from the
1358+ execution. Tracking IDs allow for grouping all executions for a
1359+ single object
1360+ """
1361+ # Get Naming Policy by Name
1362+ policy_path = 'namingPolicies'
1363+ policy_json = self .get_policy_by_name (policy_path , policy_name )
1364+ links = policy_json ["_links" ]
1365+ policy_url = links ["self" ]["href" ]
1366+ workspace_url = links ["workspace" ]["href" ]
1367+ # Ingest Name
1368+ template = {
1369+ "policy" : policy_url ,
1370+ "workspace" : workspace_url ,
1371+ "name" : name ,
1372+ "dnsSuffix" : dns_suffix
1373+ }
1374+ path = "/customNames/ingest/"
1375+ response_json = self .request (path , template , tracking_id )
1376+ return response_json
1377+
1378+ def delete_ingested_name (self , id : str ):
1379+ """
1380+ Delete an ingested name from OneFuse - The deleted object will be
1381+ removed from the OneFuse database without deprovisioning.
1382+
1383+ Parameters
1384+ ----------
1385+ id : str
1386+ ID for the Name object
1387+ """
1388+ path = f"/customNames/{ id } /ingest/"
1389+ response_json = self .deprovision_mo (path )
1390+ return response_json
1391+
13421392
13431393if __name__ == '__main__' :
13441394 username = sys .argv [1 ] # 'OneFuse Username'
0 commit comments