The only logical conclusion is that it was Obama and then CIA director John Iman Brennan. I have
doubts Obama and Brennan knew about the coup d'etat in advance and tipped off Erdogan.
The only way Erdogan was able to suppress the coup so quickly was the help of the CIA.
Or it was a fake coup and he just invented it to round up his political foes and consolidate his grip.