How-To: Add Users and Groups to a Repo using GraphQL
To create a new group using GraphQL API, your on-prem LogScale installation should use the Advanced permission model.
In LogScale configuration, enable the environment variable to support the advanced permission model:
PERMISSION_MODEL_MODE=advanced
If you're on Cloud the advanced model is enabled by default.
Then you can follow these steps:
Create a new repo called
<repo_name>
from the UI.Create a group that you will use for
<repo_name>
repository called<repo_name>.<role>
(e.g.my-new-repo.admins
)graphqlmutation { addGroup(displayName:"<repo_name>.<role>",lookupName:"<repo_name>.<role>"){ group{ id } } }
You will need the returned
group_ID
later in step 4.Find the repository id with this query:
graphqlquery { repository(name:"<repo_name>"){ id } }
Use the repository ID from step 3 as the
viewId
and the group ID from step 2 as thegroupId
in the following mutation:graphqlmutation { assignRoleToGroup(input:{viewId:"<repo_ID>",groupId:"<group_ID>",roleId:"<role_string>"}) { clientMutationId } }
Available roles can be found on the Organization settings page, Roles section. Copy the string as it is case-sensitive, for example,
admin
,member
, etc. and use it as theroleId
.clientMutationId
is deprecated (will be removed in the future), it's fine that it's null; you don't need it.Get the ID of the user you want to add to the new group:
graphqlquery { users(search:"<user_email>"){ id } }
Use the user ID from step 5 and the group ID from step 2, in the following query (you can add multiple IDs at once, using an array of IDs):
graphqlmutation { addUsersToGroup(input: {users:["<user_ID>"], groupId:"<group_ID>"}) { clientMutationId } }
Go to the UI Organization settings section to check that the process has been successful.