template.getCoreConfiguration().getConfiguration(true).setId(repoId);
template.getCoreConfiguration().getConfiguration(true).setName(repoId + "-name");
template.getCoreConfiguration().getConfiguration(true).setIndexable(false); // disable index
template.getCoreConfiguration().getConfiguration(true).setSearchable(false); // disable index
M2Repository m2Repo = (M2Repository) template.create();
repoRegistry.addRepository(m2Repo);
m2Repo.setRemoteUrl(remoteUrl);
m2Repo.setRemoteAuthenticationSettings(new UsernamePasswordRemoteAuthenticationSettings("admin", "admin"));
m2Repo.commitChanges();