To use or attempt to use or offer to use force or violence upon or toward the person of another is not unlawful if necessarily committed by a public officer in the performance of any legal duty or by any other person assisting the public officer or acting by the public officer's direction.
SDCL 22-18-2