There's a couple of variants of this story - What kind of configuration options do you want? Would you like to build the job programmatically, or have it somewhere on disk as a .analysis.xml file? Will you be doing any processing of the result, or will the job itself contain all the necesary logic.
The various steps and options are depicted in the diagram below. In the following sections we'll go through each of the 4 steps/columns in the diagram: