GET /api/roles
List all roles

Examples

GET /api/roles
200
{
  "total": 13,
  "subtotal": 13,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": "name",
    "order": "ASC"
  },
  "results": [
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "Create hosts",
      "id": 9,
      "description": null,
      "origin": ""
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "CRUD hosts",
      "id": 12,
      "description": null,
      "origin": ""
    },
    {
      "builtin": 2,
      "cloned_from_id": null,
      "name": "Default role",
      "id": 7,
      "description": null,
      "origin": "foreman"
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "Destroy hosts",
      "id": 8,
      "description": null,
      "origin": ""
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "Edit hosts",
      "id": 4,
      "description": null,
      "origin": "foreman"
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "Edit partition tables",
      "id": 2,
      "description": null,
      "origin": "foreman"
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "Manager",
      "id": 1,
      "description": null,
      "origin": "foreman"
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "No rights",
      "id": 10,
      "description": null,
      "origin": ""
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "Organization admin",
      "id": 13,
      "description": null,
      "origin": "foreman"
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "System admin",
      "id": 14,
      "description": null,
      "origin": "foreman"
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "View compute resources",
      "id": 11,
      "description": null,
      "origin": ""
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "Viewer",
      "id": 5,
      "description": null,
      "origin": "foreman"
    },
    {
      "builtin": 0,
      "cloned_from_id": null,
      "name": "View hosts",
      "id": 3,
      "description": null,
      "origin": "foreman"
    }
  ]
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

search
optional

filter results

Validations:

  • Must be a String

order
optional

Sort and order by a searchable field, e.g. ‘id DESC’

Validations:

  • Must be a String

page
optional

Page number, starting at 1

Validations:

  • Must be a number.

per_page
optional

Number of results per page to return, ‘all’ to return all results

Validations:

  • Must match regular expression /\A([1-9]\d|all)\Z$/.

Search fields

Field name Type Possible values
builtin true, false
description text
name string
permission string

GET /api/roles/:id
Show a role

Examples

GET /api/roles/1-Manager
200
{
  "builtin": 0,
  "cloned_from_id": null,
  "name": "Manager",
  "id": 1,
  "description": null,
  "origin": "foreman",
  "filters": [
    {
      "id": 139728896,
      "resource_type": "Ptable"
    },
    {
      "id": 169533705,
      "resource_type": "Subnet"
    },
    {
      "id": 170801529,
      "resource_type": "AuthSource"
    },
    {
      "id": 222559602,
      "resource_type": "CommonParameter"
    },
    {
      "id": 225912082,
      "resource_type": "Location"
    },
    {
      "id": 255448041,
      "resource_type": null
    },
    {
      "id": 291325508,
      "resource_type": "Operatingsystem"
    },
    {
      "id": 321349837,
      "resource_type": "Architecture"
    },
    {
      "id": 340438230,
      "resource_type": "Domain"
    },
    {
      "id": 343831726,
      "resource_type": "Realm"
    },
    {
      "id": 372277853,
      "resource_type": "User"
    },
    {
      "id": 503111935,
      "resource_type": "Medium"
    },
    {
      "id": 528928374,
      "resource_type": "Audit"
    },
    {
      "id": 557298380,
      "resource_type": "Usergroup"
    },
    {
      "id": 643462867,
      "resource_type": "Model"
    },
    {
      "id": 679608033,
      "resource_type": "FactValue"
    },
    {
      "id": 721145960,
      "resource_type": "Host"
    },
    {
      "id": 943645556,
      "resource_type": "Report"
    },
    {
      "id": 977587707,
      "resource_type": "Hostgroup"
    },
    {
      "id": 980424071,
      "resource_type": "Organization"
    },
    {
      "id": 1025364382,
      "resource_type": "ReportTemplate"
    },
    {
      "id": 1062414187,
      "resource_type": "Puppetclass"
    }
  ],
  "locations": [],
  "organizations": []
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

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.

description
optional

Validations:

  • Must be a String


POST /api/roles
Create a role

Examples

POST /api/roles
{
  "role": {
    "name": "staff"
  }
}
201
{
  "builtin": 0,
  "cloned_from_id": null,
  "name": "staff",
  "id": 17,
  "description": null,
  "origin": null,
  "filters": [],
  "locations": [],
  "organizations": []
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

role
required

Validations:

  • Must be a Hash

role[name]
required

Validations:

  • Must be a String

role[description]
optional , nil allowed

Role description

Validations:

  • Must be a String

role[location_ids]
optional , nil allowed

REPLACE locations with given ids

Validations:

  • Must be an array of any type

role[organization_ids]
optional , nil allowed

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type


PUT /api/roles/:id
Update a role

Examples

PUT /api/roles/8-Destroy%20hosts
{
  "role": {
    "name": "staff"
  }
}
200
{
  "builtin": 0,
  "cloned_from_id": null,
  "name": "staff",
  "id": 8,
  "description": null,
  "origin": "",
  "filters": [
    {
      "id": 10997177,
      "resource_type": "Host"
    }
  ],
  "locations": [],
  "organizations": []
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be a String

role
required

Validations:

  • Must be a Hash

role[name]
optional

Validations:

  • Must be a String

role[description]
optional , nil allowed

Role description

Validations:

  • Must be a String

role[location_ids]
optional , nil allowed

REPLACE locations with given ids

Validations:

  • Must be an array of any type

role[organization_ids]
optional , nil allowed

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type


DELETE /api/roles/:id
Delete a role

Examples

DELETE /api/roles/8-Destroy%20hosts
{
  "role": {}
}
200
{
  "id": 8,
  "name": "Destroy hosts",
  "builtin": 0,
  "description": null,
  "origin": "",
  "cloned_from_id": null
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be a String


POST /api/roles/:id/clone
Clone a role

Examples

POST /api/roles/1/clone
{
  "name": "New Manager",
  "role": {
    "name": "New Manager"
  }
}
201
{
  "id": 19,
  "name": "New Manager",
  "builtin": 0,
  "description": null,
  "origin": null,
  "cloned_from_id": 1
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be a String

role
required

Validations:

  • Must be a Hash

role[name]
optional

Validations:

  • Must be a String

role[description]
optional , nil allowed

Role description

Validations:

  • Must be a String

role[location_ids]
optional , nil allowed

REPLACE locations with given ids

Validations:

  • Must be an array of any type

role[organization_ids]
optional , nil allowed

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type