Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add exec-data option in zowe jobs list jobs command #1354

Merged
merged 19 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the Zowe CLI package will be documented in this file.

## Recent Changes

- Enhancement: Added the `exec-data` option for `zowe jobs list jobs` command to return execution data about the job in addition to the default information. [#1158](https://github.com/zowe/zowe-cli/issues/1158)

## `6.39.0`

- BugFix: Provided more accurate output for `zowe zos-jobs delete job` and `zowe zos-jobs cancel job` commands [#1333](https://github.com/zowe/zowe-cli/issues/1333)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ Object {
"description": "List all jobs with default owner and prefix settings, displaying only the job ID of each job",
"options": "--rff jobid --rft table",
},
Object {
"description": "List all jobs and return job execution data along with the default information",
"options": "--exec-data",
},
Object {
"description": "List all jobs owned by user IDs starting with 'ibmu' and return job execution data along with the default information",
"options": "-o \\"ibmu*\\" --exec-data",
},
Object {
"description": "List all jobs owned by user IDs starting with 'ibmu' and job names starting with 'myjo' and return job execution data along with the default information",
"options": "-o \\"ibmu*\\" -p \\"myjo*\\" --exec-data",
},
],
"name": "jobs",
"options": Array [
Expand All @@ -38,6 +50,15 @@ Object {
"name": "prefix",
"type": "string",
},
Object {
"aliases": Array [
"ed",
],
"default": false,
"description": "Use this option to retrieve execution data for jobs via the z/OSMF REST API.",
"name": "exec-data",
"type": "boolean",
},
],
"outputFormatOptions": true,
"profile": Object {
Expand Down
19 changes: 19 additions & 0 deletions packages/cli/src/zosjobs/list/jobs/Jobs.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export const JobsDefinition: ICommandDefinition = {
"You can specify a wildcard according to the z/OSMF Jobs REST endpoint documentation, " +
"which is usually in the form \"JOB*\".",
type: "string"
},
{
name: "exec-data", aliases: ["ed"],
description: "Use this option to retrieve execution data for jobs via the z/OSMF REST API.",
type: "boolean",
default: false
}
] as ICommandOptionDefinition[]),
profile: {
Expand All @@ -58,6 +64,19 @@ export const JobsDefinition: ICommandDefinition = {
{
options: "--rff jobid --rft table",
description: "List all jobs with default owner and prefix settings, displaying only the job ID of each job"
},
{
options: "--exec-data",
description: "List all jobs and return job execution data along with the default information"
},
{
options: "-o \"ibmu*\" --exec-data",
description: "List all jobs owned by user IDs starting with 'ibmu' and return job execution data along with the default information"
},
{
options: "-o \"ibmu*\" -p \"myjo*\" --exec-data",
description: "List all jobs owned by user IDs starting with 'ibmu' and job names starting with 'myjo' and \
return job execution data along with the default information"
}
],
outputFormatOptions: true
Expand Down
25 changes: 18 additions & 7 deletions packages/cli/src/zosjobs/list/jobs/Jobs.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,28 @@ export default class JobsHandler extends ZosmfBaseHandler {
// Obtain the list of jobs - by default uses the session user and * for owner and prefix.
const owner: string = (params.arguments.owner != null) ? params.arguments.owner : null;
const prefix: string = (params.arguments.prefix != null) ? params.arguments.prefix : JobsConstants.DEFAULT_PREFIX;
const jobs: IJob[] = await GetJobs.getJobsCommon(this.mSession, {owner, prefix});
const execData: boolean = params.arguments.execData;
const jobs: IJob[] = await GetJobs.getJobsCommon(this.mSession, {owner, prefix, execData});

// Populate the response object
params.response.data.setObj(jobs);
params.response.data.setMessage(`List of jobs returned for prefix "${prefix}" and owner "${owner}"`);

// Format the output with the default fields
params.response.format.output({
fields: ["jobid", "retcode", "jobname", "status"],
output: jobs,
format: "table"
});
if (!params.arguments.execData) {
// Format the output with the default fields
params.response.format.output({
fields: ["jobid", "retcode", "jobname", "status"],
output: jobs,
format: "table"
});
}
else {
// Format the output with the fields showing execution data
params.response.format.output({
fields: ["jobid", "retcode", "jobname", "status", "exec-system", "exec-member", "exec-submitted", "exec-started", "exec-ended"],
output: jobs,
format: "table"
t1m0thyj marked this conversation as resolved.
Show resolved Hide resolved
});
}
}
}
6 changes: 5 additions & 1 deletion packages/zosjobs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the Zowe z/OS jobs SDK package will be documented in this file.

