Skip to content

Commit

Permalink
Merge pull request #2 from collin-wicker/develop
Browse files Browse the repository at this point in the history
Merging changes made for linting tests
  • Loading branch information
collin-wicker authored Nov 7, 2023
2 parents a8850a2 + 9ecff49 commit c3a8bf4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions nautobot_ssot/integrations/servicenow/diffsync/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def map_data_to_sn_record(self, data, mapping_entry, existing_record=None, clear
column_name = mapping["reference"]["column"]
if value is not None:
# if clear_cache is set to True then clear the cache for the object
if clear_cache==True:
if clear_cache:
self._sys_id_cache.setdefault(tablename, {}).setdefault(column_name, {})[value] = {}
# Look in the cache first
sys_id = self._sys_id_cache.get(tablename, {}).get(column_name, {}).get(value, None)
Expand Down Expand Up @@ -85,7 +85,7 @@ def update(self, attrs):
return self

def delete(self):
"""Delete an existing instance in ServiceNow if it does not exist in Nautobot. This code adds the ServiceNow object to the objects_to_delete[object_class] list. The actual delete occurs in the post-run method of adapter_servicenow.py."""
"""Delete an existing instance in ServiceNow if it does not exist in Nautobot. This code adds the ServiceNow object to the objects_to_delete dict of lists. The actual delete occurs in the post-run method of adapter_servicenow.py."""
entry = self.diffsync.mapping_data[self.get_type()]
sn_resource = self.diffsync.client.resource(api_path=f"/table/{entry['table']}")
query = self.map_data_to_sn_record(data=self.get_identifiers(), mapping_entry=entry)
Expand All @@ -100,7 +100,9 @@ def delete(self):
self.diffsync.job.logger.warning(f"{self._modelname} {self.get_identifiers()} will be deleted.")
_object = sn_resource.get(query=query)
self.diffsync.objects_to_delete[self._modelname].append(_object)
self.map_data_to_sn_record(data=self.get_identifiers(), mapping_entry=entry, clear_cache=True) # remove device cache
self.map_data_to_sn_record(
data=self.get_identifiers(), mapping_entry=entry, clear_cache=True
) # remove device cache
super().delete()
return self

Expand Down

0 comments on commit c3a8bf4

Please sign in to comment.