Skip to content

Commit

Permalink
Modify the build_payload function, check for more use cases under upd…
Browse files Browse the repository at this point in the history
…ate and create
  • Loading branch information
TraciebelWairimu committed Feb 2, 2024
1 parent 195ad6b commit ab948ac
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions importer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,17 +467,27 @@ def build_payload(resource_type, resources, resource_payload_file):

for resource in resources:
try:
if resource[2] == "update":
# use the provided id
unique_uuid = resource[4]
identifier_uuid = resource[4] if resource[5] == "" else resource[5]
else:
# generate a new uuid
unique_uuid = str(uuid.uuid4())
identifier_uuid = unique_uuid
if resource[2] == "create":
if len(resource[4].strip()) > 0:
# use the provided id
unique_uuid = resource[4].strip()
identifier_uuid = resource[4] if resource[5] == "" else resource[5]
else:
# generate a new uuid
unique_uuid = str(uuid.uuid5(uuid.NAMESPACE_DNS, resource[0]))
identifier_uuid = unique_uuid
elif resource[2] == "update":
if len(resource[4].strip()) > 0:
# use the provided id
unique_uuid = resource[4].strip()
identifier_uuid = resource[4] if resource[5] == "" else resource[5]
else:
# generate a new uuid
unique_uuid = str(uuid.uuid5(uuid.NAMESPACE_DNS, resource[0]))
identifier_uuid = unique_uuid
except IndexError:
# default if method is not provided
unique_uuid = str(uuid.uuid4())
unique_uuid = str(uuid.uuid5(uuid.NAMESPACE_DNS, resource[0]))
identifier_uuid = unique_uuid

# ps = payload_string
Expand Down

0 comments on commit ab948ac

Please sign in to comment.