Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
)
schema = xsd.Schema(node)
element = schema.get_element("ns0:ElementName")
elm = element(item_1="foo", item_2="bar")
assert serialize_object(elm) == {
"item_3": None,
"item_2": "bar",
"item_1": "foo",
"item_4": None,
"nee": None,
}
elm.item_1 = "bla-1"
elm.item_2 = "bla-2"
expected = """
bla-1
bla-2
def list_custom_attributes_command(client: Client) -> Tuple[str, dict, dict]:
raw_custom_attributes_list = client.service.listCustomAttributes()
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_custom_attributes_list:
custom_attributes_list = helpers.serialize_object(raw_custom_attributes_list)
raw_response = custom_attributes_list
outputs: list = [{'Custom Attribute': custom_attribute} for custom_attribute in custom_attributes_list]
human_readable = tableToMarkdown('Symantec DLP custom attributes', outputs, removeNull=True)
else:
human_readable = 'No custom attributes found.'
return human_readable, entry_context, raw_response
:param fetch_time: For the first time the integration is enabled with the fetch incidents functionality, the fetch
time indicates from what time to start fetching existing incidents in Symantec DLP system.
:param fetch_limit: Indicates how many incidents to fetch every minute
:param last_run: Demisto last run object
:param saved_report_id: The report ID to retrive the incidents from
:return: A list of Demisto incidents
"""
# We use parse to get out time in datetime format and not iso, that's what Symantec DLP is expecting to get
if last_run and last_run.get('last_fetched_event_iso'):
last_update_time = parse(last_run['last_fetched_event_iso'])
else:
last_update_time = parse_date_range(fetch_time)[0]
incidents = []
incidents_ids = helpers.serialize_object(client.service.incidentList(
savedReportId=saved_report_id,
incidentCreationDateLaterThan=last_update_time
)).get('incidentId', '')
if incidents_ids:
last_incident_time: str = ''
for incident_id in incidents_ids:
if fetch_limit == 0:
break
fetch_limit -= 1
incident_details = json.loads(json.dumps(helpers.serialize_object(client.service.incidentDetail(
incidentId=incident_id
)[0]), default=datetime_to_iso_format))
incident_creation_time = incident_details.get('incident', {}).get('incidentCreationDate')
incident: dict = {
'rawJSON': incident_details,
def test_module(client: Client, saved_report_id: int):
"""
Performs basic get request to get item samples
"""
helpers.serialize_object(client.service.incidentList(
savedReportId=saved_report_id,
incidentCreationDateLaterThan=parse_date_range('1 year')[0]
))
demisto.results('ok')
def get_signed_doc_info(self):
response = self.__invoke('GetSignedDocInfo')
response_dict = serialize_object(response['SignedDocInfo'])
return SignedDocInfo.from_dict(response_dict)
def _post_exec(self, result):
"""Converts the result object into a format that's acceptable to
StackStorm. The results returned by zeep are custom object types
that are not compatible with StackStorm. In order to return
meaningful data from our operations we must convert them to
python built-in datatypes (strings, ints, lists, dicts).
:param result: the potentially incompatible result object
:returns: a StackStorm compatible result object
"""
result_dict = zeep.helpers.serialize_object(result, target_cls=dict)
return result_dict
'AVERAGE_CPC': lambda x: zeep.helpers.serialize_object(x)['microAmount'],
'COMPETITION': lambda x: x,
def _convert_instance(value):
if isinstance(value, CompoundValue):
value = serialize_object(value)
if isinstance(value, (dict, OrderedDict)):
return cls(**prepare_kwargs(value))
return value