通过iTop Webservice接口丰富OQL的功能
Posted Work Notes
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过iTop Webservice接口丰富OQL的功能相关的知识,希望对你有一定的参考价值。
通过Python调用iTop的Webservice接口:
#!/usr/bin/env python #coding: utf-8 import requests import json itopurl = "https://itsm.google.cn/webservices/rest.php" # opr = json.dumps( # {‘operation‘:‘list_operations‘} # ) opr = json.dumps( { ‘operation‘:‘core/get‘, ‘class‘: ‘FunctionalCI‘, ‘key‘:"SELECT FunctionalCI", ‘output_fields‘ : ‘name , contacts_list‘} ) payload={ "version":"1.0", "auth_user":"admin", "auth_pwd":"your_pwd", "json_data":opr } r = requests.post(url=itopurl, data=payload) dict_r = json.loads(r.content) fp = open("server.csv","w+") for item in dict_r[‘objects‘]: if len(dict_r[‘objects‘][item][‘fields‘][‘contacts_list‘]) == 0: # print dict_r[‘objects‘][item][‘fields‘][‘name‘] fp.write(dict_r[‘objects‘][item][‘fields‘][‘name‘] + "\n") fp.close()
https://sourceforge.net/p/itop/discussion/922361/thread/0c0ad12f/
https://wiki.openitop.org/doku.php?id=advancedtopics:rest_json
http://www.07net01.com/program/2016/02/1304701.html
以上是关于通过iTop Webservice接口丰富OQL的功能的主要内容,如果未能解决你的问题,请参考以下文章