It was an attack on military personnel of the army which illegally occupies East Jerusalem and other Palestinian territory. Instead of worrying about Hamas, how about working to end the occupation, thereby rendering Hamas unnecessary? Until the occupation ends, Palestinians will have every right to resist the Israeli military by force. 

Israeli retaliation-- collective punishment-- is just another war crime.