Nikki Haley knows how to thread the needle.

And she understands a thing or two about selling books.

The former U.N. ambassador, who obviously wants a political future, is depicting herself as a Trump loyalist—with a few exceptions. Haley knows that if she distances herself too much from the president, she’s toast with today’s Republican Party.

At the same time, she wants to maintain her viability with those who have grown skeptical of the president.

MEDIA ELITE MAY OPPOSE WARREN, BUT SHE SURE GETS GOOD PRESS

In granting exclusives to the Washington Post and CBS “Sunday Morning,” she put out the clickiest of the clickbait: how in her view John Kelly and Rex Tillerson tried to recruit her into a cabal to undermine Trump. Yes, it’s palace intrigue, but it’s pretty intriguing.

In “With All Due Respect,” Haley writes: “Kelly and Tillerson confided in me that when they resisted the president, they weren’t being insubordinate, they were trying to save the country. It was their decisions, not the president’s, that were in the best interests of America, they said. The president didn’t know what he was doing,” Haley wrote of the views the two men held. What’s more, she writes, Tillerson said people would die unless Trump was reined in.

Kelly, the former White House chief of staff, said in a statement that if providing the president “with the best and most open, legal and ethical staffing advice from across the [government] so he could make an informed decision is ‘working against Trump,’ then guilty as charged.”

There have been other books (by Bob Woodward, for instance) and other ex-officials who say they tried to steer the president away from unrealistic or outlandish ideas. If you oppose Trump, you view them as patriots doing the best they can to work within the system. If you support Trump, you view them as rogue operators trying to usurp his authority.

Haley puts herself in the latter camp.

This obviously fuels Trump’s frequent claim that people in his own administration are trying to undermine him. In this case, though, they’re two of his own top appointees rather than members of some nefarious Deep State.

But in the end, they were staff. He’s the guy who got elected. And so they became ex-staff.

SUBSCRIBE TO HOWIE'S MEDIA BUZZMETER PODCAST, A RIFF OF THE DAY'S HOTTEST STORIES

According to the Post, Haley “backed most of the foreign policy decisions by Trump that others tried to block or slow down, including withdrawal from the Iran nuclear deal and the Paris climate accord and the relocation of the U.S. Embassy in Israel to Jerusalem.”

What about impeachment? Here, too, Haley backs Trump but not 100 percent, telling the Post’s Anne Gearan: “So, do I think it’s not good practice to talk to foreign governments about investigating Americans? Yes. Do I think the president did something that warrants impeachment? No, because the aid flowed.” That, of course, is a reference to the $391 million in military aid to Ukraine that Trump held up—and the argument that it doesn’t matter because it was eventually released.

But in a clear bow to the president’s critics, Haley writes that she objected to Trump’s handling of the Helsinki summit with Vladi­mir Putin, as well as his response to the violence in Charlottesville. Reflecting on Trump’s “both sides” comments, Haley writes:

“A leader’s words matter in these situations. And the president’s words had been hurtful and dangerous. I picked up the phone and called the president.”

The most interesting excerpt involves the murder of nine black churchgoers in Charleston, when Haley was South Carolina’s governor. She says she was treated for post-traumatic stress syndrome, including episodes of sobbing, loss of appetite and feelings of guilt.

Joe Scarborough says Haley is auditioning for Mike Pence’s spot on the 2020 ticket. I don’t think there’s an opening there, but as a former governor, ex-diplomat and daughter of Indian immigrants, Haley obviously has potential as a presidential contender down the road.

Perhaps that’s why she wrote a memoir that keeps her in Trump’s camp, criticizes him in selected spots and throws a couple of her former White House colleagues under the bus.