Skip to content

Commit

Permalink
Add encoding to Submit Jobs CLI and APIs
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
  • Loading branch information
awharn committed May 13, 2024
1 parent e8518da commit 4c75f96
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 72 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,36 @@ Object {
"name": "jcl-symbols",
"type": "string",
},
Object {
"aliases": Array [
"je",
],
"description": "The encoding that should be used to read the JCL into the z/OSMF JCL reader. JCL will be converted into this codepage from UTF-8 for the JES subsystem to parse.",
"name": "job-encoding",
"type": "string",
},
Object {
"aliases": Array [
"jrl",
],
"description": "The logical record length of the submitted JCL. Defaults to 80 if not supplied.",
"name": "job-record-length",
"type": "number",
},
Object {
"aliases": Array [
"jrf",
],
"allowableValues": Object {
"values": Array [
"F",
"V",
],
},
"description": "The record format of the JCL being submitted, where V is variable, and F is fixed. Defaults to F if not supplied.",
"name": "job-record-format",
"type": "string",
},
],
"outputFormatOptions": true,
"positionals": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,36 @@ Object {
"name": "jcl-symbols",
"type": "string",
},
Object {
"aliases": Array [
"je",
],
"description": "The encoding that should be used to read the JCL into the z/OSMF JCL reader. JCL will be converted into this codepage from UTF-8 for the JES subsystem to parse.",
"name": "job-encoding",
"type": "string",
},
Object {
"aliases": Array [
"jrl",
],
"description": "The logical record length of the submitted JCL. Defaults to 80 if not supplied.",
"name": "job-record-length",
"type": "number",
},
Object {
"aliases": Array [
"jrf",
],
"allowableValues": Object {
"values": Array [
"F",
"V",
],
},
"description": "The record format of the JCL being submitted, where V is variable, and F is fixed. Defaults to F if not supplied.",
"name": "job-record-format",
"type": "string",
},
],
"outputFormatOptions": true,
"profile": Object {
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/src/zosjobs/-strings-/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ export default {
"For symbol values with no spaces: \"symbol1=value1 symbol2=value2 ...\". " +
"When a value contains spaces, enclose the value in single quotes: " +
"\"symbol1='value 1 with spaces' symbol2='value 2 with spaces' ...\". " +
"To embed a single quote in a value, use two single quotes: \"NAME=O''Brian\"."
"To embed a single quote in a value, use two single quotes: \"NAME=O''Brian\".",
JOB_ENCODING: "The encoding that should be used to read the JCL into the z/OSMF JCL reader. " +
"JCL will be converted into this codepage from UTF-8 for the JES subsystem to parse.",
JOB_RECORD_LENGTH: "The logical record length of the submitted JCL. Defaults to 80 if not supplied.",
JOB_RECORD_FORMAT: "The record format of the JCL being submitted, where V is variable, and F is fixed. " +
"Defaults to F if not supplied."
},
DATA_SET: {
SUMMARY: "Submit a job contained in a data set",
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/zosjobs/submit/Submit.shared.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export default class SharedSubmitHandler extends ZosmfBaseHandler {
waitForActive: this.mArguments.waitForActive,
waitForOutput: this.mArguments.waitForOutput,
task: status,
jclSymbols: this.mArguments.jclSymbols
jclSymbols: this.mArguments.jclSymbols,
internalReaderFileEncoding: this.mArguments.jobEncoding,
internalReaderLrecl: this.mArguments.jobRecordLength,
internalReaderRecfm: this.mArguments.jobRecordFormat
};
const options: IDownloadOptions = {};
params.response.progress.startBar({task: status});
Expand Down
16 changes: 16 additions & 0 deletions packages/cli/src/zosjobs/submit/local-file/localFile.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ export const LocalFileDefinition: ICommandDefinition = {
name: "jcl-symbols", aliases: ["js"],
description: strings.COMMON_OPT.JCL_SYMBOLS,
type: "string"
},
{
name: "job-encoding", aliases: ["je"],
description: strings.COMMON_OPT.JOB_ENCODING,
type: "string"
},
{
name: "job-record-length", aliases: ["jrl"],
description: strings.COMMON_OPT.JOB_RECORD_LENGTH,
type: "number",
},
{
name: "job-record-format", aliases: ["jrf"],
description: strings.COMMON_OPT.JOB_RECORD_FORMAT,
type: "string",
allowableValues: {values: ["F", "V"]}
}
]as ICommandOptionDefinition[]),
profile: {
Expand Down
16 changes: 16 additions & 0 deletions packages/cli/src/zosjobs/submit/stdin/stdin.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ export const StdinDefinition: ICommandDefinition = {
name: "jcl-symbols", aliases: ["js"],
description: strings.COMMON_OPT.JCL_SYMBOLS,
type: "string"
},
{
name: "job-encoding", aliases: ["je"],
description: strings.COMMON_OPT.JOB_ENCODING,
type: "string"
},
{
name: "job-record-length", aliases: ["jrl"],
description: strings.COMMON_OPT.JOB_RECORD_LENGTH,
type: "number",
},
{
name: "job-record-format", aliases: ["jrf"],
description: strings.COMMON_OPT.JOB_RECORD_FORMAT,
type: "string",
allowableValues: {values: ["F", "V"]}
}
] as ICommandOptionDefinition[]),
profile: {
Expand Down
25 changes: 18 additions & 7 deletions packages/zosjobs/src/SubmitJobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,23 @@ export class SubmitJobs {
* @returns {Promise<IJob>} - Promise that resolves to an IJob document with details about the submitted job
* @memberof SubmitJobs
*/
public static submitJcl(session: AbstractSession, jcl: string, internalReaderRecfm?: string, internalReaderLrecl?: string) {
public static submitJcl(session: AbstractSession, jcl: string, internalReaderRecfm?: string,
internalReaderLrecl?: string, internalReaderFileEncoding?: string) {
this.log.trace("submitJcl called with jcl of length %d. internalReaderRecfm %s internalReaderLrecl %s",
jcl == null ? "no jcl!" : jcl.length, internalReaderRecfm, internalReaderLrecl);
return SubmitJobs.submitJclCommon(session, {jcl, internalReaderRecfm, internalReaderLrecl});
return SubmitJobs.submitJclCommon(session, {jcl, internalReaderRecfm, internalReaderLrecl, internalReaderFileEncoding});
}

public static async submitJclString(session: AbstractSession, jcl: string, parms: ISubmitParms): Promise<IJob | ISpoolFile[]> {
ImperativeExpect.toNotBeNullOrUndefined(jcl, ZosJobsMessages.missingJcl.message);
ImperativeExpect.toNotBeEqual(jcl, "", ZosJobsMessages.missingJcl.message);
const responseJobInfo: IJob = await SubmitJobs.submitJclCommon(session, {jcl, jclSymbols: parms.jclSymbols});
const responseJobInfo: IJob = await SubmitJobs.submitJclCommon(session, {
jcl,
jclSymbols: parms.jclSymbols,
internalReaderFileEncoding: parms.internalReaderFileEncoding,
internalReaderLrecl: parms.internalReaderLrecl,
internalReaderRecfm: parms.internalReaderRecfm
});
const response: Promise<IJob | ISpoolFile[]> = this.checkSubmitOptions(session, parms, responseJobInfo);
return response;
}
Expand Down Expand Up @@ -152,6 +159,9 @@ export class SubmitJobs {
const extraHeaders = this.getSubstitutionHeaders(parms.jclSymbols);
headers.push(...extraHeaders);
}
if (parms.internalReaderFileEncoding) {
headers.push({"X-IBM-Intrdr-File-Encoding": parms.internalReaderFileEncoding});

Check warning on line 163 in packages/zosjobs/src/SubmitJobs.ts

View check run for this annotation

Codecov / codecov/patch

packages/zosjobs/src/SubmitJobs.ts#L163

Added line #L163 was not covered by tests
}
return ZosmfRestClient.putExpectJSON<IJob>(session, JobsConstants.RESOURCE, headers, parms.jcl);
}

Expand All @@ -165,10 +175,11 @@ export class SubmitJobs {
* @returns {Promise<IJob>} - Promise that resolves to an IJob document with details about the submitted job
* @memberof SubmitJobs
*/
public static async submitJclNotify(session: AbstractSession, jcl: string, internalReaderRecfm?: string, internalReaderLrecl?: string) {
this.log.trace("submitJclNotiy called with jcl of length %s, internalReaderRecfm %s, internalReaderLrecl %s",
jcl == null ? "no jcl!" : jcl.length, internalReaderRecfm, internalReaderLrecl);
return SubmitJobs.submitJclNotifyCommon(session, {jcl, internalReaderRecfm, internalReaderLrecl});
public static async submitJclNotify(session: AbstractSession, jcl: string, internalReaderRecfm?: string,
internalReaderLrecl?: string, internalReaderFileEncoding?: string) {
this.log.trace("submitJclNotiy called with jcl of length %s, internalReaderRecfm %s, internalReaderLrecl %s, internalReaderFileEncoding %s",
jcl == null ? "no jcl!" : jcl.length, internalReaderRecfm, internalReaderLrecl, internalReaderFileEncoding);
return SubmitJobs.submitJclNotifyCommon(session, {jcl, internalReaderRecfm, internalReaderLrecl, internalReaderFileEncoding});
}

/**
Expand Down
27 changes: 2 additions & 25 deletions packages/zosjobs/src/doc/input/ISubmitJclNotifyParms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
*/

import { JOB_STATUS } from "../../types/JobStatus";
import { ISubmitParmsCommon } from "./ISubmitParmsCommon";

/**
* Interface for submiting jobs API
* @export
* @interface ISubmitJclNotifyParm
*/
export interface ISubmitJclNotifyParm {
export interface ISubmitJclNotifyParm extends ISubmitParmsCommon {

/**
* JCL to submit, for example:
Expand All @@ -27,23 +28,6 @@ export interface ISubmitJclNotifyParm {
*/
jcl: string;

/**
* Specify internal reader RECFM and corresponding http(s) headers
* will be appended to the request accordingly
* "F" (fixed) or "V" (variable)
* @type {string}
* @memberof ISubmitJclNotifyParm
*/
internalReaderRecfm?: string;

/**
* Specify internal reader LRECL and corresponding http(s) headers
* will be appended to the request accordingly
* @type {string}
* @memberof ISubmitJclNotifyParm
*/
internalReaderLrecl?: string;

/**
* Watch delay (polling delay) that the underlying services will use
* to report whenever a job is complete in milliseconds.
Expand All @@ -68,11 +52,4 @@ export interface ISubmitJclNotifyParm {
* @memberof ISubmitJclNotifyParm
*/
attempts?: number;

/**
* A string for JCL symbolic substitution
* @type {string}
* @memberof ISubmitJobParms
*/
jclSymbols?: string;
}
30 changes: 4 additions & 26 deletions packages/zosjobs/src/doc/input/ISubmitJclParms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,21 @@
*
*/

import { ISubmitParmsCommon } from "./ISubmitParmsCommon";

/**
* Interface for submit JCL APIs
* @export
* @interface ISubmitJclParms
*/
export interface ISubmitJclParms {
export interface ISubmitJclParms extends ISubmitParmsCommon {

/**
* JCL to submit, for example:
* "//IEFBR14 JOB ()\n" +
* "//RUN EXEC PGM=IEFBR14"
* @type {string}
* @memberof ISubmitJclNotifyParm
* @memberof ISubmitJclParms
*/
jcl: string;

/**
* Specify internal reader RECFM and corresponding http(s) headers
* will be appended to the request accordingly
* "F" (fixed) or "V" (variable)
* @type {string}
* @memberof ISubmitJclNotifyParm
*/
internalReaderRecfm?: string;

/**
* Specify internal reader LRECL and corresponding http(s) headers
* will be appended to the request accordingly
* @type {string}
* @memberof ISubmitJclNotifyParm
*/
internalReaderLrecl?: string;

/**
* A string for JCL symbolic substitution
* @type {string}
* @memberof ISubmitJobParms
*/
jclSymbols?: string;
}
10 changes: 2 additions & 8 deletions packages/zosjobs/src/doc/input/ISubmitParms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
*/

import { ITaskWithStatus } from "@zowe/imperative";
import { ISubmitParmsCommon } from "./ISubmitParmsCommon";

/**
* Interface for submit job API
* @export
* @interface ISubmitParms
*/
export interface ISubmitParms {
export interface ISubmitParms extends ISubmitParmsCommon {

/**
* USS file which should contain syntactically correct JCL
Expand Down Expand Up @@ -64,11 +65,4 @@ export interface ISubmitParms {
* Optional
*/
task?: ITaskWithStatus;

/**
* A string for JCL symbolic substitution
* @type {string}
* @memberof ISubmitJobParms
*/
jclSymbols?: string;
}
50 changes: 50 additions & 0 deletions packages/zosjobs/src/doc/input/ISubmitParmsCommon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

/**
* Common interface for submit job API
* @export
* @interface ISubmitParms
*/
export interface ISubmitParmsCommon {

/**
* A string for JCL symbolic substitution
* @type {string}
* @memberof ISubmitParms
*/
jclSymbols?: string;

/**
* Specify internal reader file encoding and corresponding http(s) headers
* will be appended to the request accordingly
* @type {string}
* @memberof ISubmitParms
*/
internalReaderFileEncoding?: string;

/**
* Specify internal reader RECFM and corresponding http(s) headers
* will be appended to the request accordingly
* "F" (fixed) or "V" (variable)
* @type {string}
* @memberof ISubmitJclParms
*/
internalReaderRecfm?: string;

/**
* Specify internal reader LRECL and corresponding http(s) headers
* will be appended to the request accordingly
* @type {string}
* @memberof ISubmitJclParms
*/
internalReaderLrecl?: string;
}

0 comments on commit 4c75f96

Please sign in to comment.