Jobs

class zos_jobs.zowe.zos_jobs_for_zowe_sdk.Jobs(connection)

Class used to represent the base z/OSMF Jobs API.

connection

Connection object

cancel_job(jobname: str, jobid: str, modify_version='2.0')

Cancels the a job

Parameters:
  • jobname (str) – The name of the job

  • jobid (str) – The job id on JES

  • modify_version (str) – Default (“2.0”) specifies that the request is to be processed synchronously. For asynchronous processing - change the value to “1.0”

Returns:

A JSON object containing the result of the request execution

Return type:

response_json

change_job_class(jobname: str, jobid: str, class_name: str, modify_version='2.0')

Changes the job class

Parameters:
  • jobname (str) – The name of the job

  • jobid (str) – The job id on JES

  • modify_version (str) – Default (“2.0”) specifies that the request is to be processed synchronously. For asynchronous processing - change the value to “1.0”

Returns:

A JSON object containing the result of the request execution

Return type:

response_json

delete_job(jobname, jobid, modify_version='2.0')

Delete the given job on JES.

Parameters:
  • jobname (str) – The name of the job

  • jobid (str) – The job id on JES

  • modify_version (str) – Default (“2.0”) specifies that the request is to be processed synchronously. For asynchronous processing - change the value to “1.0”

Returns:

A JSON object containing the result of the request execution

Return type:

response_json

get_jcl_text(correlator)

Retrieve the input JCL text for job with specified correlator :param correlator: The correlator of the job. This is the value of the key ‘job-correlator’ in the status json :type correlator: str

Returns:

A JSON object containing the result of the request execution

Return type:

json

get_job_output_as_files(status, output_dir)

This method will get all the spool files as well as the submitted jcl text in separate files in the specified output directory. The structure will be as follows:

–<output directory> | file: jcl.txt | dir: jobname

dir: jobid | dir: stepname | file: spool file <nn> …
Parameters:
  • status (json) – The response json describing the job to be used. (i.e. from the last get_status call)

  • output_dir (str) – The output directory where the output files will be stored. The directory does not have to exist yet

Returns:

A JSON object containing the result of the request execution

Return type:

json

get_job_status(jobname, jobid)

Retrieve the status of a given job on JES.

Parameters:
  • jobname (str) – The name of the job

  • jobid (str) – The job id on JES

Returns:

A JSON object containing the status of the job on JES

Return type:

response_json

get_spool_file_contents(correlator, id)

Retrieve the contents of a single spool file from a job

Parameters:
  • correlator (str) – The correlator of the job. This is the value of the key ‘job-correlator’ in the status json

  • id (str) – The id number of the spool file. This is returned in the get_spool_files return json

Returns:

A JSON object containing the result of the request execution

Return type:

json

get_spool_files(correlator)

Retrieve the spool files for a job identified by the correlator.

Parameters:

correlator (str) – The correlator of the job. This is the value of the key ‘job-correlator’ in the status json

Returns:

A JSON object containing the result of the request execution

Return type:

json

hold_job(jobname: str, jobid: str, modify_version='2.0')

Hold the given job on JES

Parameters:
  • jobname (str) – The name of the job

  • jobid (str) – The job id on JES

  • modify_version (str) – Default (“2.0”) specifies that the request is to be processed synchronously. For asynchronous processing - change the value to “1.0”

Returns:

A JSON object containing the result of the request execution

Return type:

response_json

list_jobs(owner=None, prefix='*', max_jobs=1000, user_correlator=None)

Retrieve list of jobs on JES based on the provided arguments.

Parameters:
  • owner (str, optional) – The job owner (default is zosmf user)

  • prefix (str, optional) – The job name prefix (default is *)

  • max_jobs (int, optional) – The maximum number of jobs in the output (default is 1000)

  • user_correlator (str, optional) – The z/OSMF user correlator attribute (default is None)

Returns:

A JSON object containing a list of jobs on JES queue based on the given parameters

Return type:

json

release_job(jobname: str, jobid: str, modify_version='2.0')

Release the given job on JES

Parameters:
  • jobname (str) – The name of the job

  • jobid (str) – The job id on JES

  • modify_version (str) – Default (“2.0”) specifies that the request is to be processed synchronously. For asynchronous processing - change the value to “1.0”

Returns:

A JSON object containing the result of the request execution

Return type:

response_json

submit_from_local_file(jcl_path)

Submit a job from local file.

This function will internally call the submit_plaintext function in order to submit the contents of the given input file

Parameters:

jcl_path (str) – Path to the local file where the JCL is located

Raises:

FileNotFoundError – If the local file provided is not found

Returns:

A JSON object containing the result of the request execution

Return type:

json

submit_from_mainframe(jcl_path)

Submit a job from a given dataset.

Parameters:

jcl_path (str) – The dataset where the JCL is located

Returns:

A JSON object containing the result of the request execution

Return type:

json

submit_plaintext(jcl)

Submit a job from plain text input.

Parameters:

jcl (str) – The plain text JCL to be submitted

Returns:

A JSON object containing the result of the request execution

Return type:

json