Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

This PR supports nested group name. - #10

Open
quenhulu wants to merge 1 commit into
aabouzaid:masterfrom
quenhulu:nested-group
Open

This PR supports nested group name.#10
quenhulu wants to merge 1 commit into
aabouzaid:masterfrom
quenhulu:nested-group

Conversation

@quenhulu

@quenhulu quenhulu commented Dec 7, 2017

Copy link
Copy Markdown

Add support for grouping by nested group.
This patch splits group name with dot when get group value.
Example of nested group name is `device_type.manufacturer'.

Example of nested group name is `device_type.manufacturer'.
@coveralls

coveralls commented Dec 7, 2017

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 99.2% when pulling 1ba9d83 on quenhulu:nested-group into f88b5f2 on AAbouZaid:master.

@aabouzaid

Copy link
Copy Markdown
Owner

@quenhulu Could you please add more details about your change?
Thanks :-)

@quenhulu

quenhulu commented Dec 8, 2017

Copy link
Copy Markdown
Author

I want to group devices by manufacturer, e.g. Arista, Cisco and Juniper.
However manufacturer is not a section, but one of the device_type attributes.
So, I chaned code to group by an even attribute of section too.

manufacturer is an attribute of device_type:

$ curl http://localhost/api/dcim/devices/ | jq .
{
  "count": 99,
  "next": "http://localhost/api/dcim/devices/?limit=50&offset=50",
  "previous": null,
  "results": [
    {
      "id": 1,
      "name": "switch00",
      "display_name": "switch00",
      "device_type": {
        "id": 1,
        "url": "http://localhost/api/dcim/device-types/1/",
        "manufacturer": {
          "id": 1,
          "url": "http://localhost/api/dcim/manufacturers/1/",
          "name": "ARISTA",
          "slug": "arista"
        },
        "model": "DCS-7050QX-32",
        "slug": "dcs-7050qx-32"
      },
      ...

netbox.yml:

netbox:
    main:
        api_url: 'http://localhost/api/dcim/devices/'

    group_by:
        default:
            # group by manufacturer
            - device_type.manufacturer

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants