Wales survived losing Andy King to a red card early in the second-half to beat Cyprus 2-1 at the Cardiff City Stadium.