Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This PR supports nested group name. #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

quenhulu
Copy link

@quenhulu quenhulu commented Dec 7, 2017

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
Copy link

coveralls commented Dec 7, 2017

Coverage Status

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

@aabouzaid
Copy link
Owner

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

@quenhulu
Copy link
Author

quenhulu commented Dec 8, 2017

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants