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

Adding functionality to the VSCE to truly fix #95 #126

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
40 changes: 20 additions & 20 deletions doc/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
| _Read data set member_ | ✅ | ✅ | 🚧 <sup>2</sup> | ✅ | ✅ | ✅ | ✅ |
| _Write data set_ | ✅ | ✅ | 🚧 <sup>2</sup> | ✅ | ✅ | ❌ | ❌ |
| _Write data set member_ | ✅ | ✅ | 🚧 <sup>2</sup> | ✅ | ✅ | ❌ | ❌ |
| _Create data set_ | ✅ | ✅ | 🚧 <sup>3</sup> | | | | |
| _Create data set_ | ✅ | ✅ | 🚧 <sup>3</sup> | | | | |
| _Create data set member_ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| _Delete data set_ | ✅ | ✅ | ✅ | | | | |
| _Delete data set member_ | ✅ | ✅ | ✅ | | | | |
| _Delete data set_ | ✅ | ✅ | ✅ | | | | |
| _Delete data set member_ | ✅ | ✅ | ✅ | | | | |
| Migrate data set | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Recall data set | 🚧 <sup>4</sup> | ❌ | ✅ | ✅ | ✅ | ✅ | |
| Recall data set | 🚧 <sup>4</sup> | ❌ | ✅ | ✅ | ✅ | ✅ | |
| Delete migrated data set | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Rename data set | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Copy data set | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
Expand Down Expand Up @@ -67,27 +67,27 @@

## 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_ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
| Hold job | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Release job | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Change job class | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ➖ |
| Cancel job | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| _Delete job_ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
| 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_ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
| Hold job | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Release job | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Change job class | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ➖ |
| Cancel job | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| _Delete job_ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |

## Console

| Operation | z/OSMF | FTP | Backend | Middleware | SDK | CLI | VSCE |
| ------------------------ | ------ | --- | --------------- | ---------- | --- | --- | ---- |
| Issue MVS command | ✅ | ❌ | ✅ <sup>1</sup> | ✅ | ✅ | ✅ | ❌ |
| Get MVS command response | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Get MVS detect result | ✅ | ❌ | ❌ | ❌ | ❌ | ➖ | ➖ |
| Issue MVS command | ✅ | ❌ | ✅ <sup>1</sup> | ✅ | ✅ | ✅ | ❌ |
| Get MVS command response | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Get MVS detect result | ✅ | ❌ | ❌ | ❌ | ❌ | ➖ | ➖ |

1. Requires APF authorization

Expand Down
1 change: 1 addition & 0 deletions native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
- `golang`: Added `procstep` and `dsname` to the list of fields when getting spool files
- `golang`: Added `tygo` to generate types based on the Go types for the TypeScript SDK. [#71](https://github.com/zowe/zowe-native-proto/pull/71)
- `c,golang`: Added `watch:native` npm script to detect and upload changes to files during development. [#100](https://github.com/zowe/zowe-native-proto/pull/100)
- `golang`: Added `createDataset` and `deleteDataset` function in the middleware. [#95](https://github.com/zowe/zowe-native-proto/pull/95)

## [Unreleased]

Expand Down
27 changes: 27 additions & 0 deletions native/golang/ds.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,30 @@ func HandleDeleteDatasetRequest(jsonData []byte) {
fmt.Println(string(v))
}
}

func HandleCreateDatasetRequest(jsonData []byte) {
var dsRequest ds.CreateDatasetRequest
err := json.Unmarshal(jsonData, &dsRequest)
if err != nil {
return
}

args := []string{"./zowex", "data-set", "create", dsRequest.Dsname}

out, err := utils.BuildCommand(args).Output()
if err != nil {
log.Println("Error executing command:", err)
log.Println(string(out))
return
}

dsResponse := ds.DeleteDatasetResponse{
Success: true,
}
v, err := json.Marshal(dsResponse)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
} else {
fmt.Println(string(v))
}
}
1 change: 1 addition & 0 deletions native/golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func main() {
"consoleCommand": HandleConsoleCommandRequest,
"restoreDataset": HandleRestoreDatasetRequest,
"deleteDataset": HandleDeleteDatasetRequest,
"createDataset": HandleCreateDatasetRequest,
}

for data := range input {
Expand Down
5 changes: 5 additions & 0 deletions native/golang/types/ds/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ type DeleteDatasetRequest struct {
Command string `json:"command" tstype:"\"deleteDataset\""`
Dsname string `json:"dsname"`
}

type CreateDatasetRequest struct {
Command string `json:"command" tstype:"\"createDataset\""`
Dsname string `json:"dsname"`
}
4 changes: 4 additions & 0 deletions native/golang/types/ds/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ type ListDsMembersResponse struct {
type DeleteDatasetResponse struct {
Success bool `json:"success"`
}

type CreateDatasetResponse struct {
Success bool `json:"success"`
}
1 change: 1 addition & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `zssh delete data-set` command. [#38](https://github.com/zowe/zowe-native-proto/pull/87)
- Added `zssh create data-set` command. [#38](https://github.com/zowe/zowe-native-proto/pull/87)

## [Unreleased]

Expand Down
33 changes: 33 additions & 0 deletions packages/cli/src/create/Create.definition.ts
Original file line number Diff line number Diff line change
@@ -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 { DataSetDefinition } from "./data-set/DataSet.definition";

const DeleteDefinition: ICommandDefinition = {
name: "create",
summary: "Create data sets and/or members",
description: "Create data sets and/or data set members",
type: "group",
children: [DataSetDefinition],
passOn: [
{
property: "options",
value: [...SshSession.SSH_CONNECTION_OPTIONS, Constants.OPT_SERVER_PATH],
merge: true,
ignoreNodes: [{ type: "group" }],
},
],
};

export = DeleteDefinition;
64 changes: 64 additions & 0 deletions packages/cli/src/create/data-set/DataSet.definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* 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 DataSetDefinition: ICommandDefinition = {
handler: `${__dirname}/DataSet.handler`,
description: "Create a data set or data set member",
type: "command",
name: "data-set",
aliases: ["ds"],
summary: "Create a data set or data set member",
examples: [
{
description: "Create a data set",
options: '"ibmuser.test.cntl"',
},
{
description: "Create a data set member",
options: '"ibmuser.test.cntl(member)"',
},
],
positionals: [
{
name: "name",
description: "The name of the data set to create",
type: "string",
required: true,
},
],
profile: { optional: ["ssh"] },
options: [
// {
// name: "type",
// description: "The type of the data set. Required for creating a data set",
// type: "string",
// allowableValues: { values: ["PDS", "PDSE"], caseSensitive: false },
// },
// {
// name: "record-format",
// description: "The record format of the data set. Required for creating a data set",
// type: "string",
// allowableValues: { values: ["FB", "VB", "FS", "VS", "U"], caseSensitive: false },
// },
// {
// name: "block-size",
// description: "The block size of the data set. Required for creating a data set",
// type: "number",
// },
// {
// name: "record-length",
// description: "The record length of the data set. Required for creating a data set",
// type: "number",
// },
],
};
30 changes: 30 additions & 0 deletions packages/cli/src/create/data-set/DataSet.handler.ts
Original file line number Diff line number Diff line change
@@ -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 type { IHandlerParameters } from "@zowe/imperative";
import type { ds, ZSshClient } from "zowe-native-proto-sdk";
import { SshBaseHandler } from "../../SshBaseHandler";

export default class CreateDatasetHandler extends SshBaseHandler {
public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise<ds.CreateDatasetResponse> {
const dsname = params.arguments.name;

const response = await client.ds.createDataset({ dsname });

const dsMessage = `Dataset "${dsname}" created`;
params.response.data.setMessage(dsMessage);
params.response.data.setObj(response);
if (response.success) {
params.response.console.log(dsMessage);
}
return response;
}
}
3 changes: 2 additions & 1 deletion packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
## Recent Changes

- Added `ds.restoreDataset` function. [#38](https://github.com/zowe/zowe-native-proto/pull/38)
- Added `ds.deleteDataset` function. [#38](https://github.com/zowe/zowe-native-proto/pull/87)
- Added `ds.deleteDataset` function. [#87](https://github.com/zowe/zowe-native-proto/pull/87)
- Added `ds.createDataset` function. [#95](https://github.com/zowe/zowe-native-proto/pull/95)

## [Unreleased]

Expand Down
2 changes: 2 additions & 0 deletions packages/sdk/src/AbstractRpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export abstract class AbstractRpcClient {
this.request({ command: "restoreDataset", ...request }),
deleteDataset: (request: Omit<ds.DeleteDatasetRequest, "command">): Promise<ds.DeleteDatasetResponse> =>
this.request({ command: "deleteDataset", ...request }),
createDataset: (request: Omit<ds.CreateDatasetRequest, "command">): Promise<ds.CreateDatasetResponse> =>
this.request({ command: "createDataset", ...request }),
};
}

Expand Down
7 changes: 7 additions & 0 deletions packages/sdk/src/doc/ds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export interface DeleteDatasetRequest {
command: "deleteDataset";
dsname: string;
}
export interface CreateDatasetRequest {
command: "createDataset";
dsname: string;
}

//////////
// source: responses.go
Expand Down Expand Up @@ -70,3 +74,6 @@ export interface ListDsMembersResponse {
export interface DeleteDatasetResponse {
success: boolean;
}
export interface CreateDatasetResponse {
success: boolean;
}
3 changes: 2 additions & 1 deletion packages/vsce/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const extensionConfig = {
exclude: /node_modules/,
loader: 'builtin:swc-loader',
options: {
devtool: 'source-map',
jsc: {
parser: {
syntax: 'typescript',
Expand All @@ -68,4 +69,4 @@ const extensionConfig = {
warnings: false,
}
};
module.exports = [ extensionConfig ];
module.exports = [extensionConfig];
46 changes: 41 additions & 5 deletions packages/vsce/src/api/SshMvsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import { readFileSync, writeFileSync } from "node:fs";
import type * as zosfiles from "@zowe/zos-files-for-zowe-sdk";
import { type MainframeInteraction, imperative } from "@zowe/zowe-explorer-api";
import { ZSshUtils } from "zowe-native-proto-sdk";
import { type MainframeInteraction, imperative, Gui } from "@zowe/zowe-explorer-api";
import { ZSshUtils, type ds } from "zowe-native-proto-sdk";
import { SshCommonApi } from "./SshCommonApi";

export class SshMvsApi extends SshCommonApi implements MainframeInteraction.IMvs {
Expand Down Expand Up @@ -88,7 +88,19 @@ export class SshMvsApi extends SshCommonApi implements MainframeInteraction.IMvs
dataSetName: string,
options?: Partial<zosfiles.ICreateDataSetOptions>,
): Promise<zosfiles.IZosFilesResponse> {
throw new Error("Not yet implemented");
let response: ds.CreateDatasetResponse = { success: false };
try {
response = await (await this.client).ds.createDataset({
dsname: dataSetName,
});
if (!response.success) {
Gui.errorMessage(`Failed to create dataset ${dataSetName}`);
}
} catch (error) {
Gui.errorMessage(`Failed to create dataset ${dataSetName}`);
Gui.errorMessage(`Error: ${error}`);
}
return this.buildZosFilesResponse(response);
}

public async createDataSetMember(
Expand Down Expand Up @@ -133,14 +145,38 @@ export class SshMvsApi extends SshCommonApi implements MainframeInteraction.IMvs
}

public async hRecallDataSet(dataSetName: string): Promise<zosfiles.IZosFilesResponse> {
throw new Error("Not yet implemented");
let response: ds.RestoreDatasetResponse = { success: false };
try {
response = await (await this.client).ds.restoreDataset({
dsname: dataSetName,
});
if (!response.success) {
Gui.errorMessage(`Failed to restore dataset ${dataSetName}`);
}
} catch (error) {
Gui.errorMessage(`Failed to restore dataset ${dataSetName}`);
Gui.errorMessage(`Error: ${error}`);
}
return this.buildZosFilesResponse(response);
}

public async deleteDataSet(
dataSetName: string,
options?: zosfiles.IDeleteDatasetOptions,
): Promise<zosfiles.IZosFilesResponse> {
throw new Error("Not yet implemented");
let response: ds.DeleteDatasetResponse = { success: false };
try {
response = await (await this.client).ds.deleteDataset({
dsname: dataSetName,
});
if (!response.success) {
Gui.errorMessage(`Failed to delete dataset ${dataSetName}`);
}
} catch (error) {
Gui.errorMessage(`Failed to delete dataset ${dataSetName}`);
Gui.errorMessage(`Error: ${error}`);
}
return this.buildZosFilesResponse(response);
}

// biome-ignore lint/suspicious/noExplicitAny: apiResponse has no strong type
Expand Down
Loading
Loading