The method allows to retrieve templates according to the given parameters. 此方法允许根据指定的参数检索模板。

    Parameters 参数

    (object) Parameters defining the desired output. (object)定义需要输出的参数。

    The method supports the following parameters. 此方法支持以下参数。

    • an array of objects; 一组对象;

    • the count of retrieved objects, if the countOutput parameter has been used. 如果已经使用了countOutput参数,则检索对象的计数。

    Examples 范例

    Retrieving templates by name 按名称检索模板

    Retrieve all data about two templates named “Template OS Linux” and “Template OS Windows”. 检索名称为“Template OS Linux”和“Template OS Windows”这两个模板的所有数据。 Request 请求:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "proxy_hostid": "0",
    6. "host": "Template OS Linux",
    7. "status": "3",
    8. "disable_until": "0",
    9. "error": "",
    10. "available": "0",
    11. "errors_from": "0",
    12. "lastaccess": "0",
    13. "ipmi_authtype": "0",
    14. "ipmi_privilege": "2",
    15. "ipmi_username": "",
    16. "ipmi_password": "",
    17. "ipmi_disable_until": "0",
    18. "ipmi_available": "0",
    19. "snmp_disable_until": "0",
    20. "snmp_available": "0",
    21. "maintenanceid": "0",
    22. "maintenance_status": "0",
    23. "maintenance_type": "0",
    24. "ipmi_errors_from": "0",
    25. "snmp_errors_from": "0",
    26. "ipmi_error": "",
    27. "snmp_error": "",
    28. "jmx_available": "0",
    29. "jmx_errors_from": "0",
    30. "jmx_error": "",
    31. "name": "Template OS Linux",
    32. "flags": "0",
    33. "templateid": "10001",
    34. "description": "",
    35. "tls_connect": "1",
    36. "tls_accept": "1",
    37. "tls_issuer": "",
    38. "tls_subject": "",
    39. "tls_psk_identity": "",
    40. "tls_psk": ""
    41. },
    42. {
    43. "proxy_hostid": "0",
    44. "host": "Template OS Windows",
    45. "status": "3",
    46. "disable_until": "0",
    47. "error": "",
    48. "available": "0",
    49. "errors_from": "0",
    50. "lastaccess": "0",
    51. "ipmi_authtype": "0",
    52. "ipmi_privilege": "2",
    53. "ipmi_username": "",
    54. "ipmi_password": "",
    55. "ipmi_available": "0",
    56. "snmp_disable_until": "0",
    57. "snmp_available": "0",
    58. "maintenanceid": "0",
    59. "maintenance_status": "0",
    60. "maintenance_type": "0",
    61. "maintenance_from": "0",
    62. "ipmi_errors_from": "0",
    63. "snmp_errors_from": "0",
    64. "ipmi_error": "",
    65. "snmp_error": "",
    66. "jmx_disable_until": "0",
    67. "jmx_available": "0",
    68. "jmx_errors_from": "0",
    69. "jmx_error": "",
    70. "name": "Template OS Windows",
    71. "flags": "0",
    72. "templateid": "10081",
    73. "description": "",
    74. "tls_connect": "1",
    75. "tls_accept": "1",
    76. "tls_issuer": "",
    77. "tls_subject": "",
    78. "tls_psk_identity": "",
    79. "tls_psk": ""
    80. }
    81. ],
    82. "id": 1
    83. }

    Source 源码

    CTemplate::get() in frontends/php/include/classes/api/services/CTemplate.php. CTemplate::get()方法可在frontends/php/include/classes/api/services/CTemplate.php中参考。