TACTIC Python API
Setting up
If you haven't done so, please review Client API Setup Doc.
Starting
The primary library for running using the TACTIC API which contains all of the
API functions is tactic_client_lib
.
from tactic_client_lib import TactiServerStub
The following may also be required for python to recognize any of the python classes. It sets up the TACTIC environment.
import tacticenv
Pinging the server
from tactic_client_lib import TacticServerStub
def main():
server = TacticServerStub()
server.start("Ping Test")
try:
print(server.ping())
except:
server.abort()
raise
else:
server.finish()
if __name__ == '__main__':
main()
Executing this script will give the following output:
$ python3 examples/ping.py
OK
Querying data
The most fundamental operation in the Client API is the query function, which enables access to direct information on an sObject.
The following example illustrates the use of the query function:
# define the search type we are searching for
search_type = "workflow/job"
# define a filter
filters = []
# do the query
jobs = server.query(search_type, filters)
print("Found %d jobs" % len(jobs))
# go through the asset and print the code
for job in jobs:
code = job.get("code")
print(code)
In the example above, a search_type is first defined. This search type is a uniquely named identifier for a class of sObjects.
A list of filters is next defined. These filters allow you to narrow the search to specific sObjects.
Next, the jobs are retrieved using the query() function, which returns a list where each element is a serialized dictionary of an sObject. In this example, the code for each job is retrieved and printed.
More examples
For more examples, please look at the Client API Docs.