## Recent Changes

- Enhancement: Added the `exec-data` option for `zowe jobs list jobs` command to return execution data about the job in addition to the default information. [#1158](https://github.com/zowe/zowe-cli/issues/1158)

## `6.39.0`

- Enhancement: Updated the `cancelJobs` and `deleteJobs` functions to return an IJobFeedback object
Expand Down Expand Up @@ -34,4 +38,4 @@ All notable changes to the Zowe z/OS jobs SDK package will be documented in this

## `6.24.0`

- Initial release
- Initial release
28 changes: 28 additions & 0 deletions packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,34 @@ describe("GetJobs tests", () => {
});
GetJobs.getJobsCommon(pretendSession, {owner: "fakeOwner", prefix: "fakePrefix", maxJobs: 2, jobid: "fakeID"});
});

it("should get a list of jobs from getJobsCommon with their execution data", async () => {
(ZosmfRestClient.getExpectJSON as any) = mockGetJobsJSONData([GetJobsData.SAMPLE_COMPLETE_JOB, GetJobsData.SAMPLE_ACTIVE_JOB]);

const jobCommon = await GetJobs.getJobsCommon(pretendSession, {execData: true});
expect(jobCommon).toMatchSnapshot();
});

it("should get a list of jobs from getJobsCommon with their execution data with maxJobs param", async () => {
(ZosmfRestClient.getExpectJSON as any) = mockGetJobsJSONData([GetJobsData.SAMPLE_COMPLETE_JOB, GetJobsData.SAMPLE_ACTIVE_JOB]);

const jobCommon = await GetJobs.getJobsCommon(pretendSession, {maxJobs: 2, execData: true});
expect(jobCommon).toMatchSnapshot();
});

it("should get a list of jobs from getJobsCommon with their execution data with owner and maxJobs params", async () => {
(ZosmfRestClient.getExpectJSON as any) = mockGetJobsJSONData([GetJobsData.SAMPLE_COMPLETE_JOB, GetJobsData.SAMPLE_ACTIVE_JOB]);

const jobCommon = await GetJobs.getJobsCommon(pretendSession, {owner: "someOwner", maxJobs: 2, execData: true});
expect(jobCommon).toMatchSnapshot();
});

it("should get a list of jobs from getJobsCommon with their execution data with multiple other params", async () => {
(ZosmfRestClient.getExpectJSON as any) = mockGetJobsJSONData([GetJobsData.SAMPLE_COMPLETE_JOB, GetJobsData.SAMPLE_ACTIVE_JOB]);

const jobCommon = await GetJobs.getJobsCommon(pretendSession, {owner: "someOwner", prefix: "fakePrefix", maxJobs: 2, execData: true});
expect(jobCommon).toMatchSnapshot();
});
});

