✅ API Role permissions bulk update

Is is possible to update role permissions via the API using a json payload?


I need to export and import role permissions between Morpheus installations, I have written the code to export the permissions in json format , however there doesnt seem to be a easy way to import the json on a second Morpheus installation. Are you able to share any methods on how this might be possible?


Export and Import role permissions


Hi Kevin,

The roles API was updated in 5.5.2 to support setting permissions in bulk on create and update.
The payload looks like this:

{
  "role": {
    "permissions": [
      {
        "code": "dashboard",
        "access": "read"
      },
      {
        "code": "operations-wiki",
        "access": "full"
      }
    ],
    "instanceTypes": [
      {
        "code": "nginx",
        "access": "full"
      },
      {
        "code": "apache",
        "access": "none"
      }
    ]
  }
}

The API docs are missing these parameters for setting bulk permissions at the moment. We will be updating the documentation very soon to correct this omission.

If you have the CLI installed, you can see all options for bulk create/update there, for example:

morpheus roles update "My Role" --instance-types "nginx=full,apache=none" --permissions "dashboard=read,operations-wiki=full" -d

Thanks!
James

Thanks James,

Could really do with a way to export existing permissions from one appliance and then import over the top of a role on another appliance. When I export the existing role the Json doesnt seem usable for the import process which means I’m gonna have to write some code to put the permissions in the correct JSON format.

Not sure if that’s something you guys have available or are working on?