Updated on 2023-08-14 GMT+08:00

Querying the Input Parameters of a Template

Function

This API is used to query the input parameter of a template.

URI

GET /v2/templates/{template_id}/inputs

Table 1 Parameter description

Parameter

Mandatory

Description

template_id

Yes

Template ID

Request

N/A

Response

  • Response parameters

    For details about response parameters when the request fails, see Table 5.

    Table 2 Response parameters

    Parameter

    Type

    Description

    [Customized key]

    Map<String,Object>

    The key indicates the name of a template input parameter. The value indicates the attribute information of the template input parameter. For details, see Table 3.

    Table 3 Data structure of the attribute information of a template input parameter

    Parameter

    Type

    Description

    required

    Boolean

    Whether the parameter can be left blank. The options are as follows: true or false.

    default

    Integer or String or Float or Boolean

    Default parameter in the template. Multiple types supported, such as integer, string, and boolean. It can be selected based on the type field.

    description

    String

    Description of the parameter.

    type

    String

    Input parameter types of a template.

    • string: character string
    • integer: integer
    • boolean: Boolean
    • enum: Enumeration. If an enumeration is used, the input must contain the valid_values field of the constraints field.
    • float: floating point number
    • secret: key
    • password: password
    • ip: IP address

    constraints

    Object

    Constraints of the parameter value. For details, see Table 4.

    label

    String

    Label group to which the parameter belongs.

    advanced

    Boolean

    Whether the parameter is an advanced configuration. The default value must be available. The parameter is hidden by default on the GUI.

    immutable

    Boolean

    Whether the parameter can be modified.

    Table 4 Parameter constraint structure description

    Parameter

    Type

    Description

    in_range

    Array of integers

    The value must be greater than or equal to the minimum value, and less than or equal to the maximum value.

    regex

    String

    The input value must comply with the regular expression.

    valid_values

    Array of integers, string, float, or boolean

    The input value must be one of the given values.

    equal

    Integer, string, float, or Boolean

    The input value must be equal to this value.

    greater_or_equal

    Integer, string, float, or Boolean

    The input value must be greater than or equal to this value.

    greater_than

    Integer, string, float, or Boolean

    The input value must be greater than this value.

    less_or_equal

    Integer, string, float, or Boolean

    The input value must be less than or equal to this value.

    less_than

    Integer, string, float, or Boolean

    The input value must be less than this value.

  • Example response
    {
        "key1": {
            "default": "192.168.12.22:30303/test_yj/frontend:latest",
            "immutable": false,
            "type": "string"
        },
        "key2": {
            "default": 2,
            "immutable": false,
            "type": "integer"
        },
        "key3": {
            "immutable": true,
            "type": "string"
        },
        "key4": {
            "type": "float",
            "constraints": {
                "greater_or_equal": 0,
                "greater_than": 0,
                "less_or_equal": 2,
                "less_than": 2
            }
        }
    }

Status Code

  • Normal
    Table 5 Status code

    Status Code

    Description

    200

    Querying the input parameter is successful.

  • Abnormal
    Table 6 Status code

    Status Code

    Description

    400

    The request parameter is incorrect.

    404

    The requested resource cannot be found.

    500

    The server fails to process the request due to an unexpected condition.