describe("getJcl APIs", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,146 @@ Array [
]
`;

exports[`GetJobs tests getJobs APIs should get a list of jobs from getJobsCommon with their execution data 1`] = `
Array [
Object {
"class": "A",
"files-url": "www.nowhere.com/restjobs/jobs/files",
"job-correlator": "123545asdfadf",
"jobid": "TSUxxx",
"jobname": "IBMUSER$",
"owner": "IBMUSER",
"phase": 88,
"phase-name": "testagain",
"retcode": "CC 0000",
"status": "OUTPUT",
"subsystem": "JES2",
"type": "job",
"url": "www.nowhere.com/restjobs/jobs",
},
Object {
"class": "A",
"files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files",
"job-correlator": "J0003781USILDAMDD3CE8146.......:",
"jobid": "JOB03781",
"jobname": "KELDA16$",
"owner": "KELDA16",
"phase": 130,
"phase-name": "Job is actively converting",
"retcode": null,
"status": "INPUT",
"subsystem": "JES2",
"type": "JOB",
"url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A",
},
]
`;

exports[`GetJobs tests getJobs APIs should get a list of jobs from getJobsCommon with their execution data with maxJobs param 1`] = `
Array [
Object {
"class": "A",
"files-url": "www.nowhere.com/restjobs/jobs/files",
"job-correlator": "123545asdfadf",
"jobid": "TSUxxx",
"jobname": "IBMUSER$",
"owner": "IBMUSER",
"phase": 88,
"phase-name": "testagain",
"retcode": "CC 0000",
"status": "OUTPUT",
"subsystem": "JES2",
"type": "job",
"url": "www.nowhere.com/restjobs/jobs",
},
Object {
"class": "A",
"files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files",
"job-correlator": "J0003781USILDAMDD3CE8146.......:",
"jobid": "JOB03781",
"jobname": "KELDA16$",
"owner": "KELDA16",
"phase": 130,
"phase-name": "Job is actively converting",
"retcode": null,
"status": "INPUT",
"subsystem": "JES2",
"type": "JOB",
"url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A",
},
]
`;

exports[`GetJobs tests getJobs APIs should get a list of jobs from getJobsCommon with their execution data with multiple other params 1`] = `
Array [
Object {
"class": "A",
"files-url": "www.nowhere.com/restjobs/jobs/files",
"job-correlator": "123545asdfadf",
"jobid": "TSUxxx",
"jobname": "IBMUSER$",
"owner": "IBMUSER",
"phase": 88,
"phase-name": "testagain",
"retcode": "CC 0000",
"status": "OUTPUT",
"subsystem": "JES2",
"type": "job",
"url": "www.nowhere.com/restjobs/jobs",
},
Object {
"class": "A",
"files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files",
"job-correlator": "J0003781USILDAMDD3CE8146.......:",
"jobid": "JOB03781",
"jobname": "KELDA16$",
"owner": "KELDA16",
"phase": 130,
"phase-name": "Job is actively converting",
"retcode": null,
"status": "INPUT",
"subsystem": "JES2",
"type": "JOB",
"url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A",
},
]
`;

exports[`GetJobs tests getJobs APIs should get a list of jobs from getJobsCommon with their execution data with owner and maxJobs params 1`] = `
Array [
Object {
"class": "A",
"files-url": "www.nowhere.com/restjobs/jobs/files",
"job-correlator": "123545asdfadf",
"jobid": "TSUxxx",
"jobname": "IBMUSER$",
"owner": "IBMUSER",
"phase": 88,
"phase-name": "testagain",
"retcode": "CC 0000",
"status": "OUTPUT",
"subsystem": "JES2",
"type": "job",
"url": "www.nowhere.com/restjobs/jobs",
},
Object {
"class": "A",
"files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files",
"job-correlator": "J0003781USILDAMDD3CE8146.......:",
"jobid": "JOB03781",
"jobname": "KELDA16$",
"owner": "KELDA16",
"phase": 130,
"phase-name": "Job is actively converting",
"retcode": null,
"status": "INPUT",
"subsystem": "JES2",
"type": "JOB",
"url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A",
},
]
`;

exports[`GetJobs tests getJobs APIs should get jobs by owner 1`] = `
Array [
Object {
Expand Down
7 changes: 6 additions & 1 deletion packages/zosjobs/src/GetJobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ export class GetJobs {
}
query += (JobsConstants.QUERY_JOBID + parms.jobid);
}
if (parms.execData) {
if (RestClient.hasQueryString(query)) {
query += JobsConstants.COMBO_ID;
}
query += (JobsConstants.EXEC_DATA);
}
}

let resource = JobsConstants.RESOURCE;
Expand Down Expand Up @@ -354,5 +360,4 @@ export class GetJobs {
Logger.getAppLogger().info("GetJobs.getSpoolContentCommon() parameters: " + parameters);
return ZosmfRestClient.getExpectString(session, JobsConstants.RESOURCE + parameters, [Headers.TEXT_PLAIN_UTF8]);
}

}
9 changes: 8 additions & 1 deletion packages/zosjobs/src/JobsConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* @class JobsConstants
*/
export class JobsConstants {

/**
* Step data query string
* @static
Expand Down Expand Up @@ -133,4 +132,12 @@ export class JobsConstants {
* @memberof JobsConstants
*/
public static readonly DEFAULT_CANCEL_VERSION = "1.0";

/**
* Execution data query string
* @static
* @type {string}
* @memberof JobsConstants
*/
public static readonly EXEC_DATA: string = "exec-data=Y";
}
7 changes: 7 additions & 0 deletions packages/zosjobs/src/doc/input/IGetJobsParms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,11 @@ export interface IGetJobsParms {
* @memberof IJob
*/
jobid?: string;

/**
* Return execution data about jobs
* @type {boolean}
* @memberof IGetJobsParms
*/
execData?: boolean;
}