#!/usr/bin/env python

# ================================================================
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# ================================================================

import sys
import json
import TE

TE.Net.setAppTokenFromEnvName("TX_ACCESS_TOKEN")

postParams = {
    "descriptor_id": "4036655176350945",  # ID of the descriptor to be updated
    "reactions": "INGESTED,IN_REVIEW",
}

showURLs = False
dryRun = False
validationErrorMessage, serverSideError, responseBody = TE.Net.updateThreatDescriptor(
    postParams, showURLs, dryRun
)

if validationErrorMessage != None:
    sys.stderr.write(validationErrorMessage + "\n")
    sys.exit(1)

if serverSideError != None:
    sys.stderr.write(str(serverSideError) + "\n")
    sys.stderr.write(json.dumps(responseBody) + "\n")
    sys.exit(1)

print(json.dumps(responseBody))

[((11, 0, 11, 48), 'TE.Net.setAppTokenFromEnvName', 'TE.Net.setAppTokenFromEnvName', ({(11, 30, 11, 47): '"""TX_ACCESS_TOKEN"""'}, {}), "('TX_ACCESS_TOKEN')", False, 'import TE\n'), ((20, 56, 22, 1), 'TE.Net.updateThreatDescriptor', 'TE.Net.updateThreatDescriptor', ({(21, 4, 21, 14): 'postParams', (21, 16, 21, 24): 'showURLs', (21, 26, 21, 32): 'dryRun'}, {}), '(postParams, showURLs, dryRun)', False, 'import TE\n'), ((25, 4, 25, 51), 'sys.stderr.write', 'sys.stderr.write', ({(25, 21, 25, 50): "(validationErrorMessage + '\\n')"}, {}), "(validationErrorMessage + '\\n')", False, 'import sys\n'), ((26, 4, 26, 15), 'sys.exit', 'sys.exit', ({(26, 13, 26, 14): '(1)'}, {}), '(1)', False, 'import sys\n'), ((31, 4, 31, 15), 'sys.exit', 'sys.exit', ({(31, 13, 31, 14): '(1)'}, {}), '(1)', False, 'import sys\n'), ((33, 6, 33, 30), 'json.dumps', 'json.dumps', ({(33, 17, 33, 29): 'responseBody'}, {}), '(responseBody)', False, 'import json\n'), ((30, 21, 30, 45), 'json.dumps', 'json.dumps', ({(30, 32, 30, 44): 'responseBody'}, {}), '(responseBody)', False, 'import json\n')]