Package: iotiumlib
_       _   _                 _ _ _     
(_)     | | (_)               | (_) |    
 _  ___ | |_ _ _   _ _ __ ___ | |_| |__  
| |/ _ \| __| | | | | '_ ` _ \| | | '_ \ 
| | (_) | |_| | |_| | | | | | | | | |_) |
|_|\___/ \__|_|\__,_|_| |_| |_|_|_|_.__/Definition and UsageTheiotiumlibmodule allows you to access ioTium Orchestrator using APIs in Python.Download and Installpip install iotiumlibOrgiotiumlib.org.methodname(params)MethodRequired ParamsOptional ParamsgetNAorg_idgetv2NAfiltersaddorg_name, billing_name, billing_emaildomain_name, timezone, headless_mode, two_factor, vlan_supportdeleteorg_idreturns aResponseObject with all the response data (output, code, formattedOutput).Nodeiotiumlib.node.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersaddinode_name, serial_number, profile_idstandalone_expires, label, data_saving_mode, ssh_keyseditnode_idinode_name, label, standalone_expires, data_saving_mode, ssh_keysdeletenode_idNArebootnode_idNAnotificationsnode_idtype, filtersreturns aResponseObject with all the response data (output, code, formattedOutput).
Empty string in serial_number creates Virtual iNode.Node.trafficinsightiotiumlib.node.trafficinsight.methodname(params)MethodRequired ParamsOptional Paramsenablenode_idsampling_frequency, threat_detection_enabledisablenode_idNAgetnode_idNAisEnablednode_idNAreturns aResponseObject with all the response data (output, code, formattedOutput).Clusteriotiumlib.cluster.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersgetcluster_idNAaddnamelabels, nodes, container_timezone, instance_id, election_network_typeeditcluster_idname, labels, nodes, container_timezone, instance_id, election_network_type, election_network_iddeletecluster_idNAupgradecluster_idpolicyreturns aResponseObject with all the response data (output, code, formattedOutput).
Empty string in serial_number creates Virtual iNode.Cluster.trafficinsightiotiumlib.cluster.trafficinsight.methodname(params)MethodRequired ParamsOptional Paramsenablecluster_idsampling_frequency, threat_detection_enabledisablecluster_idNAgetcluster_idNAisEnabledcluster_idNAreturns aResponseObject with all the response data (output, code, formattedOutput).SSH Keyiotiumlib.sshkey.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersaddname, public_keydeletesshkey_idreturns aResponseObject with all the response data (output, code, formattedOutput).PKIiotiumlib.pki.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersreturns aResponseObject with all the response data (output, code, formattedOutput).Profileiotiumlib.profile.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersreturns aResponseObject with all the response data (output, code, formattedOutput).Networkiotiumlib.network.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersaddnetwork_name, node_idcidr,  start_ip, gateway_ip, end_ip, label, default_destination, connect_networks, firewall_selector, vlan_id, network_addressing, firewall_policy, service_addressing, static_routes, interface_ipeditnetwork_idnetwork_name, cidr, gateway_ip, start_ip, end_ip, label, default_destination, connect_networks, firewall_selector,  vlan_id, firewall_policy, static_routes, interface_ipdeletenetwork_idfirewall_policy, service_addressing, static_routesresetcounternetwork_idreturns aResponseObject with all the response data (output, code, formattedOutput).Firewalliotiumlib.firewall.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersaddname, org_id, ruleslabeleditfirewallgroup_idname, label, edit_rulesdeletefirewallgroup_idNAreturns aResponseObject with all the response data (output, code, formattedOutput).Serviceiotiumlib.service.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersgetv2_templateNAfiltersaddpayloadeditservice_id, payloadNAdeleteservice_idNAreturns aResponseObject with all the response data (output, code, formattedOutput).Secretiotiumlib.secret.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersaddname, filenametypeeditsecret_idname, filenamedeletesecret_idNAreturns aResponseObject with all the response data (output, code, formattedOutput).Useriotiumlib.user.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersaddname, email, password, roleNAedituser_idname, roledeleteuser_idNAnotificationsNAorg_id, node_id, type, filtersreturns aResponseObject with all the response data (output, code, formattedOutput).iotiumlib.user.mysubscriptions.methodname(params)MethodRequired ParamsOptional Paramsgetv2NAfiltersaddalert_name, type, org_idnode_id, include_child, duration pod_id, network_id, tunnel_iddeletesub_idNAreturns aResponseObject with all the response data (output, code, formattedOutput).Package Helper Functionsiotiumlib.helper.get_resource_id_by_name(resource, argument)ResourceArgumentiotiumlib.nodenode_nameiotiumlib.networknetwork_nameiotiumlib.serviceservice_nameiotiumlib.secretsecret_nameiotiumlib.profileprofile_nameiotiumlib.orgorg_nameiotiumlib.firewallcsp_nameiotiumlib.useruser_nameiotiumlib.org.mysubscriptionsalert_nameiotiumlib.helper.get_resource_name_by_id(resource, argument)ResourceArgumentiotiumlib.nodenode_idiotiumlib.networknetwork_idiotiumlib.servicepod_idiotiumlib.secretsecret_idiotiumlib.profileprofile_idiotiumlib.orgorg_idiotiumlib.firewallcsp_idiotiumlib.useruser_idiotiumlib.org.mysubscriptionsalert_idiotiumlib.helper.get_all_networks_from_node(name)iotiumlib.helper.get_resource_by_label(resource, labelname)Python example## Importing the Libraryimportiotiumlib# Login to Orchestartoriotiumlib.orch.ip="OrchHostIp"# Orchestrator IPrespObj=iotiumlib.orchlogin.login("useremail@domain.io","password")# Getting the Tokeniotiumlib.orch.token=respObj.Response.output['token']# Get ORG ID for logged in Useriotiumlib.orch.id=iotiumlib.org.get(org_id=None).Response.output['organization']['id']# Alternate Way to get ORG ID for logged in UserORG_ID=iotiumlib.helper.get_resource_id_by_name(iotiumlib.org,"Org Name")# Get PROFILE ID. Options: Edge, Virtual Edge, Virtualedge_profile_id=iotiumlib.helper.get_resource_id_by_name(iotiumlib.profile,"Edge")# Get list of Available Serial for Node provisionavail_serial_list=iotiumlib.pki.getv2(filters={"assigned":"false","own":"true"}).Response.outputforpkiinavail_serial_list:print(pki['id'])###### Managing Users ######## Get User Roles for Your Organization#TODO# Adding a New UseruserRespObj=iotiumlib.user.add(name="User Name",email="email@domain.com",password="Password@1234",role="24c416ab-483c-402a-9b76-69bce4dd97ae")# Getting User ID for specfic UserUSER_ID=iotiumlib.helper.get_resource_id_by_name(iotiumlib.user,"User Name")# Editing the User for name and roleiotiumlib.user.edit(user_id=USER_ID,role="ROLL_ID")iotiumlib.user.edit(user_id=USER_ID)iotiumlib.user.edit(user_id=USER_ID,name="New User Name",role="ROLL_ID")iotiumlib.user.edit(user_id=USER_ID,name="New User Name")# Deleting specfic Useriotiumlib.user.delete(user_id=USER_ID)###### Provising an Edge iNode ######## Other avail params:# standalone_expires (int) in minutes. Default=0# data_saving_mode (string). Default="Fast", Options: "Slow", "Off"respObj=iotiumlib.node.add(inode_name="Node Name",serial_number="pki-id",profile_id=edge_profile_id,org_id=ORG_ID,label="key:value")print(respObj.Response.output)# Get Node ID for Node edit/delete/reboot/notificationsNODE_ID=iotiumlib.helper.get_resource_id_by_name(iotiumlib.node,"Node Name")# Edit Edge iNode for inode_name, label, standalone_expires, data_saving_moderespObj_e=iotiumlib.node.edit(node_id=NODE_ID)# Initiate Reboot on specfic Edge iNoderespObj_r=iotiumlib.node.reboot(node_id=NODE_ID)# Delete Edge iNoderespObj_d=iotiumlib.node.delete(node_id=NODE_ID)# List iNode specfic event. Default: All Event. Options: type=node, network, service#start_date and end_date are in Epoch Time Stamp formatrespObj_n=iotiumlib.node.notifications(node_id=NODE_ID)respout=iotiumlib.node.notifications(node_id=NODE_ID,type="node").Response.outputrespout=iotiumlib.node.notifications(node_id=NODE_ID,type="node",filters={"start_date":"","end_date":""}).Response.output###### Adding Local Network to Edge iNode #######iotiumlib.network.add(node_id=NODE_ID,network_name="TAN Network",cidr="192.168.0.0/28",start_ip="192.168.0.1",end_ip="192.168.0.14")# Get Network ID for Network edit/deleteTAN_ID=iotiumlib.helper.get_resource_id_by_name(iotiumlib.network,"TAN Network")# Setting the Default Destination for Local Network to Edge iNodeâ€™s WAN Networkiotiumlib.network.edit(network_id=TAN_ID,default_destination="WAN_ID")# Connecting an Edge iNode Network to a Remote Virtual iNode networkiotiumlib.network.edit(network_id=TAN_ID,connect_networks=[{"network_id":"Remote_Network_Id","node_id":"Remote_Node_Id"}])# Delete Edge Local Networkiotiumlib.network.delete(network_id=TAN_ID)###### Using Custom Security Policy #######iotiumlib.firewall.add(name='FWG',org_id=ORG_ID,rules=[{'from_network':'name=TAN Network','to_network':'id="NETWORK-ID"','protocol':'SSH'},{'from_network':'label=key:value','to_network':'type=wan','action':'ALLOW'},{'from_network':'label=key:value','to_network':'type=wan','action':'ALLOW','priority':'3000'},])###### Using Secrets #######iotiumlib.secret.add(name="Service Secret Name",filename={'.dockerconfigjson':'ContentInBase64Format'},type="Dockerconfigjson")iotiumlib.secret.add(name="Service Volume Name",filename=[],type="Opaque")###### Using Mysubscriptions ########type: NODE_STATE_CHANGE, TUNNEL_STATE_CHANGE, SERVICE_STATE_CHANGE, NODE_IP_CHANGE, NODE_UPGRADE, HEADLESS_EXPIRY, CERT_EXPIRY#include_child(bool): True to include child orgs. Scope: ORG level#duration(int): default 5min.#node_id: Scope: iNode level#tunnel_id: for type=TUNNEL_STATE_CHANGE#pod_id: for type=SERVICE_STATE_CHANGE#channel_type: default EMAIL#channel_id: for channel_type=WEBHOOKiotiumlib.user.mysubscriptions.add(alert_name="Alert Name",type="SERVICE_STATE_CHANGE",org_id="OrgID")###### Listing Events ########Default: All Event. Options: type=node, network, service#start_date and end_date are in Epoch Time Stamp formatiotiumlib.user.notifications(filters={"start_date":"","end_date":""},type="node").Response.outputiotiumlib.user.notifications(node_id=NODE_ID,filters={"start_date":"","end_date":""},type="node").Response.outputiotiumlib.user.notifications(org_id=ORG_ID,filters={"start_date":"","end_date":""},type="node").Response.output###### Using Webhooks #######iotiumlib.user.webhook.add(name="Webhook Name","url"="https://abc.com/api/iotiumalerts","secret"="test")