<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">

<document>
  <header>
    <title>POST pig </title>
  </header>

  <body>
  <section>
   <title>Description</title>
    <p>Create and queue a <a href="http://pig.apache.org/">Pig</a> job.</p>
  </section>

  <section>
   <title>URL</title>
    <p><code>http://</code>www.myserver.com<code>/templeton/v1/pig</code></p>
  </section>

  <section>
   <title>Parameters</title>
    <table>
    <tr><th>Name</th><th>Description</th><th>Required?</th><th>Default</th></tr>

    <tr><td><strong>execute</strong></td>
        <td>String containing an entire, short pig program to run.</td>
        <td>One of either "execcute" or "file" is required</td>
        <td>None</td>
    </tr>

    <tr><td><strong>file</strong></td>
        <td>HDFS file name of a pig program to run.</td>
        <td>One of either "exec" or "file" is required</td>
        <td>None</td>
    </tr>

    <tr><td><strong>arg</strong></td>
        <td>Set a program argument.</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>files</strong></td>
        <td>Comma separated files to be copied to the map reduce cluster</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>statusdir</strong></td>
        <td>A directory where Templeton will write the status of the
         Pig job.  If provided, it is the caller's responsibility
         to remove this directory when done.</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>enablelog</strong></td>
        <td>Collecting hadoop job config and logs into $statusdir/logs folder.
         statusdir must be set as well to use this feature.</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>callback</strong></td>
        <td>Define a URL to be called upon job completion. You may embed a specific
         job ID into this URL using <code>$jobId</code>.  This tag
         will be replaced in the callback URL with this job's job ID.</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    </table>
  </section>

  <section>
   <title>Results</title>
     <table>
      <tr><th>Name</th><th>Description</th></tr>

      <tr><td><strong>id</strong></td>
        <td>A string containing the job ID similar to "job_201110132141_0001".</td>
      </tr>

      <tr><td><strong>info</strong></td>
        <td>A JSON object containing the information returned when the job was queued.
            See the Hadoop documentation
            (<a href="http://hadoop.apache.org/common/docs/stable/api/org/apache/hadoop/mapred/TaskController.html">Class
            TaskController</a>) for more information.</td>
      </tr>
     </table>
  </section>

  <section>
   <title>Example</title>

  <p><strong>Code and Data Setup</strong></p>
<source>
% cat id.pig
A = load 'passwd' using PigStorage(':');
B = foreach A generate $0 as id;
dump B;

% cat fake-passwd
ctdean:Chris Dean:secret
pauls:Paul Stolorz:good
carmas:Carlos Armas:evil
dra:Deirdre McClure:marvelous

% hadoop fs -put id.pig .
% hadoop fs -put fake-passwd passwd
</source>

   <p><strong>Curl Command</strong></p>
<source>
% curl -s -d user.name=ctdean \
       -d file=id.pig \
       -d arg=-v \
       'http://localhost:50111/templeton/v1/pig'
</source>

   <p><strong>JSON Output</strong></p>
<source>
{
 "id": "job_201111101627_0018",
 "info": {
          "stdout": "templeton-job-id:job_201111101627_0018
                    ",
          "stderr": "",
          "exitcode": 0
         }
}
</source>
  </section>
  </body>
</document>
