GET /api/usergroups
List all user groups

Examples

GET /api/usergroups
200
{
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "admin": false,
      "created_at": "2019-02-20 13:38:06 UTC",
      "updated_at": "2019-02-20 13:38:06 UTC",
      "name": "usergroup299",
      "id": 9
    }
  ]
}

Params

Param name Description
location_id
optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
optional

Scope by organizations

Validations:

  • Must be a Integer

search
optional

filter results

Validations:

  • Must be a String

order
optional

Sort field and order, eg. ‘id DESC’

Validations:

  • Must be a String

page
optional

paginate results

Validations:

  • Must be a String

per_page
optional

number of entries per request

Validations:

  • Must be a String

Search fields

Field name Type Possible values
name string
role string
role_id integer

GET /api/usergroups/:id
Show a user group

Examples

GET /api/usergroups/3-usergroup294
200
{
  "admin": false,
  "created_at": "2019-02-20 13:38:06 UTC",
  "updated_at": "2019-02-20 13:38:06 UTC",
  "name": "usergroup294",
  "id": 3,
  "external_usergroups": [],
  "usergroups": [],
  "users": [],
  "roles": []
}

Params

Param name Description
location_id
optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
optional

Scope by organizations

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.


POST /api/usergroups
Create a user group

Examples

POST /api/usergroups
{
  "usergroup": {
    "name": "test_usergroup"
  }
}
201
{
  "admin": false,
  "created_at": "2019-02-20 13:38:06 UTC",
  "updated_at": "2019-02-20 13:38:06 UTC",
  "name": "test_usergroup",
  "id": 6,
  "external_usergroups": [],
  "usergroups": [],
  "users": [],
  "roles": []
}

Params

Param name Description
location_id
optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
optional

Scope by organizations

Validations:

  • Must be a Integer

usergroup
required

Validations:

  • Must be a Hash

usergroup[name]
required

Validations:

  • Must be a String

usergroup[admin]
optional , nil allowed

is an admin user group

Validations:

  • Must be one of: true, false, 1, 0.

usergroup[user_ids]
optional , nil allowed

Validations:

  • Must be an array of any type

usergroup[usergroup_ids]
optional , nil allowed

Validations:

  • Must be an array of any type

usergroup[role_ids]
optional , nil allowed

Validations:

  • Must be an array of any type


PUT /api/usergroups/:id
Update a user group

User groups linked to external groups (LDAP) are automatically synced with these groups on update. Remember this synchronization will remove any LDAP users manually added to the Foreman user group. Only LDAP users in the external groups will remain. Internal users can be added or removed freely.

Examples

PUT /api/usergroups/7-usergroup297
{
  "usergroup": {
    "name": "test_usergroup",
    "usergroup_ids": [
      8
    ]
  }
}
200
{
  "admin": false,
  "created_at": "2019-02-20 13:38:06 UTC",
  "updated_at": "2019-02-20 13:38:06 UTC",
  "name": "test_usergroup",
  "id": 7,
  "external_usergroups": [],
  "usergroups": [
    {
      "name": "usergroup298",
      "id": 8,
      "created_at": "2019-02-20 13:38:06 UTC",
      "updated_at": "2019-02-20 13:38:06 UTC"
    }
  ],
  "users": [],
  "roles": []
}

Params

Param name Description
location_id
optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
optional

Scope by organizations

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be a String

usergroup
required

Validations:

  • Must be a Hash

usergroup[name]
optional

Validations:

  • Must be a String

usergroup[admin]
optional , nil allowed

is an admin user group

Validations:

  • Must be one of: true, false, 1, 0.

usergroup[user_ids]
optional , nil allowed

Validations:

  • Must be an array of any type

usergroup[usergroup_ids]
optional , nil allowed

Validations:

  • Must be an array of any type

usergroup[role_ids]
optional , nil allowed

Validations:

  • Must be an array of any type


DELETE /api/usergroups/:id
Delete a user group

Examples

DELETE /api/usergroups/4-usergroup295
{
  "usergroup": {}
}
200
{
  "id": 4,
  "name": "usergroup295",
  "created_at": "2019-02-20T13:38:06.106Z",
  "updated_at": "2019-02-20T13:38:06.106Z",
  "admin": false
}

Params

Param name Description
location_id
optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
optional

Scope by organizations

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be a String