Created internal directory cannot be deleted

Hello,

I’m trying to find out why an internal Jira directory I create programmatically cannot be deleted. I can successfully create it using next code:

Set<OperationType> set = new HashSet<>(
  Arrays.asList(CREATE_USER,
                CREATE_GROUP,
                CREATE_ROLE,
                UPDATE_USER,
                UPDATE_GROUP,
                UPDATE_ROLE,
                UPDATE_USER_ATTRIBUTE,
                UPDATE_GROUP_ATTRIBUTE,
                UPDATE_ROLE_ATTRIBUTE,
                DELETE_USER,
                DELETE_GROUP,
                DELETE_ROLE));

DirectoryImpl directory = new DirectoryImpl("DIRECTORY_NAME",
INTERNAL, InternalDirectory.class.getName());

directory.setAllowedOperations(set);

Map<String, String> directoryAttributes = new HashMap<>();
directoryAttributes.put(DirectoryImpl.ATTRIBUTE_KEY_USER_ENCRYPTION_METHOD, "atlassian-security");
directoryAttributes.put(DirectoryImpl.ATTRIBUTE_KEY_USE_NESTED_GROUPS, "false");
directory.setAttributes(directoryAttributes);

Directory newDirectory = crowdDirectoryService.addDirectory(directory);

The problem is that when I disable it in the Jira UI the button “Remove” does not appear. I was trying to see whether I’m missing any directory attributes but didn’t find anything in the Java API documentation. I know that it can be removed programmatically but would prefer to leave this activity to application itself.

It’s not possible to create multiple Jira Internal Directories within the application. So I assume the application is designed in such a way that manually creating Jira Internal Directories is not possible (creates one for you initially) and that you can’t remove the one it comes with.

But then there is a whole public class to use to manipulate with user directories, including “Internal” type. It doesn’t make sense to prohibit such creation but leave all tools in place to be used.