GET /v1/groups/<id>/rules

Resolve the rules for a specific node group, and then translate those rules to work with the PuppetDB nodes and inventory endpoints.

Request format

When Forming node classifier API requests to this endpoint, the URI path must contain a node group ID. For example:

GET https://localhost:4433/classifier-api/v1/groups/085e2797-32f3-4920-9412-8e9decf4ef65/rules

Response format

A successful response returns a JSON object that uses these keys to enumerate the group's rules:

Key Definition
rule The rules for the group in classifier format.
rule_with_inherited The inherited rules (including the rules for this group) in classifier format
translated An object containing two children (nodes_query_format and inventory_query_format), which represent each of the inherited rules translated into a different format.
nodes_query_format The optimized translated inherited group in the format that works with the nodes endpoint in PuppetDB.
inventory_query_format The optimized translated inherited group in the format that works with the inventory endpoint in PuppetDB.

For example:

{
  "rule": [
    "=",
    [
      "fact",
      "is_spaceship"
    ],
    "true"
  ],
  "rule_with_inherited": [
    "and",
    [
      "=",
      [
        "fact",
        "is_spaceship"
      ],
      "true"
    ],
    [
      "~",
      "name",
      ".*"
    ]
  ],
  "translated": {
    "nodes_query_format": [
      "or",
      [
        "=",
        [
          "fact",
          "is_spaceship"
        ],
        "true"
      ],
      [
        "=",
        [
          "fact",
          "is_spaceship",
          true
        ]
      ]
    ],
    "inventory_query_format": [
      "or",
      [
        "=",
        "facts.is_spaceship",
        "true"
      ],
      [
        "=",
        "facts.is_spaceship",
        true
      ]
    ]
  }
}

Error responses

If there is an error, Node classifier API errors provide error information in the kind key.

If the endpoint can't find a node group with the specified ID, the server returns a 404 Not Found or malformed-UUID response.

Related information