#!/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))

[((263, 311), 'TE.Net.setAppTokenFromEnvName', 'TE.Net.setAppTokenFromEnvName', (['"""TX_ACCESS_TOKEN"""'], {}), "('TX_ACCESS_TOKEN')\n", (292, 311), False, 'import TE\n'), ((537, 596), 'TE.Net.updateThreatDescriptor', 'TE.Net.updateThreatDescriptor', (['postParams', 'showURLs', 'dryRun'], {}), '(postParams, showURLs, dryRun)\n', (566, 596), False, 'import TE\n'), ((643, 690), 'sys.stderr.write', 'sys.stderr.write', (["(validationErrorMessage + '\\n')"], {}), "(validationErrorMessage + '\\n')\n", (659, 690), False, 'import sys\n'), ((695, 706), 'sys.exit', 'sys.exit', (['(1)'], {}), '(1)\n', (703, 706), False, 'import sys\n'), ((844, 855), 'sys.exit', 'sys.exit', (['(1)'], {}), '(1)\n', (852, 855), False, 'import sys\n'), ((863, 887), 'json.dumps', 'json.dumps', (['responseBody'], {}), '(responseBody)\n', (873, 887), False, 'import json\n'), ((807, 831), 'json.dumps', 'json.dumps', (['responseBody'], {}), '(responseBody)\n', (817, 831), False, 'import json\n')]