Skip to content

Commit

Permalink
APP-4334 make processing for method for transform for single value ma…
Browse files Browse the repository at this point in the history
…tch that of multiple values (#324)

APP-4334 make processing for method for transform for single value match that of multiple value
  • Loading branch information
cblades-tc authored Feb 15, 2024
1 parent c52270f commit 09483a0
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tcex/api/tc/ti_transform/transform_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from collections.abc import Callable
from datetime import datetime
from inspect import signature
from typing import Any
from typing import Any, cast

# third-party
import jmespath
Expand Down Expand Up @@ -157,6 +157,7 @@ def _process(self):
self._process_security_labels(self.transform.security_labels or [])
self._process_tags(self.transform.tags or [])

# date fields
# date fields
self._process_metadata_datetime('dateAdded', self.transform.date_added)
self._process_metadata_datetime('lastModified', self.transform.last_modified)
Expand All @@ -167,6 +168,13 @@ def _process(self):
self._process_metadata_datetime(
'externalLastModified', self.transform.external_last_modified
)
self._process_metadata_datetime('firstSeen', self.transform.first_seen)
self._process_metadata_datetime('lastSeen', self.transform.first_seen)
self._process_metadata_datetime('externalDateAdded', self.transform.external_date_added)
self._process_metadata_datetime('externalDateExpires', self.transform.external_date_expires)
self._process_metadata_datetime(
'externalLastModified', self.transform.external_last_modified
)

# xid
self._process_metadata('xid', self.transform.xid)
Expand Down Expand Up @@ -466,12 +474,12 @@ def _transform_value(self, metadata: MetadataTransformModel | None) -> str | Non

for t in metadata.transform or []:
# pass value to static_map or callable, but never both
if isinstance(value, str):
if t.filter_map is not None:
value = self._transform_value_map(value, t.filter_map, True)
elif t.static_map is not None:
value = self._transform_value_map(value, t.static_map)
elif value is not None and callable(t.method):
value = cast(Any, value) # due to line 472, we know value is not None.
if t.filter_map is not None:
value = self._transform_value_map(value, t.filter_map, True)
elif t.static_map is not None:
value = self._transform_value_map(value, t.static_map)
elif callable(t.method):
value = self._transform_value_callable(value, t.method, t.kwargs)

# ensure only a string value or None is returned (set to default if required)
Expand Down

0 comments on commit 09483a0

Please sign in to comment.