ManageIQ / ManageIQ/manageiq-api

Endpoint to retrieve tags under a category with descriptions

Open
#704 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Ruby
Stars
20
Forks
149
Avg merge
3d 22h
Merged PRs (30d)
1

Description

I need a way to retrieve tags under a given category with tag descriptions (which are actually used across the UI as the title of the given tag). For now I have this request, that returns me with the tags under a category:

# curl -XGET http://admin:smartvm@localhost:3000/api/categories/1\?expand\=tags | jq
{
  "href": "http://localhost:3000/api/categories/1",
  "id": "1",
  "description": "Location",
  "icon": null,
  "read_only": false,
  "syntax": "string",
  "single_value": true,
  "example_text": "The geographic location of the resource, such as New York, Chicago, or London.",
  "tag_id": "3",
  "parent_id": null,
  "show": true,
  "default": true,
  "perf_by_tag": null,
  "name": "location",
  "tags": [
    {
      "href": "http://localhost:3000/api/categories/1/tags/4",
      "id": "4",
      "name": "/managed/location/ny"
    },
    {
      "href": "http://localhost:3000/api/categories/1/tags/5",
      "id": "5",
      "name": "/managed/location/chicago"
    },
    {
      "href": "http://localhost:3000/api/categories/1/tags/6",
      "id": "6",
      "name": "/managed/location/london"
    },
    {
      "href": "http://localhost:3000/api/categories/1/tags/7",
      "id": "7",
      "name": "/managed/location/paris"
    }
  ],
  "actions": [
    {
      "name": "edit",
      "method": "post",
      "href": "http://localhost:3000/api/categories/1"
    },
    {
      "name": "delete",
      "method": "post",
      "href": "http://localhost:3000/api/categories/1"
    },
    {
      "name": "delete",
      "method": "delete",
      "href": "http://localhost:3000/api/categories/1"
    }
  ]
}

But the description is not part of the expanded tags, however, I found a solution to fire a second request that returns me the descriptions as well:

# curl -XPOST http://admin:smartvm@localhost:3000/api/tags/\?attributes\=categorization -d '{ "action": "query", "resources": [ { "id": 4 }, { "id": 5 } ]  }'

{
  "results": [
    {
      "href": "http://localhost:3000/api/tags/4",
      "id": "4",
      "name": "/managed/location/ny",
      "categorization": {
        "name": "ny",
        "description": "New York",
        "category": {
          "name": "location",
          "description": "Location"
        },
        "display_name": "Location: New York"
      },
      "actions": [
        {
          "name": "edit",
          "method": "post",
          "href": "http://localhost:3000/api/tags/4"
        },
        {
          "name": "delete",
          "method": "post",
          "href": "http://localhost:3000/api/tags/4"
        },
        {
          "name": "delete",
          "method": "delete",
          "href": "http://localhost:3000/api/tags/4"
        }
      ]
    },
    {
      "href": "http://localhost:3000/api/tags/5",
      "id": "5",
      "name": "/managed/location/chicago",
      "categorization": {
        "name": "chicago",
        "description": "Chicago",
        "category": {
          "name": "location",
          "description": "Location"
        },
        "display_name": "Location: Chicago"
      },
      "actions": [
        {
          "name": "edit",
          "method": "post",
          "href": "http://localhost:3000/api/tags/5"
        },
        {
          "name": "delete",
          "method": "post",
          "href": "http://localhost:3000/api/tags/5"
        },
        {
          "name": "delete",
          "method": "delete",
          "href": "http://localhost:3000/api/tags/5"
        }
      ]
    }
  ]
}

However, the request building is a little messy as I have to specify all the tag IDs one by one and then merge the result. So my question: is there a way to do this in a single request, by specifying a magic attribute that adds the description field to the expanded tags?

@martinpovolny @abellotti

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the category endpoint's expanded tags response and the tag categorization query shown in the issue. Determine whether the API supports a single expansion or attribute request, then verify that one category request returns each tag's description without manually listing IDs or merging results.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.