## zowe › ejes › api

Make requests with the (E)JES REST API to the (E)JES API using options that correspond to object models in the (E)JES REST API swagger documentation. You should refer to that document, refer to chapter 10 of the (E)JES Reference, and issue "zowe ejes api init --helpApp" further details.

All responses are returned in JSON format by using the --rfj (--response-format-json) option.

The tools necessary manage the spool with (E)JES are provided. You will be able to download sysout, email it as PDF, and submit jobs from MVS and the local workstation. All downloads are saved to a file in the current working directory, or to the path specified on the EJES_DOWNLOAD_PATH environment variable.

The CLI generates exit codes. 0 indicates the transaction completed, but you should check the output for (E)JES errors. A non-zero exit code below 100 indicates a problem coding an options or a download file filesystem issue. An exit code above 100 is a response code from the host through the API. If use the host host "return" command in the --command option, you will receive a 500 exit code. Use a stateless init request or issue a term request to avoid this result.

This CLI was developed to provide an easy scripting option to avoid coding directly to the REST API. However, it can be used to experiment with the REST API. The --debug option will return the host requests and responses as objects and properties in JSON.

#### Usage

zowe ejes api <command>

Where <command> is one of the following:

#### Examples

- This is an example of a init request to position sysout (to download with a subsequent stateful request) using cookie management. Note the --cookie write option. Most of your stateful transaction scripts will be written this way. The --command option contains (E)JES host commands. Refer to the (E)JES Reference for details of the argument for that option.

Example:

      * `$  zowe ejes api init --cookie write --command "status hrlyjba;1 b"`

- This downloads the above sysout as a pdf using cookie management The -rfj (--request-format-json) output json includes the PDF file name of the sysout.

Example:

      * `$  zowe ejes api exec -d pdf --cc interpret --rfj --cookie read`

- This example uses the same cookie-managed session as above to download another sysout. The --command option argument string runs first, then the download. The order of options does not matter.

Example:

      * `$  zowe ejes api exec -d pdf --cc interpret --command "status hrlyjbb;1b" --rfj --cookie read`

- This terminates the session and deletes the cookie.

Example:

      * `$  zowe ejes api term --cookie read`

- Cancel a long running download. If you had needed to cancel the above download, with cookie management, you would have done it this way. The status is in returned JSON.

Example:

      * `$  zowe ejes api cancel-download --rfj --cookie read`

- Initalize a session by using --command to display the status screen, then output the JCL of the first job. Use --enumValue to request 10 lines. The option -q requests the message array, lines of output, and the function array. Though browsed output is requested, if the first job does not have JCL, the status screen will be returned to show that the job that did not meet the criteria. The --rfj option visualizes the output as JSON. Without it, the CLI returns only the cookie.

  Example:

  - `zowe ejes api init --command "status;1 j" --enumvalue 10 -q message,lines,function --rfj`

- Perform a stateless transaction that submits a job using the --command option. It shows the status of jobs with the same name, sorting so the most recent is shown first. The --enumvalue option is requesting the top 5 lines. The query parameter -q is requesting the message array that will contain the submit result, lines of output, and the array of jobs submitted in this session. The --commanddata option supplies the JCL to submit referred to by the "api-array". The "\n" are line separators an editor would supply.

Example:

      * `$  zowe ejes api exec --command "submit api-array;st iefbr14;sort time d;upd" --enumvalue 5 -q message,lines,submittedJobs --rfj --commanddata "//IEFBR14  JOB IEFBR14,'IEFBR14',CLASS=A,MSGCLASS=H\n//EXEC     EXEC PGM=IEFBR14\n//"`

- Perform the same stateless transaction above but use the --commanddatafile option to use a file on the workstation. If EJES_SUBMIT_PATH is defined in the environment, that will be used as the file path, otherwise the same directory the CLI is run in will be used if a full path is not supplied.

Example:

      * `$  zowe ejes api exec --command "submit api-array;st iefbr14;sort time d;upd" --enumvalue 5 -q message,lines,submittedJobs --rfj --commanddatafile "iefbr14.jcl"`

#### Commands

- cancel-download | c - - Issue a cancel-download request
- exec | e - - Issue an exec request
- init | i - - Issue an init request
- term | t - - Issue a term request