From b603659fd31d1a1dd60a1f7dc173440f2a57fd2b Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 5 Mar 2025 13:54:20 -0500 Subject: [PATCH 01/11] feat: add hold and release to zowex Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- doc/apis.md | 4 ++-- native/c/zowex.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/doc/apis.md b/doc/apis.md index 9002ba55..8eddabe9 100644 --- a/doc/apis.md +++ b/doc/apis.md @@ -78,8 +78,8 @@ | _Submit job_ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | | _Delete job_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | Cancel job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ 1 | -| Hold job | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | -| Release job | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| Hold job | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | +| Release job | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | | Change job class | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ➖ | 1. Does not support force, restart, dump, or purge diff --git a/native/c/zowex.cpp b/native/c/zowex.cpp index 82ec5495..8e6de297 100644 --- a/native/c/zowex.cpp +++ b/native/c/zowex.cpp @@ -44,6 +44,8 @@ int handle_job_submit(ZCLIResult); int handle_job_submit_jcl(ZCLIResult); int handle_job_delete(ZCLIResult); int handle_job_cancel(ZCLIResult); +int handle_job_hold(ZCLIResult); +int handle_job_release(ZCLIResult); int handle_console_issue(ZCLIResult); @@ -340,6 +342,20 @@ int main(int argc, char *argv[]) job_cancel.get_options().push_back(job_cancel_restart); job_group.get_verbs().push_back(job_cancel); + ZCLIVerb job_hold("hold"); + job_hold.get_aliases().push_back("hld"); + job_hold.set_description("hold a job"); + job_hold.set_zcli_verb_handler(handle_job_hold); + job_hold.get_positionals().push_back(job_jobid); + job_group.get_verbs().push_back(job_hold); + + ZCLIVerb job_release("release"); + job_release.get_aliases().push_back("rel"); + job_release.set_description("release a job"); + job_release.set_zcli_verb_handler(handle_job_release); + job_release.get_positionals().push_back(job_jobid); + job_group.get_verbs().push_back(job_release); + // // console group // @@ -852,6 +868,46 @@ int handle_job_cancel(ZCLIResult result) return RTNCD_SUCCESS; } +int handle_job_hold(ZCLIResult result) +{ + int rc = 0; + ZJB zjb = {0}; + string jobid(result.get_positional("jobid")->get_value()); + + rc = zjb_hold_by_jobid(&zjb, jobid); + + if (0 != rc) + { + cout << "Error: could not hold job: '" << jobid << "' rc: '" << rc << "'" << endl; + cout << " Details: " << zjb.diag.e_msg << endl; + return RTNCD_FAILURE; + } + + cout << "Job " << jobid << " held " << endl; + + return RTNCD_SUCCESS; +} + +int handle_job_release(ZCLIResult result) +{ + int rc = 0; + ZJB zjb = {0}; + string jobid(result.get_positional("jobid")->get_value()); + + rc = zjb_release_by_jobid(&zjb, jobid); + + if (0 != rc) + { + cout << "Error: could not release job: '" << jobid << "' rc: '" << rc << "'" << endl; + cout << " Details: " << zjb.diag.e_msg << endl; + return RTNCD_FAILURE; + } + + cout << "Job " << jobid << " released " << endl; + + return RTNCD_SUCCESS; +} + int handle_console_issue(ZCLIResult result) { int rc = 0; From e389b12517b41c40e7647fc7be5ac2618ec83f72 Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:09:08 -0500 Subject: [PATCH 02/11] feat: add job hold/release to go layer Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- doc/apis.md | 4 +-- native/golang/cmds/definitions.go | 2 ++ native/golang/cmds/jobs.go | 42 +++++++++++++++++++++++++++ native/golang/types/jobs/requests.go | 14 +++++++++ native/golang/types/jobs/responses.go | 16 ++++++++++ 5 files changed, 76 insertions(+), 2 deletions(-) diff --git a/doc/apis.md b/doc/apis.md index 8eddabe9..225d80f5 100644 --- a/doc/apis.md +++ b/doc/apis.md @@ -78,8 +78,8 @@ | _Submit job_ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | | _Delete job_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | Cancel job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ 1 | -| Hold job | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | -| Release job | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | +| Hold job | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | +| Release job | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | | Change job class | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ➖ | 1. Does not support force, restart, dump, or purge diff --git a/native/golang/cmds/definitions.go b/native/golang/cmds/definitions.go index 96f483b3..a6718bc6 100644 --- a/native/golang/cmds/definitions.go +++ b/native/golang/cmds/definitions.go @@ -53,6 +53,8 @@ func initializeJobHandlers(disp *CmdDispatcher) { "submitJcl": HandleSubmitJclRequest, "cancelJob": HandleCancelJobRequest, "deleteJob": HandleDeleteJobRequest, + "holdJob": HandleHoldJobRequest, + "releaseJob": HandleReleaseJobRequest, } registerHandlers(disp, handlers) } diff --git a/native/golang/cmds/jobs.go b/native/golang/cmds/jobs.go index 2e143000..753a4a61 100644 --- a/native/golang/cmds/jobs.go +++ b/native/golang/cmds/jobs.go @@ -202,6 +202,48 @@ func HandleCancelJobRequest(conn *utils.StdioConn, params []byte) (result any, e return } +// HandleHoldJobRequest holds a job by invoking the `zowex job hold` command +func HandleHoldJobRequest(conn *utils.StdioConn, params []byte) (result any, e error) { + request, err := utils.ParseCommandRequest[jobs.HoldJobRequest](params) + if err != nil { + return nil, err + } + + _, err = conn.ExecCmd([]string{"job", "hold", request.JobId}) + + if err != nil { + e = fmt.Errorf("Failed to hold job: %v", err) + return + } + + result = jobs.HoldJobResponse{ + Success: true, + JobId: request.JobId, + } + return +} + +// HandleReleaseJobRequest releases a job by invoking the `zowex job release` command +func HandleReleaseJobRequest(conn *utils.StdioConn, params []byte) (result any, e error) { + request, err := utils.ParseCommandRequest[jobs.ReleaseJobRequest](params) + if err != nil { + return nil, err + } + + _, err = conn.ExecCmd([]string{"job", "release", request.JobId}) + + if err != nil { + e = fmt.Errorf("Failed to release job: %v", err) + return + } + + result = jobs.ReleaseJobResponse{ + Success: true, + JobId: request.JobId, + } + return +} + // HandleSubmitJobRequest handles a SubmitJobRequest by invoking the `zowex job submit` command func HandleSubmitJobRequest(conn *utils.StdioConn, params []byte) (result any, e error) { request, err := utils.ParseCommandRequest[jobs.SubmitJobRequest](params) diff --git a/native/golang/types/jobs/requests.go b/native/golang/types/jobs/requests.go index ba2dd21f..575fdefb 100644 --- a/native/golang/types/jobs/requests.go +++ b/native/golang/types/jobs/requests.go @@ -84,3 +84,17 @@ type DeleteJobRequest struct { // Job ID to cancel JobId string `json:"jobId"` } + +type HoldJobRequest struct { + common.CommandRequest `tstype:",extends"` + Command string `json:"command" tstype:"\"holdJob\""` + // Job ID to hold + JobId string `json:"jobId"` +} + +type ReleaseJobRequest struct { + common.CommandRequest `tstype:",extends"` + Command string `json:"command" tstype:"\"releaseJob\""` + // Job ID to release + JobId string `json:"jobId"` +} diff --git a/native/golang/types/jobs/responses.go b/native/golang/types/jobs/responses.go index bf693a03..a16b2144 100644 --- a/native/golang/types/jobs/responses.go +++ b/native/golang/types/jobs/responses.go @@ -83,3 +83,19 @@ type CancelJobResponse struct { // The ID for the job that was cancelled JobId string `json:"jobId"` } + +type HoldJobResponse struct { + common.CommandResponse `tstype:",extends"` + // Whether the job was successfully held + Success bool `json:"success"` + // The ID for the job that was held + JobId string `json:"jobId"` +} + +type ReleaseJobResponse struct { + common.CommandResponse `tstype:",extends"` + // Whether the job was successfully released + Success bool `json:"success"` + // The ID for the job that was released + JobId string `json:"jobId"` +} From 7dcf2cdd76027fb752972fd99b36bdb3fd8a748d Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:16:31 -0500 Subject: [PATCH 03/11] feat: add job hold/release for SDK and CLI Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- doc/apis.md | 5 +-- packages/cli/src/hold/Hold.definition.ts | 33 +++++++++++++++++ packages/cli/src/hold/job/Job.definition.ts | 36 +++++++++++++++++++ packages/cli/src/hold/job/Job.handler.ts | 29 +++++++++++++++ .../cli/src/release/Release.definition.ts | 33 +++++++++++++++++ .../cli/src/release/job/Job.definition.ts | 36 +++++++++++++++++++ packages/cli/src/release/job/Job.handler.ts | 29 +++++++++++++++ packages/sdk/src/AbstractRpcClient.ts | 4 +++ packages/sdk/src/doc/gen/jobs.ts | 34 ++++++++++++++++++ 9 files changed, 237 insertions(+), 2 deletions(-) create mode 100644 packages/cli/src/hold/Hold.definition.ts create mode 100644 packages/cli/src/hold/job/Job.definition.ts create mode 100644 packages/cli/src/hold/job/Job.handler.ts create mode 100644 packages/cli/src/release/Release.definition.ts create mode 100644 packages/cli/src/release/job/Job.definition.ts create mode 100644 packages/cli/src/release/job/Job.handler.ts diff --git a/doc/apis.md b/doc/apis.md index 225d80f5..347396ea 100644 --- a/doc/apis.md +++ b/doc/apis.md @@ -78,11 +78,12 @@ | _Submit job_ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | | _Delete job_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | Cancel job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ 1 | -| Hold job | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | -| Release job | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | +| Hold job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ➖ 2 | +| Release job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ➖ 2 | | Change job class | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ➖ | 1. Does not support force, restart, dump, or purge +2. Zowe Explorer does not support the Job Hold/Release operation ## Console diff --git a/packages/cli/src/hold/Hold.definition.ts b/packages/cli/src/hold/Hold.definition.ts new file mode 100644 index 00000000..71bdfd85 --- /dev/null +++ b/packages/cli/src/hold/Hold.definition.ts @@ -0,0 +1,33 @@ +/** + * 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. + * + */ + +import type { ICommandDefinition } from "@zowe/imperative"; +import { SshSession } from "@zowe/zos-uss-for-zowe-sdk"; +import { Constants } from "../Constants"; +import { JobDefinition } from "./job/Job.definition"; + +const HoldDefinition: ICommandDefinition = { + name: "hold", + summary: "Hold jobs", + description: "Hold jobs", + type: "group", + children: [JobDefinition], + passOn: [ + { + property: "options", + value: [...SshSession.SSH_CONNECTION_OPTIONS, Constants.OPT_SERVER_PATH], + merge: true, + ignoreNodes: [{ type: "group" }], + }, + ], +}; + +export = HoldDefinition; diff --git a/packages/cli/src/hold/job/Job.definition.ts b/packages/cli/src/hold/job/Job.definition.ts new file mode 100644 index 00000000..2638fd6a --- /dev/null +++ b/packages/cli/src/hold/job/Job.definition.ts @@ -0,0 +1,36 @@ +/** + * 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. + * + */ + +import type { ICommandDefinition } from "@zowe/imperative"; + +export const JobDefinition: ICommandDefinition = { + handler: `${__dirname}/Job.handler`, + description: "Hold a job", + type: "command", + name: "job", + aliases: ["j"], + summary: "Hold a job", + examples: [ + { + description: "Hold a job", + options: '"TSU00369"', + }, + ], + positionals: [ + { + name: "job-id", + description: "The ID of the job to hold", + type: "string", + required: true, + }, + ], + profile: { optional: ["ssh"] }, +}; diff --git a/packages/cli/src/hold/job/Job.handler.ts b/packages/cli/src/hold/job/Job.handler.ts new file mode 100644 index 00000000..586ecb76 --- /dev/null +++ b/packages/cli/src/hold/job/Job.handler.ts @@ -0,0 +1,29 @@ +/** + * 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. + * + */ + +import type { IHandlerParameters } from "@zowe/imperative"; +import type { ZSshClient, jobs } from "zowe-native-proto-sdk"; +import { SshBaseHandler } from "../../SshBaseHandler"; + +export default class HoldJobHandler extends SshBaseHandler { + public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise { + const jobId = params.arguments.jobId; + const response = await client.jobs.holdJob({ jobId }); + + const msg = `Job "${jobId}" held`; + params.response.data.setMessage(msg); + params.response.data.setObj(response); + if (response.success) { + params.response.console.log(msg); + } + return response; + } +} diff --git a/packages/cli/src/release/Release.definition.ts b/packages/cli/src/release/Release.definition.ts new file mode 100644 index 00000000..74e1e285 --- /dev/null +++ b/packages/cli/src/release/Release.definition.ts @@ -0,0 +1,33 @@ +/** + * 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. + * + */ + +import type { ICommandDefinition } from "@zowe/imperative"; +import { SshSession } from "@zowe/zos-uss-for-zowe-sdk"; +import { Constants } from "../Constants"; +import { JobDefinition } from "./job/Job.definition"; + +const ReleaseDefinition: ICommandDefinition = { + name: "release", + summary: "Release jobs", + description: "Release jobs", + type: "group", + children: [JobDefinition], + passOn: [ + { + property: "options", + value: [...SshSession.SSH_CONNECTION_OPTIONS, Constants.OPT_SERVER_PATH], + merge: true, + ignoreNodes: [{ type: "group" }], + }, + ], +}; + +export = ReleaseDefinition; diff --git a/packages/cli/src/release/job/Job.definition.ts b/packages/cli/src/release/job/Job.definition.ts new file mode 100644 index 00000000..0db9030c --- /dev/null +++ b/packages/cli/src/release/job/Job.definition.ts @@ -0,0 +1,36 @@ +/** + * 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. + * + */ + +import type { ICommandDefinition } from "@zowe/imperative"; + +export const JobDefinition: ICommandDefinition = { + handler: `${__dirname}/Job.handler`, + description: "Release a job", + type: "command", + name: "job", + aliases: ["j"], + summary: "Release a job", + examples: [ + { + description: "Release a job", + options: '"TSU00369"', + }, + ], + positionals: [ + { + name: "job-id", + description: "The ID of the job to release", + type: "string", + required: true, + }, + ], + profile: { optional: ["ssh"] }, +}; diff --git a/packages/cli/src/release/job/Job.handler.ts b/packages/cli/src/release/job/Job.handler.ts new file mode 100644 index 00000000..df331d55 --- /dev/null +++ b/packages/cli/src/release/job/Job.handler.ts @@ -0,0 +1,29 @@ +/** + * 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. + * + */ + +import type { IHandlerParameters } from "@zowe/imperative"; +import type { ZSshClient, jobs } from "zowe-native-proto-sdk"; +import { SshBaseHandler } from "../../SshBaseHandler"; + +export default class ReleaseJobHandler extends SshBaseHandler { + public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise { + const jobId = params.arguments.jobId; + const response = await client.jobs.releaseJob({ jobId }); + + const msg = `Job "${jobId}" released`; + params.response.data.setMessage(msg); + params.response.data.setObj(response); + if (response.success) { + params.response.console.log(msg); + } + return response; + } +} diff --git a/packages/sdk/src/AbstractRpcClient.ts b/packages/sdk/src/AbstractRpcClient.ts index 24dab423..c3728d02 100644 --- a/packages/sdk/src/AbstractRpcClient.ts +++ b/packages/sdk/src/AbstractRpcClient.ts @@ -55,6 +55,10 @@ export abstract class AbstractRpcClient { this.request({ command: "submitJob", ...request }), submitJcl: (request: Omit): Promise => this.request({ command: "submitJcl", ...request }), + holdJob: (request: Omit): Promise => + this.request({ command: "holdJob", ...request }), + releaseJob: (request: Omit): Promise => + this.request({ command: "releaseJob", ...request }), }; } diff --git a/packages/sdk/src/doc/gen/jobs.ts b/packages/sdk/src/doc/gen/jobs.ts index bb7f72f1..0b99f2d0 100644 --- a/packages/sdk/src/doc/gen/jobs.ts +++ b/packages/sdk/src/doc/gen/jobs.ts @@ -94,6 +94,20 @@ export interface DeleteJobRequest extends common.CommandRequest { */ jobId: string; } +export interface HoldJobRequest extends common.CommandRequest { + command: "holdJob"; + /** + * Job ID to hold + */ + jobId: string; +} +export interface ReleaseJobRequest extends common.CommandRequest { + command: "releaseJob"; + /** + * Job ID to release + */ + jobId: string; +} ////////// // source: responses.go @@ -184,3 +198,23 @@ export interface CancelJobResponse extends common.CommandResponse { */ jobId: string; } +export interface HoldJobResponse extends common.CommandResponse { + /** + * Whether the job was successfully held + */ + success: boolean; + /** + * The ID for the job that was held + */ + jobId: string; +} +export interface ReleaseJobResponse extends common.CommandResponse { + /** + * Whether the job was successfully released + */ + success: boolean; + /** + * The ID for the job that was released + */ + jobId: string; +} From 743eaf542965c8bb62e16f81b2f89e4c3ff4a005 Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:41:07 -0500 Subject: [PATCH 04/11] chore: update changelog Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- native/CHANGELOG.md | 1 + packages/cli/CHANGELOG.md | 1 + packages/sdk/CHANGELOG.md | 1 + 3 files changed, 3 insertions(+) diff --git a/native/CHANGELOG.md b/native/CHANGELOG.md index 78592047..8ef3e630 100644 --- a/native/CHANGELOG.md +++ b/native/CHANGELOG.md @@ -22,6 +22,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how - `golang`: Added `createDataset` function in the middleware. [#95](https://github.com/zowe/zowe-native-proto/pull/95) - `c,golang`: Added `createMember` function. [#95](https://github.com/zowe/zowe-native-proto/pull/95) - `c,golang`: Added `cancelJob` function. [#138](https://github.com/zowe/zowe-native-proto/pull/138) +- `c,golang`: Added `holdJob` and `releaseJob` functions. [#182](https://github.com/zowe/zowe-native-proto/pull/182) ## [Unreleased] diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 25ef6db5..9a82cfc8 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -10,6 +10,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how - Added `zssh view uss-file` command. [#38](https://github.com/zowe/zowe-native-proto/pull/38) - Added `zssh list spool-files` command. [#38](https://github.com/zowe/zowe-native-proto/pull/38) - Added support for cancelling jobs. [#138](https://github.com/zowe/zowe-native-proto/pull/138) +- Added support for holding and releasing jobs. [#182](https://github.com/zowe/zowe-native-proto/pull/182) ## [Unreleased] diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 20f3b9d0..9423e924 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -8,6 +8,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how - Added `ds.restoreDataset` function. [#38](https://github.com/zowe/zowe-native-proto/pull/38) - Added support for cancelling jobs. [#138](https://github.com/zowe/zowe-native-proto/pull/138) +- Added support for holding and releasing jobs. [#182](https://github.com/zowe/zowe-native-proto/pull/182) ## [Unreleased] From 121ef1589fd5f51e0255309eccbe31481603158e Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 5 Mar 2025 19:54:15 -0500 Subject: [PATCH 05/11] feat: add submit uss across the board Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- doc/apis.md | 33 ++++++------ native/c/zowex.cpp | 51 +++++++++++++++++++ native/golang/cmds/definitions.go | 1 + native/golang/cmds/jobs.go | 22 ++++++++ native/golang/types/jobs/requests.go | 7 +++ native/golang/types/jobs/responses.go | 10 ++++ packages/cli/src/submit/Submit.definition.ts | 5 +- .../cli/src/submit/ds/Dataset.definition.ts | 37 ++++++++++++++ packages/cli/src/submit/ds/Dataset.handler.ts | 30 +++++++++++ .../submit/local-file/LocalFile.definition.ts | 37 ++++++++++++++ .../submit/local-file/LocalFile.handler.ts | 40 +++++++++++++++ .../cli/src/submit/stdin/Stdin.handler.ts | 2 +- packages/cli/src/submit/uss/Uss.definition.ts | 37 ++++++++++++++ packages/cli/src/submit/uss/Uss.handler.ts | 29 +++++++++++ packages/sdk/src/AbstractRpcClient.ts | 2 + packages/sdk/src/doc/gen/jobs.ts | 21 ++++++++ 16 files changed, 346 insertions(+), 18 deletions(-) create mode 100644 packages/cli/src/submit/ds/Dataset.definition.ts create mode 100644 packages/cli/src/submit/ds/Dataset.handler.ts create mode 100644 packages/cli/src/submit/local-file/LocalFile.definition.ts create mode 100644 packages/cli/src/submit/local-file/LocalFile.handler.ts create mode 100644 packages/cli/src/submit/uss/Uss.definition.ts create mode 100644 packages/cli/src/submit/uss/Uss.handler.ts diff --git a/doc/apis.md b/doc/apis.md index 347396ea..cc418e1b 100644 --- a/doc/apis.md +++ b/doc/apis.md @@ -68,22 +68,23 @@ ## Jobs -| Operation | z/OSMF | FTP | Backend | Middleware | SDK | CLI | VSCE | -| ------------------ | ------ | --- | ------- | ---------- | --- | --- | --------------- | -| _Get job status_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| _List jobs_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| _List spool files_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| _Read spool file_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| _Get job JCL_ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | -| _Submit job_ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | -| _Delete job_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| Cancel job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ 1 | -| Hold job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ➖ 2 | -| Release job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ➖ 2 | -| Change job class | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ➖ | - -1. Does not support force, restart, dump, or purge -2. Zowe Explorer does not support the Job Hold/Release operation +| Operation | z/OSMF | FTP | Backend | Middleware | SDK | CLI | VSCE | +| ------------------ | ------ | --- | --------------- | ---------- | --- | --- | --------------- | +| _Get job status_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| _List jobs_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| _List spool files_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| _Read spool file_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| _Get job JCL_ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | +| _Submit job_ | ✅ | ✅ | ✅ 1 | ✅ | ✅ | ✅ | ✅ | +| _Delete job_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| Cancel job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ 2 | +| Hold job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ➖ 3 | +| Release job | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ➖ 3 | +| Change job class | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ➖ | + +1. Unable to submit JCL from stdin (see #183) +2. Does not support force, restart, dump, or purge +3. Zowe Explorer does not support the Job Hold/Release operation ## Console diff --git a/native/c/zowex.cpp b/native/c/zowex.cpp index 8e6de297..825e6651 100644 --- a/native/c/zowex.cpp +++ b/native/c/zowex.cpp @@ -42,6 +42,7 @@ int handle_job_view_file(ZCLIResult); int handle_job_view_jcl(ZCLIResult); int handle_job_submit(ZCLIResult); int handle_job_submit_jcl(ZCLIResult); +int handle_job_submit_uss(ZCLIResult); int handle_job_delete(ZCLIResult); int handle_job_cancel(ZCLIResult); int handle_job_hold(ZCLIResult); @@ -311,6 +312,18 @@ int main(int argc, char *argv[]) job_submit_jcl.get_options().push_back(job_jobid_only); job_group.get_verbs().push_back(job_submit_jcl); + ZCLIVerb job_submit_uss("submit-uss"); + job_submit_uss.get_aliases().push_back("sub-u"); + job_submit_uss.set_description("submit a job from USS files"); + job_submit_uss.set_zcli_verb_handler(handle_job_submit_uss); + ZCLIPositional job_uss_file("file-path"); + job_uss_file.set_required(true); + job_uss_file.set_description("USS file containing JCL"); + job_submit_uss.get_positionals().push_back(job_uss_file); + + job_submit_uss.get_options().push_back(job_jobid_only); + job_group.get_verbs().push_back(job_submit_uss); + ZCLIVerb job_delete("delete"); job_delete.get_aliases().push_back("del"); job_delete.set_description("delete a job"); @@ -789,6 +802,44 @@ int handle_job_submit(ZCLIResult result) return RTNCD_SUCCESS; } +int handle_job_submit_uss(ZCLIResult result) +{ + int rc = 0; + ZJB zjb = {0}; + string file(result.get_positional("file-path")->get_value()); + + ZUSF zusf = {0}; + string response; + rc = zusf_read_from_uss_file(&zusf, file, response); + if (0 != rc) + { + cerr << "Error: could not view USS file: '" << file << "' rc: '" << rc << "'" << endl; + cerr << " Details:\n" + << zusf.diag.e_msg << endl + << response << endl; + return RTNCD_FAILURE; + } + + vector jobs; + string jobid; + rc = zjb_submit(&zjb, response, jobid); + + if (0 != rc) + { + cerr << "Error: could not submit JCL: '" << file << "' rc: '" << rc << "'" << endl; + cerr << " Details: " << zjb.diag.e_msg << endl; + return RTNCD_FAILURE; + } + + string only_jobid(result.get_option("--only-jobid")->get_value()); + if ("true" == only_jobid) + cout << jobid << endl; + else + cout << "Submitted " << file << ", " << jobid << endl; + + return RTNCD_SUCCESS; +} + int handle_job_submit_jcl(ZCLIResult result) { int rc = 0; diff --git a/native/golang/cmds/definitions.go b/native/golang/cmds/definitions.go index a6718bc6..fbbe60e4 100644 --- a/native/golang/cmds/definitions.go +++ b/native/golang/cmds/definitions.go @@ -51,6 +51,7 @@ func initializeJobHandlers(disp *CmdDispatcher) { "readSpool": HandleReadSpoolRequest, "submitJob": HandleSubmitJobRequest, "submitJcl": HandleSubmitJclRequest, + "submitUss": HandleSubmitUssRequest, "cancelJob": HandleCancelJobRequest, "deleteJob": HandleDeleteJobRequest, "holdJob": HandleHoldJobRequest, diff --git a/native/golang/cmds/jobs.go b/native/golang/cmds/jobs.go index 753a4a61..5a5a2de8 100644 --- a/native/golang/cmds/jobs.go +++ b/native/golang/cmds/jobs.go @@ -266,6 +266,28 @@ func HandleSubmitJobRequest(conn *utils.StdioConn, params []byte) (result any, e return } +// HandleSubmitUssRequest handles a SubmitUssRequest by invoking the `zowex job submit-uss` command +func HandleSubmitUssRequest(conn *utils.StdioConn, params []byte) (result any, e error) { + request, err := utils.ParseCommandRequest[jobs.SubmitUssRequest](params) + if err != nil { + return nil, err + } + + out, err := conn.ExecCmd([]string{"job", "submit-uss", request.Path, "--only-jobid", "true"}) + + if err != nil { + e = fmt.Errorf("Failed to submit job: %v", err) + return + } + + result = jobs.SubmitUssResponse{ + Success: true, + Path: request.Path, + JobId: strings.TrimSpace(string(out)), + } + return +} + // HandleSubmitJclRequest handles a SubmitJclRequest by invoking the `zowex job submit-jcl` command func HandleSubmitJclRequest(conn *utils.StdioConn, params []byte) (result any, e error) { request, err := utils.ParseCommandRequest[jobs.SubmitJclRequest](params) diff --git a/native/golang/types/jobs/requests.go b/native/golang/types/jobs/requests.go index 575fdefb..93764963 100644 --- a/native/golang/types/jobs/requests.go +++ b/native/golang/types/jobs/requests.go @@ -64,6 +64,13 @@ type SubmitJobRequest struct { Dsname string `json:"dsname"` } +type SubmitUssRequest struct { + common.CommandRequest `tstype:",extends"` + Command string `json:"command" tstype:"\"submitUss\""` + // File path w/ contents to submit as JCL + Path string `json:"fspath"` +} + type SubmitJclRequest struct { common.CommandRequest `tstype:",extends"` Command string `json:"command" tstype:"\"submitJcl\""` diff --git a/native/golang/types/jobs/responses.go b/native/golang/types/jobs/responses.go index a16b2144..6d6aff65 100644 --- a/native/golang/types/jobs/responses.go +++ b/native/golang/types/jobs/responses.go @@ -60,6 +60,16 @@ type SubmitJobResponse struct { Dsname string `json:"dsname"` } +type SubmitUssResponse struct { + common.CommandResponse `tstype:",extends"` + // Whether the job was successfully submitted + Success bool `json:"success"` + // The job ID of the newly-submitted job + JobId string `json:"jobId"` + // The USS file where the JCL was read from + Path string `json:"fspath"` +} + type SubmitJclResponse struct { common.CommandResponse `tstype:",extends"` // Whether the JCL was successfully submitted diff --git a/packages/cli/src/submit/Submit.definition.ts b/packages/cli/src/submit/Submit.definition.ts index fe49e28e..32920d15 100644 --- a/packages/cli/src/submit/Submit.definition.ts +++ b/packages/cli/src/submit/Submit.definition.ts @@ -13,6 +13,9 @@ import type { ICommandDefinition } from "@zowe/imperative"; import { SshSession } from "@zowe/zos-uss-for-zowe-sdk"; import { Constants } from "../Constants"; import { SubmitStdinDefinition } from "./stdin/Stdin.definition"; +import { SubmitDsDefinition } from "./ds/Dataset.definition"; +import { SubmitUssDefinition } from "./uss/Uss.definition"; +import { SubmitLocalFileDefinition } from "./local-file/LocalFile.definition"; const SubmitDefinition: ICommandDefinition = { name: "submit", @@ -20,7 +23,7 @@ const SubmitDefinition: ICommandDefinition = { summary: "Submit contents", description: "Submit resource contents or requests to a mainframe system", type: "group", - children: [SubmitStdinDefinition], + children: [SubmitStdinDefinition, SubmitDsDefinition, SubmitUssDefinition, SubmitLocalFileDefinition], passOn: [ { property: "options", diff --git a/packages/cli/src/submit/ds/Dataset.definition.ts b/packages/cli/src/submit/ds/Dataset.definition.ts new file mode 100644 index 00000000..0628f516 --- /dev/null +++ b/packages/cli/src/submit/ds/Dataset.definition.ts @@ -0,0 +1,37 @@ +/** + * 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. + * + */ + +import type { ICommandDefinition } from "@zowe/imperative"; + +export const SubmitDsDefinition: ICommandDefinition = { + handler: `${__dirname}/Dataset.handler`, + description: "Submit a job from JCL written in a dataset.", + type: "command", + name: "data-set", + aliases: ["ds"], + summary: "Submit a job from a dataset", + examples: [ + { + description: 'Submit a job from the dataset "IBMUSER.PUBLIC.CNTL(IEFBR14)"', + options: '"IBMUSER.PUBLIC.CNTL(IEFBR14)"', + }, + ], + positionals: [ + { + name: "name", + description: "The dataset containing the JCL to submit", + type: "string", + required: true, + }, + ], + profile: { optional: ["ssh"] }, + outputFormatOptions: true, +}; diff --git a/packages/cli/src/submit/ds/Dataset.handler.ts b/packages/cli/src/submit/ds/Dataset.handler.ts new file mode 100644 index 00000000..53a3e65d --- /dev/null +++ b/packages/cli/src/submit/ds/Dataset.handler.ts @@ -0,0 +1,30 @@ +/** + * 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. + * + */ + +import { text } from "node:stream/consumers"; +import type { IHandlerParameters } from "@zowe/imperative"; +import type { ZSshClient, jobs } from "zowe-native-proto-sdk"; +import { SshBaseHandler } from "../../SshBaseHandler"; + +export default class SubmitDsHandler extends SshBaseHandler { + public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise { + const dsname = params.arguments.name; + const response = await client.jobs.submitJob({ dsname }); + + const msg = `Job submitted: ${response.jobId}`; + params.response.data.setMessage(msg); + params.response.data.setObj(response); + if (response.success) { + params.response.console.log(msg); + } + return response; + } +} diff --git a/packages/cli/src/submit/local-file/LocalFile.definition.ts b/packages/cli/src/submit/local-file/LocalFile.definition.ts new file mode 100644 index 00000000..c967006e --- /dev/null +++ b/packages/cli/src/submit/local-file/LocalFile.definition.ts @@ -0,0 +1,37 @@ +/** + * 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. + * + */ + +import type { ICommandDefinition } from "@zowe/imperative"; + +export const SubmitLocalFileDefinition: ICommandDefinition = { + handler: `${__dirname}/LocalFile.handler`, + description: "Submit a job from JCL written in a local file.", + type: "command", + name: "local-file", + aliases: ["lf"], + summary: "Submit a job from local files", + examples: [ + { + description: 'Submit a job from the file "my_jcl.txt"', + options: '"my_jcl.txt"', + }, + ], + positionals: [ + { + name: "fspath", + description: "The path to the JCL to submit", + type: "string", + required: true, + }, + ], + profile: { optional: ["ssh"] }, + outputFormatOptions: true, +}; diff --git a/packages/cli/src/submit/local-file/LocalFile.handler.ts b/packages/cli/src/submit/local-file/LocalFile.handler.ts new file mode 100644 index 00000000..29d1e730 --- /dev/null +++ b/packages/cli/src/submit/local-file/LocalFile.handler.ts @@ -0,0 +1,40 @@ +/** + * 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. + * + */ + +import { ImperativeError, type IHandlerParameters } from "@zowe/imperative"; +import type { ZSshClient, jobs } from "zowe-native-proto-sdk"; +import { SshBaseHandler } from "../../SshBaseHandler"; +import { readFileSync } from "node:fs"; + +export default class SubmitLocalFileHandler extends SshBaseHandler { + public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise { + const fspath = params.arguments.fspath; + let JclString: string; + try { + JclString = readFileSync(fspath).toString(); + } catch (err) { + throw new ImperativeError({ + msg: "Failed to read local file", + additionalDetails: err.toString(), + causeErrors: err, + }); + } + const response = await client.jobs.submitJcl({ jcl: JclString }); + + const msg = `Job submitted: ${response.jobId}`; + params.response.data.setMessage(msg); + params.response.data.setObj(response); + if (response.success) { + params.response.console.log(msg); + } + return response; + } +} diff --git a/packages/cli/src/submit/stdin/Stdin.handler.ts b/packages/cli/src/submit/stdin/Stdin.handler.ts index 5cc5b572..71607079 100644 --- a/packages/cli/src/submit/stdin/Stdin.handler.ts +++ b/packages/cli/src/submit/stdin/Stdin.handler.ts @@ -15,7 +15,7 @@ import type { ZSshClient, jobs } from "zowe-native-proto-sdk"; import { SshBaseHandler } from "../../SshBaseHandler"; export default class SubmitJclHandler extends SshBaseHandler { - public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise { + public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise { const jcl = await text(params.stdin); const response = await client.jobs.submitJcl({ jcl }); diff --git a/packages/cli/src/submit/uss/Uss.definition.ts b/packages/cli/src/submit/uss/Uss.definition.ts new file mode 100644 index 00000000..f293a9a3 --- /dev/null +++ b/packages/cli/src/submit/uss/Uss.definition.ts @@ -0,0 +1,37 @@ +/** + * 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. + * + */ + +import type { ICommandDefinition } from "@zowe/imperative"; + +export const SubmitUssDefinition: ICommandDefinition = { + handler: `${__dirname}/Uss.handler`, + description: "Submit a job from JCL written in a USS file.", + type: "command", + name: "uss-file", + aliases: ["uss"], + summary: "Submit a job from USS files", + examples: [ + { + description: 'Submit a job from the USS file "my_jcl.txt"', + options: '"my_jcl.txt"', + }, + ], + positionals: [ + { + name: "fspath", + description: "The USS path to the JCL to submit", + type: "string", + required: true, + }, + ], + profile: { optional: ["ssh"] }, + outputFormatOptions: true, +}; diff --git a/packages/cli/src/submit/uss/Uss.handler.ts b/packages/cli/src/submit/uss/Uss.handler.ts new file mode 100644 index 00000000..36ece5fa --- /dev/null +++ b/packages/cli/src/submit/uss/Uss.handler.ts @@ -0,0 +1,29 @@ +/** + * 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. + * + */ + +import type { IHandlerParameters } from "@zowe/imperative"; +import type { ZSshClient, jobs } from "zowe-native-proto-sdk"; +import { SshBaseHandler } from "../../SshBaseHandler"; + +export default class SubmitUssHandler extends SshBaseHandler { + public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise { + const fspath = params.arguments.fspath; + const response = await client.jobs.submitUss({ fspath }); + + const msg = `Job submitted: ${response.jobId}`; + params.response.data.setMessage(msg); + params.response.data.setObj(response); + if (response.success) { + params.response.console.log(msg); + } + return response; + } +} diff --git a/packages/sdk/src/AbstractRpcClient.ts b/packages/sdk/src/AbstractRpcClient.ts index c3728d02..943b882c 100644 --- a/packages/sdk/src/AbstractRpcClient.ts +++ b/packages/sdk/src/AbstractRpcClient.ts @@ -53,6 +53,8 @@ export abstract class AbstractRpcClient { this.request({ command: "deleteJob", ...request }), submitJob: (request: Omit): Promise => this.request({ command: "submitJob", ...request }), + submitUss: (request: Omit): Promise => + this.request({ command: "submitUss", ...request }), submitJcl: (request: Omit): Promise => this.request({ command: "submitJcl", ...request }), holdJob: (request: Omit): Promise => diff --git a/packages/sdk/src/doc/gen/jobs.ts b/packages/sdk/src/doc/gen/jobs.ts index 0b99f2d0..196a4b3f 100644 --- a/packages/sdk/src/doc/gen/jobs.ts +++ b/packages/sdk/src/doc/gen/jobs.ts @@ -73,6 +73,13 @@ export interface SubmitJobRequest extends common.CommandRequest { */ dsname: string; } +export interface SubmitUssRequest extends common.CommandRequest { + command: "submitUss"; + /** + * File path w/ contents to submit as JCL + */ + fspath: string; +} export interface SubmitJclRequest extends common.CommandRequest { command: "submitJcl"; /** @@ -168,6 +175,20 @@ export interface SubmitJobResponse extends common.CommandResponse { */ dsname: string; } +export interface SubmitUssResponse extends common.CommandResponse { + /** + * Whether the job was successfully submitted + */ + success: boolean; + /** + * The job ID of the newly-submitted job + */ + jobId: string; + /** + * The USS file where the JCL was read from + */ + fspath: string; +} export interface SubmitJclResponse extends common.CommandResponse { /** * Whether the JCL was successfully submitted From 5876cebb954562a9b63261696f27a53a42b3abff Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 12 Mar 2025 09:04:43 -0400 Subject: [PATCH 06/11] review: fix lint issues Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- packages/cli/src/submit/Submit.definition.ts | 4 ++-- packages/cli/src/submit/local-file/LocalFile.handler.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/submit/Submit.definition.ts b/packages/cli/src/submit/Submit.definition.ts index 32920d15..44734b61 100644 --- a/packages/cli/src/submit/Submit.definition.ts +++ b/packages/cli/src/submit/Submit.definition.ts @@ -12,10 +12,10 @@ import type { ICommandDefinition } from "@zowe/imperative"; import { SshSession } from "@zowe/zos-uss-for-zowe-sdk"; import { Constants } from "../Constants"; -import { SubmitStdinDefinition } from "./stdin/Stdin.definition"; import { SubmitDsDefinition } from "./ds/Dataset.definition"; -import { SubmitUssDefinition } from "./uss/Uss.definition"; import { SubmitLocalFileDefinition } from "./local-file/LocalFile.definition"; +import { SubmitStdinDefinition } from "./stdin/Stdin.definition"; +import { SubmitUssDefinition } from "./uss/Uss.definition"; const SubmitDefinition: ICommandDefinition = { name: "submit", diff --git a/packages/cli/src/submit/local-file/LocalFile.handler.ts b/packages/cli/src/submit/local-file/LocalFile.handler.ts index 29d1e730..ad55c586 100644 --- a/packages/cli/src/submit/local-file/LocalFile.handler.ts +++ b/packages/cli/src/submit/local-file/LocalFile.handler.ts @@ -9,10 +9,10 @@ * */ -import { ImperativeError, type IHandlerParameters } from "@zowe/imperative"; +import { readFileSync } from "node:fs"; +import { type IHandlerParameters, ImperativeError } from "@zowe/imperative"; import type { ZSshClient, jobs } from "zowe-native-proto-sdk"; import { SshBaseHandler } from "../../SshBaseHandler"; -import { readFileSync } from "node:fs"; export default class SubmitLocalFileHandler extends SshBaseHandler { public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise { From 1e3c0d7bf0684d2fdc434cfd493aada7a7540745 Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 12 Mar 2025 09:34:26 -0400 Subject: [PATCH 07/11] review: remove unnecessary trim :yum: Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- native/CHANGELOG.md | 1 + native/golang/cmds/jobs.go | 6 +++--- packages/cli/CHANGELOG.md | 1 + packages/sdk/CHANGELOG.md | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/native/CHANGELOG.md b/native/CHANGELOG.md index 5ebc0e6d..2ede9fc9 100644 --- a/native/CHANGELOG.md +++ b/native/CHANGELOG.md @@ -27,6 +27,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how - `c`: Added check for maximum data set pattern length before making a list request. Now, requests with patterns longer than 44 characters are rejected. [#185](https://github.com/zowe/zowe-native-proto/pull/185) - `c,golang`: Fixed issue where submit JCL handler did not convert input data from UTF-8 and did not support an `--encoding` option. [#198](https://github.com/zowe/zowe-native-proto/pull/198) - `c`: Fixed issue where submit JCL handler did not support raw bytes from stdin when the binary is directly invoked through a shell. [#198](https://github.com/zowe/zowe-native-proto/pull/198) +- `c,golang`: Added `submitUss` function. [#184](https://github.com/zowe/zowe-native-proto/pull/184) ## [Unreleased] diff --git a/native/golang/cmds/jobs.go b/native/golang/cmds/jobs.go index d3c882f7..1748884f 100644 --- a/native/golang/cmds/jobs.go +++ b/native/golang/cmds/jobs.go @@ -262,7 +262,7 @@ func HandleSubmitJobRequest(conn *utils.StdioConn, params []byte) (result any, e result = jobs.SubmitJobResponse{ Success: true, Dsname: request.Dsname, - JobId: strings.TrimSpace(string(out)), + JobId: string(out), } return } @@ -284,7 +284,7 @@ func HandleSubmitUssRequest(conn *utils.StdioConn, params []byte) (result any, e result = jobs.SubmitUssResponse{ Success: true, Path: request.Path, - JobId: strings.TrimSpace(string(out)), + JobId: string(out), } return } @@ -331,7 +331,7 @@ func HandleSubmitJclRequest(conn *utils.StdioConn, params []byte) (result any, e result = jobs.SubmitJclResponse{ Success: true, - JobId: strings.TrimSpace(string(out)), + JobId: string(out), } return } diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index a4241804..d970473d 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -12,6 +12,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how - Added support for cancelling jobs. [#138](https://github.com/zowe/zowe-native-proto/pull/138) - Added support for holding and releasing jobs. [#182](https://github.com/zowe/zowe-native-proto/pull/182) - Updated error handling for listing data sets. [#185](https://github.com/zowe/zowe-native-proto/pull/185) +- Added `zssh submit uss-file|local-file|data-set` commands. [#184](https://github.com/zowe/zowe-native-proto/pull/184) ## [Unreleased] diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 9423e924..02ad40a4 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -9,6 +9,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how - Added `ds.restoreDataset` function. [#38](https://github.com/zowe/zowe-native-proto/pull/38) - Added support for cancelling jobs. [#138](https://github.com/zowe/zowe-native-proto/pull/138) - Added support for holding and releasing jobs. [#182](https://github.com/zowe/zowe-native-proto/pull/182) +- Added `jobs.submitUss` function. [#184](https://github.com/zowe/zowe-native-proto/pull/184) ## [Unreleased] From 892fb1b3b0d3510d1db459eda79e4a62ff74305f Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 12 Mar 2025 09:43:40 -0400 Subject: [PATCH 08/11] review: fix local-file after merge Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- packages/cli/src/submit/local-file/LocalFile.handler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/submit/local-file/LocalFile.handler.ts b/packages/cli/src/submit/local-file/LocalFile.handler.ts index ad55c586..3bbf3369 100644 --- a/packages/cli/src/submit/local-file/LocalFile.handler.ts +++ b/packages/cli/src/submit/local-file/LocalFile.handler.ts @@ -11,7 +11,7 @@ import { readFileSync } from "node:fs"; import { type IHandlerParameters, ImperativeError } from "@zowe/imperative"; -import type { ZSshClient, jobs } from "zowe-native-proto-sdk"; +import { type ZSshClient, ZSshUtils, type jobs } from "zowe-native-proto-sdk"; import { SshBaseHandler } from "../../SshBaseHandler"; export default class SubmitLocalFileHandler extends SshBaseHandler { @@ -27,7 +27,7 @@ export default class SubmitLocalFileHandler extends SshBaseHandler { causeErrors: err, }); } - const response = await client.jobs.submitJcl({ jcl: JclString }); + const response = await client.jobs.submitJcl({ jcl: ZSshUtils.encodeByteArray(Buffer.from(JclString)) }); const msg = `Job submitted: ${response.jobId}`; params.response.data.setMessage(msg); From 299d779b31de946e9b66721e3caf7c773855e431 Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:31:52 -0400 Subject: [PATCH 09/11] chore: cleanup after updating from the main branch Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- packages/cli/src/submit/local-file/LocalFile.handler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/submit/local-file/LocalFile.handler.ts b/packages/cli/src/submit/local-file/LocalFile.handler.ts index 3bbf3369..80e6e274 100644 --- a/packages/cli/src/submit/local-file/LocalFile.handler.ts +++ b/packages/cli/src/submit/local-file/LocalFile.handler.ts @@ -11,7 +11,7 @@ import { readFileSync } from "node:fs"; import { type IHandlerParameters, ImperativeError } from "@zowe/imperative"; -import { type ZSshClient, ZSshUtils, type jobs } from "zowe-native-proto-sdk"; +import { B64String, type ZSshClient, type jobs } from "zowe-native-proto-sdk"; import { SshBaseHandler } from "../../SshBaseHandler"; export default class SubmitLocalFileHandler extends SshBaseHandler { @@ -27,7 +27,7 @@ export default class SubmitLocalFileHandler extends SshBaseHandler { causeErrors: err, }); } - const response = await client.jobs.submitJcl({ jcl: ZSshUtils.encodeByteArray(Buffer.from(JclString)) }); + const response = await client.jobs.submitJcl({ jcl: B64String.encode(Buffer.from(JclString)) }); const msg = `Job submitted: ${response.jobId}`; params.response.data.setMessage(msg); From 088bb350ad1badc8c3046a4e41398760ab70889f Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 12 Mar 2025 12:02:30 -0400 Subject: [PATCH 10/11] Update packages/cli/src/submit/local-file/LocalFile.handler.ts thanks @t1m0thyj Co-authored-by: Timothy Johnson Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- packages/cli/src/submit/local-file/LocalFile.handler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/submit/local-file/LocalFile.handler.ts b/packages/cli/src/submit/local-file/LocalFile.handler.ts index 80e6e274..8612af70 100644 --- a/packages/cli/src/submit/local-file/LocalFile.handler.ts +++ b/packages/cli/src/submit/local-file/LocalFile.handler.ts @@ -19,7 +19,7 @@ export default class SubmitLocalFileHandler extends SshBaseHandler { const fspath = params.arguments.fspath; let JclString: string; try { - JclString = readFileSync(fspath).toString(); + JclString = readFileSync(fspath); } catch (err) { throw new ImperativeError({ msg: "Failed to read local file", @@ -27,7 +27,7 @@ export default class SubmitLocalFileHandler extends SshBaseHandler { causeErrors: err, }); } - const response = await client.jobs.submitJcl({ jcl: B64String.encode(Buffer.from(JclString)) }); + const response = await client.jobs.submitJcl({ jcl: B64String.encode(JclString) }); const msg = `Job submitted: ${response.jobId}`; params.response.data.setMessage(msg); From 004d763a65ffda880fa808cf6864dcf780873729 Mon Sep 17 00:00:00 2001 From: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Date: Wed, 12 Mar 2025 12:05:20 -0400 Subject: [PATCH 11/11] cleanup after accepting the suggestion Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- packages/cli/src/submit/local-file/LocalFile.handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/submit/local-file/LocalFile.handler.ts b/packages/cli/src/submit/local-file/LocalFile.handler.ts index 8612af70..5deec659 100644 --- a/packages/cli/src/submit/local-file/LocalFile.handler.ts +++ b/packages/cli/src/submit/local-file/LocalFile.handler.ts @@ -17,7 +17,7 @@ import { SshBaseHandler } from "../../SshBaseHandler"; export default class SubmitLocalFileHandler extends SshBaseHandler { public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise { const fspath = params.arguments.fspath; - let JclString: string; + let JclString: Buffer; try { JclString = readFileSync(fspath); } catch (err) {