Hi,
I'd like to automatize the configuration of permissions of Insight Objecttype with java or REST api. Is that supported and has anyone an idea how I can do that?
Many thanks!
Hi,
You can use the JAVA API for this. You can use:
class ConfigureFacadeImpl
public void storeActorsForRoleBean(Map<String,Set<String>> newRoleActorBeans,
int roleBeanId)
public List<com.riadalabs.jira.plugins.insight.services.model.RoleBean>findRoleBeansByObjectType(int objectTypeId)
public List<com.riadalabs.jira.plugins.insight.services.model.RoleBean>findRoleBeansByObjectSchema(int objectSchemaId)The method will return a list of RoleBeans, one for each role (example manager, developer and user). The RoleBean will also include the id.
com.riadalabs.jira.plugins.insight.services.model.RoleActorBean;for each user/group. The RoleActorBean includes variable "type" which is either “atlassian-group-role-actor” or “atlassian-user-role-actor” and param "typeParam" which is either userKey or groupName.
Forgot to add the link to the api https://insight-javadoc.riada.io/insight-javadoc-8.6.6/insight-core/
//Puya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Puya, thank you very much for the extremely detailed answer!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have the following code that finds a objectType I want and add a group to each role for that objecttype. If it helps someone then thats great.
import com.atlassian.jira.component.ComponentAccessor
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ConfigureFacade
import com.riadalabs.jira.plugins.insight.services.model.RoleBean
import com.riadalabs.jira.plugins.insight.services.model.MutableObjectTypeBean
import com.riadalabs.jira.plugins.insight.services.model.ObjectTypeBean
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectFacade)
def objectTypeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectTypeFacade)
def configureFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ConfigureFacade
String mnemonic = 'TEST'
Integer schemaId = 5
List parentTypeNames = ['OT1, 'OT2', 'OT3']
String userName = 'myusername'
String groupName = 'jira-users'
String userRoleType = "atlassian-user-role-actor"
String groupRoleType = "atlassian-group-role-actor"
// create sets
Set<String> groupActors = new HashSet<String>()
groupActors.add(groupName)
// get mutable one of the object beans
MutableObjectTypeBean objTypeBean = objectTypeFacade.findObjectTypeBeans(schemaId).find {
it.name == parentTypeNames[1]
}.createMutable()
log.warn(objTypeBean.id)
// find all roles
List<RoleBean> roles = configureFacade.findRoleBeansByObjectType(objTypeBean.id)
roles.each {
// store the actors to role bean
configureFacade.storeActorsForRoleBean([(groupRoleType): groupActors] as java.util.Map, it?.id)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.