Collibra Roles
We have a use case where we want to assign temporary role within a workflow and retract the role when the workflow gets over.
Use Case: An approval workflow is triggered on a system, as part of the workflow a temporary role is assigned to a selected person on the said system and related assets (ex: database, table, column). Once the person acknowledges completion of the task, the role is retracted.
Would love to hear the thoughts of the people on how to do this temp role assignment on selected asset (and related assets)
shivamsharma
Posted 5 years ago · Edited 1 year ago·Last reply 5 years ago
8 comments
arthurburkhardt
·5 years ago · EditedAlso, quick tip for everyone: Use the java library (https://productresources.collibra.com/downloads/2021-01/, dgc-core-2021.01.0-12-apiv2.jar) in Eclipse, it provides all the autocomplete and information you need.
arthurburkhardt
·5 years ago · EditedYour problem is clearly with
.resourceType(rel.type)you need to use instead
.resourceType(rel.resourceType)You can find more doc here https://developer.collibra.com/developer-tutorials/1082277/, and you should look into a coaching session for such topics.
shivamsharma
OP5 years ago · EditedThank you. This made it work.
shivamsharma
OP5 years ago · Edited@arvind.singh Really appreciate your response! The code that you provided wasn’t executing so i made a few minor changes but i still get the below error:
Will be grateful if you could provide some feedback
Log Error
Caused by: groovy.lang.MissingMethodException: No signature of method: com.collibra.dgc.core.api.dto.instance.responsibility.AddResponsibilityRequest$Builder.resourceType() is applicable for argument types: (com.collibra.dgc.core.api.model.reference.impl.ResourceReferenceImpl) values: [ResourceReferenceImpl{id=00000000-0000-0000-0000-000000007042, resourceType=RelationType}]
Possible solutions: resourceType(com.collibra.dgc.core.api.model.ResourceType), resourceId(java.util.UUID)
Code I used
import com.collibra.dgc.core.api.model.instance.Asset
import com.collibra.dgc.core.api.model.instance.Relation
import com.collibra.dgc.core.api.model.ResourceType
import com.collibra.dgc.core.api.dto.instance.responsibility.AddResponsibilityRequest
import com.collibra.dgc.core.api.dto.instance.relation.FindRelationsRequest
import com.collibra.dgc.core.api.dto.user.FindUsersRequest
/* To get relation id for relation between assets. Current asset is target in the relation */
def relationTypeIdVar =string2Uuid(‘00000000-0000-0000-0000-000000007042’) // relation of column(Source) is part of table(target)
List relationList = relationApi.findRelations(FindRelationsRequest.builder()
.targetId(item.id)
.relationTypeId(relationTypeIdVar)
.build()).getResults()
/The user executing the workflow will be assigned the relevant role on the source assets/
def userName = execution.getVariable(“startUser”)
def user = userApi.findUsers(FindUsersRequest.builder().name(userName).build())
.getResults().first()
if(relationList){
for(rel in relationList){
responsibilityApi.addResponsibility(AddResponsibilityRequest.builder()
.ownerId(user.id)
.resourceId(rel.id)
.roleId(string2Uuid(‘0debbf09-2324-4fa2-993a-bfcf960aca81’))
.resourceType(rel.type)
.build())
}
}
Thank You!
shivamsharma
OP5 years ago · Edited@pranay.mahendra Hi Pranay, just following up on this thread, do you have any suggestions on the approach/API to use to get all asset ids related to a selected asset. Reason being the temporary role assignment has to be on the selected asset AND its related assets based on defined relation to look for.
Shivam
arvindsingh
·5 years ago · Edited@shivam_sharma49
import com.collibra.dgc.core.api.model.ResourceType
import com.collibra.dgc.core.api.dto.instance.responsibility.AddResponsibilityRequest
import com.collibra.dgc.core.api.dto.instance.relation.FindRelationsRequest
/* Here is how we can get relation id for relation between assets. You have check whether your current asset is a source or target in that relation. In this example, it’s a source. /
def relationTypeIdVar =string2Uuid('00000-0000-0000-*****’) // put relationType Resource Id here.
relationList=relationApi.findRelations(FindRelationsRequest.builder()
.sourceId(item.getId())
.relationTypeId(relationTypeIdVar)
.build()).getResults()
if(relationList){
For(rel in relationList){
responsibilityApi.addResponsibility(AddResponsibilityRequest.builder()
.ownerId(user.id) //you can use userApi to get user based on conditions.
.resourceId(rel.getTarget().getId()) //assuming you want to want to assign this responsibility to target asset.
.roleId(string2Uuid(roleId))
.resourceType(resourceType) //get resource type based on your target asset. try rel.getTargetType().getResourceType()
.build())
}
}
I haven’t tested it. But, it should work!
shivamsharma
OP5 years ago · EditedThanks Pranay, I ll try this out.
Shivam
pmahend3
·5 years ago · EditedHi Shivam,
This is an interesting usecase. You should be able to implement this by setting the roleId as a static precondition at the beginning of the workflow. When the approval workflow is kicked off and the initiator picks the approver from a list, you can use the addResponsibility method to add the approver to the role for the asset in question and then assign the task to them. Once they complete the task, you can then use the removeResponsibility method of clean up this assignment. Note that these methods are part of the ResponsibilityApi interface and this will add to the history of the asset in question. I hope this helps.
Cheers