GET /api/smart_variables
列出所有智能变量

GET /api/hosts/:host_id/smart_variables
具体主机的智能变量列表

GET /api/hostgroups/:hostgroup_id/smart_variables
具体主机组的智能变量列表

GET /api/puppetclasses/:puppetclass_id/smart_variables
具体 Puppet 类别的智能变量列表

示例

GET /api/puppetclasses/298486374/smart_variables
200
{
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "description": null,
      "parameter_type": "string",
      "variable_type": "string",
      "hidden_value?": false,
      "validator_type": null,
      "validator_rule": null,
      "override_value_order": "organization,location\nxyz\nhostgroup",
      "merge_overrides": false,
      "merge_default": false,
      "avoid_duplicates": false,
      "puppetclass_id": 298486374,
      "puppetclass_name": "apache",
      "created_at": "2019-09-11 14:58:01 UTC",
      "updated_at": "2019-09-11 14:58:01 UTC",
      "variable": "special_info",
      "id": 281110143,
      "default_value": "secret",
      "override_values_count": 2
    }
  ]
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

host_id
选填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

hostgroup_id
选填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

puppetclass_id
选填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

show_hidden
选填

显示隐藏值

Validations:

  • Must be one of: true, false, 1, 0.

search
选填

过滤结果

Validations:

  • Must be a String

order
选填

排序项和顺序,例如 ‘id DESC’

Validations:

  • Must be a String

page
选填

页号,从 1 开始

Validations:

  • Must be a number.

per_page
选填

每页中显示的返回结果数

Validations:

  • Must be a number.

搜索字段

字段名 类型 可能的值
avoid_duplicates true, false
key string
merge_default true, false
merge_overrides true, false
override true, false
parameter string
puppetclass string

GET /api/smart_variables/:id
显示智能变量

示例

