• 通过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'] + "
    ")
    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

  • 相关阅读:
    《C》指针
    《C》变量
    《C》数组
    《C》VS控制台应用
    listagg wm_concat 行转列
    Linux学习之shell script
    Linux学习之正则表达式sed
    Linux学习之正则表达式grep
    Linux学习之SAMBA共享(密码验证)
    Linux学习之SAMBA共享(无密码)
  • 原文地址:https://www.cnblogs.com/IvanChen/p/5526739.html
Copyright © 2020-2023  润新知