API¶
Toolkit Object¶
-
class
itoolkit.
iToolKit
(iparm=0, iret=0, ids=1, irow=1)¶ Main iToolKit XMLSERVICE collector and output parser.
- Args:
- iparm (num): include xml node parm output (0-no, 1-yes). iret (num): include xml node return output (0-no, 1-yes). ids (num): include xml node ds output (0-no, 1-yes). irow (num): include xml node row output (0-no, 1-yes).
- Returns:
- iToolKit (obj)
-
add
(obj)¶ Add additional child object.
- Args:
- none
- Returns:
- none
- Notes:
- <?xml version=‘1.0’?> <xmlservice>
-
call
(itrans)¶ Call xmlservice with accumulated input XML.
- Args:
- itrans (obj): XMLSERVICE transport (iRestCall, iDB2Call, etc.)
- Returns:
- none
-
clear
()¶ Clear collecting child objects.
- Args:
- none
- Returns:
- (void)
- Notes:
- <?xml version=‘1.0’?> <xmlservice>
-
dict_out
(ikey=0)¶ return dict output.
- Args:
- ikey (str): select ‘key’ from {‘key’:’value’}.
- Returns:
- dict {‘key’:’value’}
-
hybrid_out
(ikey=0)¶ return hybrid output.
- Args:
- ikey (str): select ‘key’ from {‘key’:’value’}.
- Returns:
- hybrid {key:{‘data’:[list]}}
-
list_out
(ikey=-1)¶ return list output.
- Args:
- ikey (num): select list from index [[0],[1],,,,].
- Returns:
- list [value]
-
trace_close
()¶ End trace (1.2+)
- Args:
- none
- Returns:
- (void)
-
trace_hexdump
(itext)¶ Write trace hexdump (1.2+) Args:
itext (str): trace text- Returns:
- (void)
-
trace_open
(iname='*terminal')¶ Open trace *terminal or file /tmp/python_toolkit_(iname).log (1.2+)
- Args:
- iname (str): trace *terminal or file /tmp/python_toolkit_(iname).log
- Returns:
- (void)
-
trace_write
(itext)¶ Write trace text (1.2+)
- Args:
- itext (str): trace text
- Returns:
- (void)
-
xml_in
()¶ return raw xml input.
- Args:
- none
- Returns:
- xml
-
xml_out
()¶ return raw xml output.
- Args:
- none
- Returns:
- xml
Toolkit Operations¶
-
class
itoolkit.
iPgm
(ikey, iname, iopt={})¶ IBM i XMLSERVICE call *PGM.
- Args:
ikey (str): XML <ikey>…operation …</ikey> for parsing output. iname (str): IBM i *PGM or *SRVPGM name iopt (dict): option - dictionay of options (below)
{‘error’:’on|off|fast’} : optional - XMLSERVICE error choice {‘error’:’fast’} {‘func’:’MYFUNC’} : optional - IBM i *SRVPGM function export. {‘lib’:’mylib’} : optional - IBM i library name {‘mode’:’opm|ile’} : optional - XMLSERVICE error choice {‘mode’:’ile’}- Example:
iPgm(‘zzcall’,’ZZCALL’) .addParm(iData(‘var1’,‘1a’,’a’)) .addParm(iData(‘var2’,‘1a’,’b’)) .addParm(iData(‘var3’,‘7p4’,‘32.1234’)) .addParm(iData(‘var4’,‘12p2’,‘33.33’)) .addParm(
iDS(‘var5’) .addData(iData(‘d5var1’,‘1a’,’a’)) .addData(iData(‘d5var2’,‘1a’,’b’)) .addData(iData(‘d5var3’,‘7p4’,‘32.1234’)) .addData(iData(‘d5var4’,‘12p2’,‘33.33’)) )- Returns:
- iPgm (obj)
- Notes:
- pgm:
- <pgm name=’’
- [lib=’’
- func=’’ mode=’opm|ile’ error=’on|off|fast’ (1.7.6) ]> … </pgm>
-
add
(obj)¶ Additional mini dom xml child nodes.
- Args:
- obj (iBase) : additional child object
- Example:
itool = iToolKit() itool.add(
iPgm(‘zzcall’,’ZZCALL’) <— child of iToolkit .addParm(iData(‘INCHARA’,‘1a’,’a’)) <— child of iPgm )- Returns:
- (void)
-
addParm
(obj)¶ Add a parameter child node.
- Args:
- obj (obj): iData object or iDs object.
- Returns:
- (void)
-
make
()¶ Assemble coherent mini dom xml, including child nodes.
- Args:
- none
- Returns:
- xml.dom.minidom (obj)
-
xml_in
()¶ Return XML string of collected mini dom xml child nodes.
- Args:
- none
- Returns:
- XML (str)
-
class
itoolkit.
iSrvPgm
(ikey, iname, ifunc, iopt={})¶ IBM i XMLSERVICE call *SRVPGM.
- Args:
ikey (str): XML <ikey>…operation …</ikey> for parsing output. iname (str): IBM i *PGM or *SRVPGM name ifunc (str): IBM i *SRVPGM function export. iopt (dict): option - dictionay of options (below)
{‘error’:’on|off|fast’} : optional - XMLSERVICE error choice {‘error’:’fast’} {‘lib’:’mylib’} : optional - IBM i library name {‘mode’:’opm|ile’} : optional - XMLSERVICE error choice {‘mode’:’ile’}- Example:
- see iPgm
- Returns:
- iSrvPgm (obj)
- Notes:
- pgm:
- <pgm name=’’
- [lib=’’
- func=’’ mode=’opm|ile’ error=’on|off|fast’ (1.7.6) ]> … </pgm>
-
add
(obj)¶ Additional mini dom xml child nodes.
- Args:
- obj (iBase) : additional child object
- Example:
itool = iToolKit() itool.add(
iPgm(‘zzcall’,’ZZCALL’) <— child of iToolkit .addParm(iData(‘INCHARA’,‘1a’,’a’)) <— child of iPgm )- Returns:
- (void)
-
addParm
(obj)¶ Add a parameter child node.
- Args:
- obj (obj): iData object or iDs object.
- Returns:
- (void)
-
addRet
(obj)¶ Add a return structure child node.
- Args:
- obj (obj): iData object or iDs object.
- Returns:
- (void)
-
make
()¶ Assemble coherent mini dom xml, including child nodes.
- Args:
- none
- Returns:
- xml.dom.minidom (obj)
-
xml_in
()¶ Return XML string of collected mini dom xml child nodes.
- Args:
- none
- Returns:
- XML (str)
-
class
itoolkit.
iCmd
(ikey, icmd, iopt={})¶ IBM i XMLSERVICE call *CMD not returning *OUTPUT.
- Args:
ikey (str): XML <ikey>…operation …</ikey> for parsing output. icmd (str): IBM i command no output (see 5250 command prompt). iopt (dict): option - dictionay of options (below)
{‘error’:’on|off|fast’} : optional - XMLSERVICE error choice {‘error’:’fast’} {‘exec’:cmd|system|rexx’} : optional - XMLSERVICE command execute choice {‘exec’:’cmd’}
RTVJOBA CCSID(?N) {‘exec’:’rex’}- Example:
- iCmd(‘chglibl’, ‘CHGLIBL LIBL(XMLSERVICE) CURLIB(XMLSERVICE)’) iCmd(‘rtvjoba’, ‘RTVJOBA CCSID(?N) OUTQ(?)’)
- Returns:
- iCmd (obj)
- Notes:
- Special commands returning output parameters are allowed.
- (?) - indicate string return (?N) - indicate numeric return
- <cmd [exec=’cmd|system|rexx’ (default exec=’cmd’)
- hex=’on’ before=’cc1/cc2/cc3/cc4’ after=’cc4/cc3/cc2/cc1’ (1.6.8) error=’on|off|fast’ (1.7.6) ]>IBM i command</cmd>
-
add
(obj)¶ Additional mini dom xml child nodes.
- Args:
- obj (iBase) : additional child object
- Example:
itool = iToolKit() itool.add(
iPgm(‘zzcall’,’ZZCALL’) <— child of iToolkit .addParm(iData(‘INCHARA’,‘1a’,’a’)) <— child of iPgm )- Returns:
- (void)
-
make
()¶ Assemble coherent mini dom xml, including child nodes.
- Args:
- none
- Returns:
- xml.dom.minidom (obj)
-
xml_in
()¶ Return XML string of collected mini dom xml child nodes.
- Args:
- none
- Returns:
- XML (str)
-
class
itoolkit.
iCmd5250
(ikey, icmd, iopt={})¶ IBM i XMLSERVICE call 5250 *CMD returning *OUTPUT.
- Args:
ikey (str): XML <ikey>…operation …</ikey> for parsing output. icmd (str): IBM i PASE script/utility (see call qp2term). iopt (dict): option - dictionay of options (below)
{‘error’:’on|off|fast’} : optional - XMLSERVICE error choice {‘error’:’fast’} {‘row’:’on|off’} : optional - XMLSERVICE <row>line output</row> choice {‘row’:’off’}- Example:
- iCmd5250(‘dsplibl’,’dsplibl’) iCmd5250(‘wrkactjob’,’wrkactjob’)
- Returns:
- iCmd5250 (obj)
- Notes:
This is a subclass of iSh, therefore XMLSERVICE perfoms standard PASE shell popen fork/exec calls.
/QOpenSys/usr/bin/system ‘wrkactjob’
Please note, this is a relatively slow operation, use sparingly on high volume web sites.
- <sh [rows=’on|off’
- hex=’on’ before=’cc1/cc2/cc3/cc4’ after=’cc4/cc3/cc2/cc1’ (1.7.4) error=’on|off|fast’ (1.7.6) ]>(PASE utility)</sh>
-
add
(obj)¶ Additional mini dom xml child nodes.
- Args:
- obj (iBase) : additional child object
- Example:
itool = iToolKit() itool.add(
iPgm(‘zzcall’,’ZZCALL’) <— child of iToolkit .addParm(iData(‘INCHARA’,‘1a’,’a’)) <— child of iPgm )- Returns:
- (void)
-
make
()¶ Assemble coherent mini dom xml, including child nodes.
- Args:
- none
- Returns:
- xml.dom.minidom (obj)
-
xml_in
()¶ Return XML string of collected mini dom xml child nodes.
- Args:
- none
- Returns:
- XML (str)
-
class
itoolkit.
iSh
(ikey, icmd, iopt={})¶ IBM i XMLSERVICE call PASE utilities.
- Args:
ikey (str): XML <ikey>…operation …</ikey> for parsing output. icmd (str): IBM i PASE script/utility (see call qp2term). iopt (dict): option - dictionay of options (below)
{‘error’:’on|off|fast’} : optional - XMLSERVICE error choice {‘error’:’fast’} {‘row’:’on|off’} : optional - XMLSERVICE <row>line output</row> choice {‘row’:’off’}- Example:
- iSh(‘ls /home/xml/master | grep -i xml’)
- Returns:
- iSh (obj)
- Notes:
XMLSERVICE perfoms standard PASE shell popen calls, therefore, additional job will be forked, utilities will be exec’d, and stdout will be collected to be returned.
Please note, this is a relatively slow operation, use sparingly on high volume web sites.
- <sh [rows=’on|off’
- hex=’on’ before=’cc1/cc2/cc3/cc4’ after=’cc4/cc3/cc2/cc1’ (1.7.4) error=’on|off|fast’ (1.7.6) ]>(PASE utility)</sh>
-
add
(obj)¶ Additional mini dom xml child nodes.
- Args:
- obj (iBase) : additional child object
- Example:
itool = iToolKit() itool.add(
iPgm(‘zzcall’,’ZZCALL’) <— child of iToolkit .addParm(iData(‘INCHARA’,‘1a’,’a’)) <— child of iPgm )- Returns:
- (void)
-
make
()¶ Assemble coherent mini dom xml, including child nodes.
- Args:
- none
- Returns:
- xml.dom.minidom (obj)
-
xml_in
()¶ Return XML string of collected mini dom xml child nodes.
- Args:
- none
- Returns:
- XML (str)
-
class
itoolkit.
iXml
(ixml)¶ IBM i XMLSERVICE raw xml input.
- Args:
- ixml (str): custom XML for XMLSERVICE operation.
- Example:
- iXml(“<cmd>CHGLIBL LIBL(XMLSERVICE)</cmd>”) iXml(“<sh>ls /tmp</sh>”)
- Returns:
- iXml (obj)
- Notes:
- Not commonly used, but ok when other classes fall short.
-
add
(obj)¶ add input not allowed.
- Returns:
- raise except
-
make
()¶ Assemble coherent mini dom xml.
- Args:
- none
- Returns:
- xml.dom.minidom (obj)
-
xml_in
()¶ Return XML string of collected mini dom xml child nodes.
- Args:
- none
- Returns:
- XML (str)
-
class
itoolkit.
iDS
(ikey, iopt={})¶ Data structure child node for iPgm, iSrvPgm, or nested iDS data structures.
- Args:
ikey (str): XML <ds … var=”ikey”> for parsing output. iopt (dict): option - dictionay of options (below)
{‘dim’:’n’} : optional - XMLSERVICE dimension/occurs number. {‘dou’:’label’} : optional - XMLSERVICE do until label. {‘len’:’label’} : optional - XMLSERVICE calc length label.- Example:
- see iPgm
- Returns:
- iDS (obj)
- Notes:
- pgm data structure:
- <ds [dim=’n’ dou=’label’
- len=’label’ (1.5.4) data=’records’ (1.7.5) ]>(see <data>)</ds>
-
add
(obj)¶ Additional mini dom xml child nodes.
- Args:
- obj (iBase) : additional child object
- Example:
itool = iToolKit() itool.add(
iPgm(‘zzcall’,’ZZCALL’) <— child of iToolkit .addParm(iData(‘INCHARA’,‘1a’,’a’)) <— child of iPgm )- Returns:
- (void)
-
addData
(obj)¶ Add a iData or iDS child node.
- Args:
- obj (obj): iData object or iDs object.
- Returns:
- (void)
-
make
()¶ Assemble coherent mini dom xml, including child nodes.
- Args:
- none
- Returns:
- xml.dom.minidom (obj)
-
xml_in
()¶ Return XML string of collected mini dom xml child nodes.
- Args:
- none
- Returns:
- XML (str)
-
class
itoolkit.
iData
(ikey, itype, ival, iopt={})¶ Data value child node for iPgm, iSrvPgm, or iDS data structures.
- Args:
ikey (str): XML <data … var=”ikey”> for parsing output. iparm (obj): dom for parameter or return or ds. itype (obj): data type [see XMLSERVICE types, ‘3i0’, …]. ival (obj): data type value. iopt (dict): option - dictionay of options (below)
{‘dim’:’n’} : optional - XMLSERVICE dimension/occurs number. {‘varying’:’on|off|2|4’} : optional - XMLSERVICE varying {‘varying’:’off’}. {‘hex’:’on|off’} : optional - XMLSERVICE hex chracter data {‘hex’:’off’}. {‘enddo’:’label’} : optional - XMLSERVICE enddo until label. {‘setlen’:’label’} : optional - XMLSERVICE set calc length label. {‘offset’:’n’} : optional - XMLSERVICE offset label. {‘next’:’label’} : optional - XMLSERVICE next offset label (value).- Example:
- see iPgm
- Returns:
- iData (obj)
- Notes:
- pgm data elements:
- <data type=’data types’
- [dim=’n’
- varying=’on|off|2|4’ enddo=’label’ setlen=’label’ (1.5.4) offset=’label’ hex=’on|off’ before=’cc1/cc2/cc3/cc4’ after=’cc4/cc3/cc2/cc1’ (1.6.8) trim=’on|off’ (1.7.1) next=’nextoff’ (1.9.2) ]>(value)</data>
C types RPG types XMLSERVICE types SQL types =============== ============================ ================================================ ========= int8/byte D myint8 3i 0 <data type=‘3i0’/> TINYINT (unsupported DB2) int16/short D myint16 5i 0 (4b 0) <data type=‘5i0’/> SMALLINT int32/int D myint32 10i 0 (9b 0) <data type=‘10i0’/> INTEGER int64/longlong D myint64 20i 0 <data type=‘20i0’/> BIGINT uint8/ubyte D myuint8 3u 0 <data type=‘3u0’/> uint16/ushort D myuint16 5u 0 <data type=‘5u0’/> uint32/uint D myuint32 10u 0 <data type=‘10u0’/> uint64/ulonglong D myuint64 20u 0 <data type=‘20u0’/> char D mychar 32a <data type=‘32a’/> CHAR(32) varchar2 D myvchar2 32a varying <data type=‘32a’ varying=’on’/> VARCHAR(32) varchar4 D myvchar4 32a varying(4) <data type=‘32a’ varying=‘4’/> packed D mydec 12p 2 <data type=‘12p2’/> DECIMAL(12,2) zoned D myzone 12s 2 <data type=’12s2’/> NUMERIC(12,2) float D myfloat 4f <data type=‘4f2’/> FLOAT real/double D myreal 8f <data type=‘8f4’/> REAL binary D mybin (any) <data type=‘9b’>F1F2F3</data> BINARY hole (no out) D myhole (any) <data type=‘40h’/> boolean D mybool 1n <data type=‘4a’/> CHAR(4) time D mytime T timfmt(*iso) <data type=‘8A’>09.45.29</data> TIME timestamp D mystamp Z <data type=‘26A’>2011-12-29-12.45.29.000000</data> TIMESTAMP date D mydate D datfmt(*iso) <data type=‘10A’>2009-05-11</data> DATE
-
add
(obj)¶ Additional mini dom xml child nodes.
- Args:
- obj (iBase) : additional child object
- Example:
itool = iToolKit() itool.add(
iPgm(‘zzcall’,’ZZCALL’) <— child of iToolkit .addParm(iData(‘INCHARA’,‘1a’,’a’)) <— child of iPgm )- Returns:
- (void)
-
make
()¶ Assemble coherent mini dom xml, including child nodes.
- Args:
- none
- Returns:
- xml.dom.minidom (obj)
-
xml_in
()¶ Return XML string of collected mini dom xml child nodes.
- Args:
- none
- Returns:
- XML (str)
Transports¶
HTTP Transport¶
-
class
itoolkit.rest.irestcall.
iRestCall
(iurl, iuid, ipwd=0, idb2=0, ictl=0, ipc=0, isiz=0)¶ Transport XMLSERVICE calls over standard HTTP rest.
- Args:
iurl (str): XMLSERVICE url (https://common1.frankeni.com:47700/cgi-bin/xmlcgi.pgm). iuid (str): Database user profile name ipwd (str): optional - Database user profile password
– or – env var PASSWORD (export PASSWORD=mypass)idb2 (str): optional - Database (WRKRDBDIRE *LOCAL) ictl (str): optional - XMLSERVICE control [‘*here’,’*sbmjob’] ipc (str): optional - XMLSERVICE xToolkit job route for *sbmjob [‘/tmp/myunique42’] isiz (str): optional - XMLSERVICE expected max XML output size, required for DB2
- Example:
- from itoolkit.rest.irestcall import * itransport = iRestCall(url,user,password)
- Returns:
- none
-
call
(itool)¶ Call xmlservice with accumulated input XML.
- Args:
- itool - iToolkit object
- Returns:
- xml
-
trace_data
()¶ Return trace driver data.
- Args:
- none
- Returns:
- initialization data
Database Transport¶
-
class
itoolkit.db2.idb2call.
iDB2Call
(iuid, ipwd=0, idb2=0, ictl=0, ipc=0, isiz=0, ilib=0)¶ Transport XMLSERVICE calls over DB2 connection.
- Args:
iuid (str): Database user profile name or database connection ipwd (str): optional - Database user profile password
– or – env var PASSWORD (export PASSWORD=mypass)idb2 (str): optional - Database (WRKRDBDIRE *LOCAL) ictl (str): optional - XMLSERVICE control [‘*here’,’*sbmjob’] ipc (str): optional - XMLSERVICE xToolkit job route for *sbmjob [‘/tmp/myunique42’] isiz (int): optional - XMLSERVICE expected max XML output size, required for DB2 ilib (str): optional - XMLSERVICE library compiled (default QXMLSERV)
- Example:
- from itoolkit.db2.idb2call import * itransport = iDB2Call(user,password) – or – conn = ibm_db.connect(database, user, password) itransport = iDB2Call(conn)
- Returns:
- (obj)
-
call
(itool)¶ Call xmlservice with accumulated input XML.
- Args:
- itool - iToolkit object
- Returns:
- xml
-
trace_data
()¶ Return trace driver data.
- Args:
- none
- Returns:
- initialization data
Direct Memory Transport¶
-
class
itoolkit.lib.ilibcall.
iLibCall
(ictl=0, ipc=0, iccsid=0, pccsid=0)¶ Transport XMLSERVICE direct job call (within job/process calls).
- Args:
- ictl (str): optional - XMLSERVICE control [‘*here’,’*sbmjob’] ipc (str): optional - XMLSERVICE xToolkit job route for *sbmjob [‘/tmp/myunique42’] iccsid (int): optional - XMLSERVICE EBCDIC CCSID [0,37,…] 0 = default jobccsid (1.2+) pccsid (int): optional - XMLSERVICE ASCII CCSID [0,1208, …] 0 = default 1208 (1.2+)
- Returns:
- none
-
call
(itool)¶ Call xmlservice with accumulated input XML.
- Args:
- itool - iToolkit object
- Returns:
- xml
-
trace_data
()¶ Return trace driver data.
- Args:
- none
- Returns:
- initialization data