Sign new node cert and assign classes

Hello

I am in the process of automating provisioning workflow.

I need to make remote call to the API to do the following

  1. Sign cert for the new node
  2. Assign specific classes to this new node

I have not used the foreman API before, so would appreciate any help with
this.
If there is a better way to automate this, I am open to this as well.

Thank you