GET /api/puppetclasses/980190962/smart_variables/1018350796
200
{
  "description": null,
  "parameter_type": null,
  "variable_type": null,
  "hidden_value?": true,
  "validator_type": null,
  "validator_rule": null,
  "override_value_order": "fqdn\nhostgroup\nos\ndomain",
  "merge_overrides": false,
  "merge_default": false,
  "avoid_duplicates": false,
  "puppetclass_id": 980190962,
  "puppetclass_name": "base",
  "created_at": "2019-09-11 14:34:10 UTC",
  "updated_at": "2019-09-11 14:34:10 UTC",
  "variable": "param8",
  "id": 1018350796,
  "default_value": "hidden",
  "override_values_count": 0,
  "override_values": []
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

show_hidden
选填

显示隐藏值

Validations:

  • Must be one of: true, false, 1, 0.


POST /api/smart_variables
创建智能变量

示例

POST /api/smart_variables
{
  "smart_variable": {
    "variable": "QSFxqjVjdV",
    "puppetclass_id": 298486374,
    "hidden_value": true
  }
}
201
{
  "description": null,
  "parameter_type": null,
  "variable_type": null,
  "hidden_value?": true,
  "validator_type": null,
  "validator_rule": null,
  "override_value_order": "fqdn\nhostgroup\nos\ndomain",
  "merge_overrides": false,
  "merge_default": false,
  "avoid_duplicates": false,
  "puppetclass_id": 298486374,
  "puppetclass_name": "apache",
  "created_at": "2019-09-11 14:34:11 UTC",
  "updated_at": "2019-09-11 14:34:11 UTC",
  "variable": "QSFxqjVjdV",
  "id": 1018350798,
  "default_value": "*****",
  "override_values_count": 0,
  "override_values": []
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

smart_variable
必填

Validations:

  • Must be a Hash

smart_variable[variable]
必填

变量名称

Validations:

  • Must be a String

smart_variable[puppetclass_id]
选填 , 允许空值

Puppet 类别 ID

Validations:

  • Must be a number.

smart_variable[default_value]
选填 , 允许空值

变量的默认值

Validations:

  • Must be one of types: string, boolean, integer, real, array, hash, yaml, json

smart_variable[hidden_value]
选填 , 允许空值

何时将启用的参数隐藏到 UI 中

Validations:

  • Must be one of: true, false, 1, 0.

smart_variable[override_value_order]
选填 , 允许空值

解析参数值的指令

Validations:

  • Must be a String

smart_variable[description]
选填 , 允许空值

变量描述

Validations:

  • Must be a String

smart_variable[validator_type]
选填 , 允许空值

验证值类型

Validations:

  • Must be one of: regexp, list.

smart_variable[validator_rule]
选填 , 允许空值

用来在参数中强制使用某些值

Validations:

  • Must be a String

smart_variable[variable_type]
选填 , 允许空值

变量值类型

Validations:

  • Must be one of: string, boolean, integer, real, array, hash, yaml, json.

smart_variable[merge_overrides]
选填 , 允许空值

合并所有匹配的值(仅用于阵列/哈希类型)

Validations:

  • Must be one of: true, false, 1, 0.

smart_variable[merge_default]
选填 , 允许空值

合并所有匹配值时包括默认值

Validations:

  • Must be one of: true, false, 1, 0.

smart_variable[avoid_duplicates]
选填 , 允许空值

删除重复值(仅用于阵列类型)

Validations:

  • Must be one of: true, false, 1, 0.


PUT /api/smart_variables/:id
更新智能变量

示例

PUT /api/smart_variables/1018350799-IJcocqAlPP
{
  "smart_variable": {
    "hidden_value": false
  }
}
200
{
  "description": null,
  "parameter_type": null,
  "variable_type": null,
  "hidden_value?": false,
  "validator_type": null,
  "validator_rule": null,
  "override_value_order": "fqdn\nhostgroup\nos\ndomain",
  "merge_overrides": false,
  "merge_default": false,
  "avoid_duplicates": false,
  "puppetclass_id": 980190962,
  "puppetclass_name": "base",
  "created_at": "2019-09-11 14:34:11 UTC",
  "updated_at": "2019-09-11 14:34:11 UTC",
  "variable": "IJcocqAlPP",
  "id": 1018350799,
  "default_value": null,
  "override_values_count": 0,
  "override_values": []
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

smart_variable
必填

Validations:

  • Must be a Hash

smart_variable[variable]
选填

变量名称

Validations:

  • Must be a String

smart_variable[puppetclass_id]
选填 , 允许空值

Puppet 类别 ID

Validations:

  • Must be a number.

smart_variable[default_value]
选填 , 允许空值

变量的默认值

Validations:

  • Must be one of types: string, boolean, integer, real, array, hash, yaml, json

smart_variable[hidden_value]
选填 , 允许空值

何时将启用的参数隐藏到 UI 中

Validations:

  • Must be one of: true, false, 1, 0.

smart_variable[override_value_order]
选填 , 允许空值

解析参数值的指令

Validations:

  • Must be a String

smart_variable[description]
选填 , 允许空值

变量描述

Validations:

  • Must be a String

smart_variable[validator_type]
选填 , 允许空值

验证值类型

Validations:

  • Must be one of: regexp, list.

smart_variable[validator_rule]
选填 , 允许空值

用来在参数中强制使用某些值

Validations:

  • Must be a String

smart_variable[variable_type]
选填 , 允许空值

变量值类型

Validations:

  • Must be one of: string, boolean, integer, real, array, hash, yaml, json.

smart_variable[merge_overrides]
选填 , 允许空值

合并所有匹配的值(仅用于阵列/哈希类型)

Validations:

  • Must be one of: true, false, 1, 0.

smart_variable[merge_default]
选填 , 允许空值

合并所有匹配值时包括默认值

Validations:

  • Must be one of: true, false, 1, 0.

smart_variable[avoid_duplicates]
选填 , 允许空值

删除重复值(仅用于阵列类型)

Validations:

  • Must be one of: true, false, 1, 0.


DELETE /api/smart_variables/:id
删除智能参数

示例

DELETE /api/smart_variables/281110143-special_info
{
  "smart_variable": {}
}
200
{
  "description": null,
  "parameter_type": "string",
  "variable_type": "string",
  "hidden_value?": false,
  "validator_type": null,
  "validator_rule": null,
  "override_value_order": "organization,location\nxyz\nhostgroup",
  "merge_overrides": false,
  "merge_default": false,
  "avoid_duplicates": false,
  "puppetclass_id": 298486374,
  "puppetclass_name": "apache",
  "created_at": "2019-09-11 14:58:01 UTC",
  "updated_at": "2019-09-11 14:58:01 UTC",
  "variable": "special_info",
  "id": 281110143,
  "default_value": "secret",
  "override_values_count": 0,
  "override_values": []
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.