Jobs
- class zos_jobs.zowe.zos_jobs_for_zowe_sdk.Jobs(connection: dict[str, Any], log: bool = True)
Class used to represent the base z/OSMF Jobs API.
It includes all operations related to datasets.
- Parameters:
connection (dict[str, Any]) – A profile for connection in dict (json) format
log (bool) – Flag to disable logger
- cancel_job(jobname: str, jobid: str, modify_version: str = '2.0') StatusResponse
Cancel 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”
- Raises:
ValueError – Thrown if the modify_version is invalid
- Returns:
A JSON object containing the result of the request execution
- Return type:
StatusResponse
- change_job_class(jobname: str, jobid: str, class_name: str, modify_version: str = '2.0') StatusResponse
Change the job class.
- Parameters:
jobname (str) – The name of the job
jobid (str) – The job id on JES
class_name (str) – The name of class to be set to
modify_version (str) – Default (“2.0”) specifies that the request is to be processed synchronously. For asynchronous processing - change the value to “1.0”
- Raises:
ValueError – Thrown if the modify_version is invalid
- Returns:
A JSON object containing the result of the request execution
- Return type:
StatusResponse
- delete_job(jobname: str, jobid: str, modify_version: str = '2.0') StatusResponse
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”
- Raises:
ValueError – Thrown if the modify_version is invalid
- Returns:
A JSON object containing the result of the request execution
- Return type:
StatusResponse
- get_jcl_text(correlator: str) str
Retrieve the input JCL text for job with specified correlator.
- Parameters:
correlator (str) – The correlator of the job. This is the value of the key ‘job-correlator’ in the status json
- Returns:
A str object containing the result of the request execution
- Return type:
str
- get_job_output_as_files(status: dict[str, Any], output_dir: str) None
Get all spool files and 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 (dict[str, Any]) – 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
- get_job_status(jobname: str, jobid: str) JobResponse
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:
JobResponse
- get_spool_file_contents(correlator: str, id: str) str
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:
The contents of the spool file
- Return type:
str
- get_spool_files(correlator: str) list[SpoolResponse]
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:
list[SpoolResponse]
- hold_job(jobname: str, jobid: str, modify_version: str = '2.0') StatusResponse
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”
- Raises:
ValueError – Thrown if the modify_version is invalid
- Returns:
A JSON object containing the result of the request execution
- Return type:
StatusResponse
- list_jobs(owner: str | None = None, prefix: str = '*', max_jobs: int = 1000, user_correlator: str | None = None) list[JobResponse]
Retrieve list of jobs on JES based on the provided arguments.
- Parameters:
owner (Optional[str]) – The job owner (default is zosmf user)
prefix (str) – The job name prefix (default is *)
max_jobs (int) – The maximum number of jobs in the output (default is 1000)
user_correlator (Optional[str]) – The z/OSMF user correlator attribute (default is None)
- Returns:
A list of jobs on JES queue based on the given parameters
- Return type:
list[JobResponse]
- release_job(jobname: str, jobid: str, modify_version: str = '2.0') StatusResponse
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”
- Raises:
ValueError – Thrown if the modify_version is invalid
- Returns:
A JSON object containing the result of the request execution
- Return type:
StatusResponse
- submit_from_local_file(jcl_path: str) JobResponse
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:
JobResponse
- submit_from_mainframe(jcl_path: str) JobResponse
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:
JobResponse
- submit_plaintext(jcl: str) JobResponse
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:
JobResponse