CRecordUserDbDeleteRole
Delete a role from the user database.
This message belongs to the session manager API.
{ "id": "6d41016b-041d-4094-945d-8498f0b8f3be", "name": "USER_DB_DELETE_ROLE", "description": "Delete a role.", "slots": [ { "key": "SessionToken", "name": "SESSION_TOKEN", "direction": "REQUEST", "mandatory": "true", "type": "UUID", "description": "The session token." }, { "key": "role", "name": "ROLE_ID", "direction": "REQUEST", "mandatory": "true", "type": "STRING", "description": "The id of the role to delete." } ] }
Example of use of the class CRecordUserDbDeleteRole (after generating)
You need the microservice ID of the session manager:
public static final IId SESSION_MICROSERVICE_ID = CIdFactory.fromObject("ccf168c1-f18b-4229-85f9-24461a19ee6a");
The own SessionToken is needed to verify the authorization for the change.
You need the permission NY_DeleteRole
.
In addition, the role id is required.
private void deleteRole(@NotNull final UUID aToken, @NotNull final String aRoleId) throws CException { final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID); final CRecord record = CRecordUserDbDeleteRole.create(); CRecordUserDbDeleteRole.setSessionToken(record, aToken); CRecordUserDbDeleteRole.setRoleId(record, aRoleId); sendRequest(env, record); }
To catch the response of the request, we need a message handler. We add it in the constructor of the message handler registry.
// constructor: addMessageHandler(CRecordUserDbDeleteRole.ID, this::asyncDeleteRole);
private boolean asyncDeleteRole(@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) { if (aEnvelope.isAnswer()) { final int resultCode = aEnvelope.getResultCode(); if (resultCode == CResultCode.SUCCESS) { // ... } return true; } return false; }