Zoweと戯れる - (3) Zowe CLI

#はじめに
ZoweのCLI(Command Level Interface)を試してみました。
Windows PC上にクライアント用のモジュール(Node.jsベース)を導入することで、クライアント側のコマンドで(Windowsだとコマンドプロンプトから)z/OSの操作が色々とできるようになります。
すばらしいですねぇ。

## 関連記事
[Zoweと戯れる - (1) インストール](https://qiita.com/tomotagwork/items/e0fdb744f9c30fc224ed)
[Zoweと戯れる - (2) Zoweデスクトップ](https://qiita.com/tomotagwork/private/cc06368abf3a8caaaac5)
[Zoweと戯れる - (3) Zowe CLI](https://qiita.com/tomotagwork/private/78cd7c63dd00a29564a4)
[Zoweと戯れる - (4) VSCode Extension for Zowe](https://qiita.com/tomotagwork/items/8cdc99e669f8ae82eddc)

#セットアップ
## 環境: 
Windows10

node.js/npmのバージョンは以下の通り

```
c:\y\temp\zowe>node --version
v10.16.0

c:\y\temp\zowe>npm --version
6.9.0
```

## CLIモジュールのインストール

参考: [Installing Zowe CLI - Installing Zowe CLI from an online registry](https://docs.zowe.org/stable/user-guide/cli-installcli.html#installing-zowe-cli-from-an-online-registry)

PCはインターネットに接続している環境なので、Webから導入します。
指示通りコマンド打っただけ。
オープンってすばらしい。ホスト側とはエライ違いですなー。

```
c:\y\temp\zowe>npm config set @brightside:registry https://api.bintray.com/npm/ca/brightside

c:\y\temp\zowe>npm install -g @brightside/core@lts-incremental
npm WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance only, flatted is its successor.
C:\Users\TomohiroTaguchi\AppData\Roaming\npm\bright -> C:\Users\TomohiroTaguchi\AppData\Roaming\npm\node_modules\@brightside\core\lib\main.js
C:\Users\TomohiroTaguchi\AppData\Roaming\npm\zowe -> C:\Users\TomohiroTaguchi\AppData\Roaming\npm\node_modules\@brightside\core\lib\main.js

> @brightside/core@2.28.1 postinstall C:\Users\TomohiroTaguchi\AppData\Roaming\npm\node_modules\@brightside\core
> node ./scripts/validatePlugins

Since you re-installed Zowe CLI, we are re-validating any plugins.
No plugins have been installed into your CLI application.
+ @brightside/core@2.28.1
added 521 packages from 811 contributors in 22.628s


c:\y\temp\zowe>zowe plugins install @brightside/cics@lts-incremental
Imperative CLI Framework plug-ins can gain control of your CLI application
legitimately during the execution of every command. Install 3rd party plug-ins
at your own risk. CA Technologies makes no warranties regarding the use of
3rd party plug-ins.

Imperative's plugin installation program handles peer dependencies for modules
in the @brightside namespace and missing package.json file,
so you can safely ignore NPM warnings about
missing peer dependencies related to @brightside modules and absent C:\Users\TomohiroTaguchi\.zowe\plugins\installed\package.json file.
Registry = https://registry.npmjs.org/

_______________________________________________________________
npm WARN @brightside/cics@1.0.0 requires a peer of @brightside/core@2.x but none is installed. You must install peer dependencies yourself.
npm WARN @brightside/cics@1.0.0 requires a peer of @brightside/imperative@2.x but none is installed. You must install peer dependencies yourself.

Installed plugin name = '@brightside/cics'

_____ Validation results for plugin '@brightside/cics' _____
This plugin was successfully validated. Enjoy the plugin.

```

ヘルプ見てみる。

```
c:\y\temp\zowe>zowe --help

 DESCRIPTION
 -----------

   Welcome to Zowe CLI!

   Zowe CLI is a command line interface (CLI) that provides a simple and
   streamlined way to interact with IBM z/OS.

   For additional Zowe CLI documentation, visit https://zowe.github.io/docs-site

   For Zowe CLI support, visit https://zowe.org


 USAGE
 -----

   zowe <group>

   Where <group> is one of the following:

 GROUPS
 ------

   cics                  Interact with IBM CICS programs and transactions.
   config                Manage configuration and overrides
   plugins               Install and manage plug-ins
   profiles              Create and manage configuration profiles
   provisioning | pv     Perform z/OSMF provisioning tasks
   zos-console | console Issue z/OS console commands and collect responses
   zos-files | files     Manage z/OS data sets
   zos-jobs | jobs       Manage z/OS jobs
   zos-tso | tso         Interact with TSO
   zos-uss | uss         Issue z/OS USS commands and receive responses
   zos-workflows | wf    Create and manage z/OSMF workflows
   zosmf                 Interact with z/OSMF

 OPTIONS
 -------

   --version  | -V (boolean)

      Display the current version of Zowe CLI

   --available-commands  | --ac (boolean)

      Displays a list of available commands

 GLOBAL OPTIONS
 --------------

   --response-format-json  | --rfj (boolean)

      Produce JSON formatted data from a command

   --help  | -h (boolean)

      Display help text
```

こんな感じのディレクトリ構成が作られてる。

```
c:\Users\TomohiroTaguchi\.zowe>tree .
フォルダー パスの一覧:  ボリューム Windows
ボリューム シリアル番号は 1866-E2FC です
C:\USERS\TOMOHIROTAGUCHI\.ZOWE
├─imperative
│  └─logs
├─plugins
│  └─installed
│      └─node_modules
│          └─@brightside
│              └─cics
│                  ├─lib
│                  │  ├─api
│                  │  │  ├─constants
│                  │  │  ├─doc
│                  │  │  ├─methods
│                  │  │  │  ├─define
│                  │  │  │  ├─delete
│                  │  │  │  ├─discard
│                  │  │  │  ├─get
│                  │  │  │  ├─install
│                  │  │  │  └─set
│                  │  │  └─rest
│                  │  └─cli
│                  │      ├─-strings-
│                  │      ├─define
│                  │      │  ├─program
│                  │      │  └─transaction
│                  │      ├─delete
│                  │      │  ├─program
│                  │      │  └─transaction
│                  │      ├─discard
│                  │      │  ├─program
│                  │      │  └─transaction
│                  │      ├─get
│                  │      │  └─resource
│                  │      ├─install
│                  │      │  ├─program
│                  │      │  └─transaction
│                  │      └─refresh
│                  │          └─program
│                  └─node_modules
│                      ├─sax
│                      │  └─lib
│                      ├─xml2js
│                      │  └─lib
│                      └─xmlbuilder
│                          └─lib
├─profiles
│  ├─cics
│  ├─ssh
│  ├─tso
│  └─zosmf
├─settings
└─zowe
    └─logs

```

# 構成
参考: [Configuring Zowe CLI](https://zowe.github.io/docs-site/latest/user-guide/cli-configuringcli.html#defining-zowe-cli-connection-details)

コマンド打つときのオプションで接続先やユーザーなどをその都度指定してもよいですが、プロファイルを作っておくとデフォルトでそれを使ってくれます。
プロファイルもz/OSMF用とかssh用とか色々あって、どのコマンド使うときにどのサービス用のプロファイルが必要なのかとかがイマイチ分かりにくいのだが、基本はz/OSMFが使われるコマンドが多いみたいです。
ということでz/OSMF用プロファイル作成。

```
c:\Users\TomohiroTaguchi\.zowe>zowe profiles create zosmf-profile prof_zDTPE01 --host zdtpe01.mk.ise.com --port 10443 --user USER01 --password xxxxx --reject-unauthorized false
Profile created successfully! Path:
C:\Users\TomohiroTaguchi\.zowe\profiles\zosmf\prof_zDTPE01.yaml

host:               zdtpe01.mk.ise.com
port:               10443
user:               USER01
password:           xxxxx
rejectUnauthorized: false

Review the created profile and edit if necessary using the profile update command.


c:\Users\TomohiroTaguchi\.zowe>zowe profiles ls zosmf-profiles
prof_zDTPE01 (default)
```

次にTSO用のプロファイル(tso-profile)を作成します。これはTSOコマンドを実行する場合に必要でした。

```
c:\>zowe profiles create tso-profile prof_zDTPE01 --account ACCT# --logon-procedure ISPFPROC
Profile created successfully! Path:
C:\Users\TomohiroTaguchi\.zowe\profiles\tso\prof_zDTPE01.yaml

account:        ACCT#
characterSet:   697
codePage:       1047
columns:        80
logonProcedure: ISPFPROC
regionSize:     4096
rows:           24

Review the created profile and edit if necessary using the profile update command.

c:\>zowe  profiles list tso-profiles --sc
-
  name:     prof_zDTPE01 (default)
  contents:
    account:        ACCT#
    characterSet:   697
    codePage:       1047
    columns:        80
    logonProcedure: ISPFPROC
    regionSize:     4096
    rows:           24
```

SSH用のプロファイルを作成(ssh-profile)します。これはUSSコマンド実行時に必要でした。

```
c:\>zowe profiles create ssh-profile prof_zDTPE01 --host zdtpe01.mk.ise.com --user USER01 --password xxxxx
Profile created successfully! Path:
C:\Users\TomohiroTaguchi\.zowe\profiles\ssh\prof_zDTPE01.yaml

host:     zdtpe01.mk.ise.com
port:     22
user:     USER01
password: xxxxx

Review the created profile and edit if necessary using the profile update command.


c:\>zowe profiles list ssh-profiles --sc
-
  name:     prof_zDTPE01 (default)
  contents:
    host:     zdtpe01.mk.ise.com
    port:     22
    user:     USER01
    password: xxxxx
```

# 実行

[Using Zowe CLI](https://zowe.github.io/docs-site/latest/user-guide/cli-usingcli.html#displaying-zowe-cli-help)

## zos-files

データセットを見てみる。

```
c:\>zowe zos-files ls ds "IBMUSER.*"
IBMUSER.ATR.REPORT
IBMUSER.DDIR
IBMUSER.DDIR.D
IBMUSER.DDIR.I
IBMUSER.HCD.MSGLOG
IBMUSER.HCD.TERM
IBMUSER.HCD.TRACE
IBMUSER.JCLLIB
IBMUSER.SRCHDSL.LIST
IBMUSER.SUPERC.LIST
IBMUSER.S0W1.ISPF.ISPPROF
IBMUSER.ZDTPE01.ISPF.ISPPROF
IBMUSER.ZOSMF.CICS.PROVSION.XML
```

```
c:\>zowe zos-files ls ds "ZOWE01.*" -a
-
  dsname: ZOWE01.CPP.ZOSV221.D170810.BINDER.LOAD
  blksz:  6144
  catnm:  USERCAT.Z23A.ZOWE01
  cdate:  2019/04/25
  dev:    3390
  dsntp:  LIBRARY
  dsorg:  PO-E
  edate:  ***None***
  extx:   1
  lrecl:  0
  migr:   NO
  mvol:   N
  ovf:    NO
  rdate:  2019/05/09
  recfm:  U
  sizex:  78
  spacu:  BLOCKS
  used:   99
  vol:    A3SYS1
-
  dsname: ZOWE01.CPP.ZOSV221.D170810.SCNJCMP
  blksz:  32760
  catnm:  USERCAT.Z23A.ZOWE01
  cdate:  2019/04/25
  dev:    3390
  dsntp:  LIBRARY
  dsorg:  PO-E
  edate:  ***None***
  extx:   1
  lrecl:  0
  migr:   NO
  mvol:   N
  ovf:    NO
  rdate:  2019/04/25
  recfm:  U
  sizex:  3499
  spacu:  BLOCKS
  used:   99
  vol:    A3SYS1
-
  dsname: ZOWE01.SETUP.JCLLIB
  blksz:  27920
  catnm:  USERCAT.Z23A.ZOWE01
  cdate:  2019/04/25
  dev:    3390
  dsntp:  PDS
  dsorg:  PO
  edate:  ***None***
  extx:   1
  lrecl:  80
  migr:   NO
  mvol:   N
  ovf:    NO
  rdate:  2019/05/07
  recfm:  FB
  sizex:  150
  spacu:  CYLINDERS
  used:   2
  vol:    ZOWE01
-
  dsname: ZOWE01.SISLOAD
  blksz:  32760
  catnm:  USERCAT.Z23A.ZOWE01
  cdate:  2019/05/09
  dev:    3390
  dsntp:  LIBRARY
  dsorg:  PO-E
  edate:  ***None***
  extx:   1
  lrecl:  0
  migr:   NO
  mvol:   N
  ovf:    NO
  rdate:  2019/05/13
  recfm:  U
  sizex:  100
  spacu:  TRACKS
  used:   19
  vol:    ZOWE01
-
  dsname: ZOWE01.SISSAMP
  blksz:  32760
  catnm:  USERCAT.Z23A.ZOWE01
  cdate:  2019/05/09
  dev:    3390
  dsntp:  LIBRARY
  dsorg:  PO-E
  edate:  ***None***
  extx:   1
  lrecl:  0
  migr:   NO
  mvol:   N
  ovf:    NO
  rdate:  2019/05/13
  recfm:  U
  sizex:  100
  spacu:  TRACKS
  used:   1
  vol:    ZOWE01
-
  dsname: ZOWE01.ZFS
  catnm:  USERCAT.Z23A.ZOWE01
  dsorg:  VS
  migr:   NO
  mvol:   N
  vol:    *VSAM*
-
  dsname: ZOWE01.ZFS.DATA
  blksz:  ?
  catnm:  USERCAT.Z23A.ZOWE01
  cdate:  2019/04/25
  dev:    3390
  dsorg:  VS
  edate:  ***None***
  extx:   18
  lrecl:  ?
  migr:   NO
  mvol:   N
  ovf:    NO
  rdate:  2019/05/09
  recfm:  ?
  sizex:  90600
  spacu:  CYLINDERS
  used:   ?
  vol:    ZOWE01
```

yaml形式で返された。オサレ。

ヘルプによると、以下の辺りの操作ができそうです。

```xxx:ヘルプ抜粋
   create | cre  Create data sets
   delete | del  Delete a data set or Unix System Services file
   download | dl Download content from z/OS data sets and USS files
   invoke | call Invoke various z/OS utilities
   list | ls     List the details for data sets and the members in the data sets
   upload | ul   Upload the contents of a file to z/OS data sets
```

invokeというのは、IDCAMSユーティリティの利用のようで、VSAMの作成/削除なんかができそうです。


## zos-console

システムコマンド打ってみる。

```
c:\>zowe zos-console issue command "d a,l"
 CNZ4105I 18.30.01 DISPLAY ACTIVITY 850
  JOBS     M/S    TS USERS    SYSAS    INITS   ACTIVE/MAX VTAM     OAS
 00019    00019    00002      00033    00033    00000/00040       00036
  LLA      LLA      LLA      NSW  S  CSF      CSF      CSF      NSW  S
  JES2     JES2     IEFPROC  NSW  S  VLF      VLF      VLF      NSW  S
  HZR      HZR      IEFPROC  NSW  S  VTAM     VTAM     VTAM     NSW  S
  DLF      DLF      DLF      NSW  S  RACF     RACF     RACF     NSW  S
  RRS      RRS      RRS      NSW  S  TSO      TSO      STEP1    OWT  S
  SDSF     SDSF     SDSF     NSW  S  TCPIP    TCPIP    TCPIP    NSW  SO
  TN3270   TN3270   TN3270   NSW  SO HZSPROC  HZSPROC  HZSSTEP  NSW  SO
  SSHD3    STEP1    START1   OWT  AO PORTMAP  PORTMAP  PMAP     OWT  SO
  FTPD1    STEP1    FTPD     OWT  AO IZUANG1  IZUANG1  STEP1    OWT  SO
  IZUSVR1  IZUSVR1  ZOSMF    IN   SO ZOWESVR  ZOWESVR  ZOWESTEP OWT  SO
  ZOWESVR1 STEP1    IZUSVR   OWT  AO ZOWESVR3 STEP1    IZUSVR   OWT  AO
  ZOWESVR6 *OMVSEX  IZUSVR   IN   AO ZOWESVR9 *OMVSEX  IZUSVR   IN   AO
  ZOWESVR7 STEP1    IZUSVR   IN   AO ZOWESVR8 STEP1    IZUSVR   OWT  AO
  ZOWESVR3 *OMVSEX  IZUSVR   IN   AO ZOWESVR6 *OMVSEX  IZUSVR   IN   AO
  ZOWESVR8 *OMVSEX  IZUSVR   OWT  AO ZOWESVR9 *OMVSEX  IZUSVR   IN   AO
  ZOWESVR9 *OMVSEX  IZUSVR   IN   AO ZOWESVR3 *OMVSEX  IZUSVR   OWT  AO
  ZOWESVR5 *OMVSEX  IZUSVR   OWT  AO ZOWESVR9 *OMVSEX  IZUSVR   OWT  AO
  ZOWESVR5 STEP1    IZUSVR   OWT  AO ZOWESVR6 STEP1    IZUSVR   OWT  AO
  ZOWESVR7 *OMVSEX  IZUSVR   OWT  AO ZWESIS01 ZWESIS01 ZWESIS01 NSW  SO
 USER01   OWT  O   USER01   IN
```

## zos-jobs

JOBのリスト(JESのSpool)を見てみる。

```
c:\>zowe zos-jobs ls jobs -o "USER*"
TSU00185 ABEND S222 USER01 OUTPUT
TSU00176 ABEND S222 USER01 OUTPUT
TSU00097 ABEND S622 USER01 OUTPUT
TSU00034 ABEND S622 USER01 OUTPUT

c:>zowe zos-jobs ls jobs -o "USER*" --rfj
{
  "success": true,
  "exitCode": 0,
  "message": "List of jobs returned for prefix \"USER*\" and owner \"*\"",
  "stdout": "TSU00185 ABEND S222 USER01 OUTPUT\nTSU00176 ABEND S222 USER01 OUTPUT\nTSU00097 ABEND S622 USER01 OUTPUT\nTSU00034 ABEND S622 USER01 OUTPUT\n",
  "stderr": "",
  "data": [
    {
      "owner": "USER01",
      "phase": 20,
      "subsystem": "JES2",
      "phase-name": "Job is on the hard copy queue",
      "job-correlator": "T0000185S0W1....D61F3B9E.......:",
      "type": "TSU",
      "url": "https://xxx.xxx.xxx.xxx:10443/zosmf/restjobs/jobs/T0000185S0W1....D61F3B9E.......%3A",
      "jobid": "TSU00185",
      "class": "TSU",
      "files-url": "https://xxx.xxx.xxx.xxx:10443/zosmf/restjobs/jobs/T0000185S0W1....D61F3B9E.......%3A/files",
      "jobname": "USER01",
      "status": "OUTPUT",
      "retcode": "ABEND S222"
    },
    {
      "owner": "USER01",
      "phase": 20,
      "subsystem": "JES2",
      "phase-name": "Job is on the hard copy queue",
      "job-correlator": "T0000176S0W1....D61F248A.......:",
      "type": "TSU",
      "url": "https://xxx.xxx.xxx.xxx:10443/zosmf/restjobs/jobs/T0000176S0W1....D61F248A.......%3A",
      "jobid": "TSU00176",
      "class": "TSU",
      "files-url": "https://xxx.xxx.xxx.xxx:10443/zosmf/restjobs/jobs/T0000176S0W1....D61F248A.......%3A/files",
      "jobname": "USER01",
      "status": "OUTPUT",
      "retcode": "ABEND S222"
    },
    {
      "owner": "USER01",
      "phase": 20,
      "subsystem": "JES2",
      "phase-name": "Job is on the hard copy queue",
      "job-correlator": "T0000097S0W1....D61C321B.......:",
      "type": "TSU",
      "url": "https://xxx.xxx.xxx.xxx:10443/zosmf/restjobs/jobs/T0000097S0W1....D61C321B.......%3A",
      "jobid": "TSU00097",
      "class": "TSU",
      "files-url": "https://xxx.xxx.xxx.xxx:10443/zosmf/restjobs/jobs/T0000097S0W1....D61C321B.......%3A/files",
      "jobname": "USER01",
      "status": "OUTPUT",
      "retcode": "ABEND S622"
    },
    {
      "owner": "USER01",
      "phase": 20,
      "subsystem": "JES2",
      "phase-name": "Job is on the hard copy queue",
      "job-correlator": "T0000034S0W1....D618A173.......:",
      "type": "TSU",
      "url": "https://xxx.xxx.xxx.xxx:10443/zosmf/restjobs/jobs/T0000034S0W1....D618A173.......%3A",
      "jobid": "TSU00034",
      "class": "TSU",
      "files-url": "https://xxx.xxx.xxx.xxx:10443/zosmf/restjobs/jobs/T0000034S0W1....D618A173.......%3A/files",
      "jobname": "USER01",
      "status": "OUTPUT",
      "retcode": "ABEND S622"
    }
  ]
}
```

オプション指定でJSONになったりする。オサレー。

そのほか、JCLのサブミット(データセット上にあるJCL or ローカルのファイル指定)、Spoolの一覧参照(ST画面っぽい情報)、JOBLOG参照/ローカルのファイルに落とす、といった操作ができるようです。

```xxx:ヘルプ抜粋
   cancel | can  Cancel a job
   delete | del  Delete a job
   download | dl Download job output
   list | ls     List jobs and spool files
   submit | sub  Submit z/OS jobs
   view | vw     View details of a z/OS job
```

## zos-tso

TSOコマンドとして"LISTUSER"を打ってみます。

```
c:\>zowe zos-tso issue command LISTUSER --ssm
USER=USER01  NAME=UNKNOWN  OWNER=SYS1      CREATED=18.232
 DEFAULT-GROUP=SYS1     PASSDATE=19.115 PASS-INTERVAL=180 PHRASEDATE=N/A
 ATTRIBUTES=SPECIAL OPERATIONS
 REVOKE DATE=NONE   RESUME DATE=NONE
 LAST-ACCESS=19.152/09:18:40
 CLASS AUTHORIZATIONS=NONE
 NO-INSTALLATION-DATA
 NO-MODEL-NAME
 LOGON ALLOWED   (DAYS)          (TIME)
 ---------------------------------------------
 ANYDAY                          ANYTIME
  GROUP=SYS1      AUTH=USE      CONNECT-OWNER=SYS1      CONNECT-DATE=18.232
    CONNECTS=   139  UACC=NONE     LAST-CONNECT=19.152/09:18:40
    CONNECT ATTRIBUTES=NONE
    REVOKE DATE=NONE   RESUME DATE=NONE
  GROUP=IZUADMIN  AUTH=USE      CONNECT-OWNER=USER01    CONNECT-DATE=19.116
    CONNECTS=    00  UACC=NONE     LAST-CONNECT=UNKNOWN
    CONNECT ATTRIBUTES=NONE
    REVOKE DATE=NONE   RESUME DATE=NONE
SECURITY-LEVEL=NONE SPECIFIED
CATEGORY-AUTHORIZATION
 NONE SPECIFIED
SECURITY-LABEL=NONE SPECIFIED
READY
```

--rfj(Response Format Json)オプション付けてみます。

```
c:\>zowe zos-tso issue command LISTUSER --ssm --rfj
{
  "success": true,
  "exitCode": 0,
  "message": "",
  "stdout": "USER=USER01  NAME=UNKNOWN  OWNER=SYS1      CREATED=18.232  \n DEFAULT-GROUP=SYS1     PASSDATE=19.115 PASS-INTERVAL=180 PHRASEDATE=N/A    \n ATTRIBUTES=SPECIAL OPERATIONS  \n REVOKE DATE=NONE   RESUME DATE=NONE \n LAST-ACCESS=19.152/09:18:40   \n CLASS AUTHORIZATIONS=NONE  \n NO-INSTALLATION-DATA\n NO-MODEL-NAME\n LOGON ALLOWED   (DAYS)          (TIME)\n ---------------------------------------------\n ANYDAY                          ANYTIME\n  GROUP=SYS1      AUTH=USE      CONNECT-OWNER=SYS1      CONNECT-DATE=18.232\n    CONNECTS=   139  UACC=NONE     LAST-CONNECT=19.152/09:18:40\n    CONNECT ATTRIBUTES=NONE  \n    REVOKE DATE=NONE   RESUME DATE=NONE    \n  GROUP=IZUADMIN  AUTH=USE      CONNECT-OWNER=USER01    CONNECT-DATE=19.116\n    CONNECTS=    00  UACC=NONE     LAST-CONNECT=UNKNOWN        \n    CONNECT ATTRIBUTES=NONE  \n    REVOKE DATE=NONE   RESUME DATE=NONE    \nSECURITY-LEVEL=NONE SPECIFIED\nCATEGORY-AUTHORIZATION\n NONE SPECIFIED\nSECURITY-LABEL=NONE SPECIFIED\nREADY \n\n",
  "stderr": "",
  "data": {
    "success": true,
    "startResponse": {
      "success": true,
      "zosmfTsoResponse": {
        "servletKey": "USER01-102-aabaaaai",
        "queueID": "1310766",
        "sessionID": "0x66",
        "ver": "0100",
        "tsoData": [
          {
            "TSO MESSAGE": {
              "VERSION": "0100",
              "DATA": "IKJ56455I USER01 LOGON IN PROGRESS AT 11:12:07 ON JUNE 1, 2019"
            }
          }
        ],
        "reused": false,
        "timeout": false
      },
      "collectedResponses": [
        {
          "servletKey": "USER01-102-aabaaaai",
          "queueID": "1310766",
          "sessionID": "0x66",
          "ver": "0100",
          "tsoData": [
            {
              "TSO MESSAGE": {
                "VERSION": "0100",
                "DATA": "IKJ56455I USER01 LOGON IN PROGRESS AT 11:12:07 ON JUNE 1, 2019"
              }
            }
          ],
          "reused": false,
          "timeout": false
        }
      ],
      "servletKey": "USER01-102-aabaaaai",
      "messages": "IKJ56455I USER01 LOGON IN PROGRESS AT 11:12:07 ON JUNE 1, 2019\nIKJ56951I NO BROADCAST MESSAGES\n*****************************************************************\n*                                                               *\n* APPLICATION DEVELOPER'S CONTROLLED DISTRIBUTION (ADCD)        *\n*                                                               *\n*  ADCD.Z23A.CLIST(ISPFCL) PRODUCES THIS MESSAGE                *\n*  ADCD.* DATASETS CONTAIN SYSTEM CUSTOMIZATION                 *\n*  SMP/E DATASETS CAN BE LOCATED FROM 3.4 WITH DSNAME **.CSI    *\n*  HTTP://DTSC.DFW.IBM.COM/ADCD.HTML CONTAINS DOCUMENTATION     *\n*                                                               *\n*  USERID              PASSWORD        COMMENT                  *\n*  ----------------    ------------ --------------              *\n*  IBMUSER             - SYS1/IBMUSER FULL AUTHORITY            *\n*  ADCDMST             - ADCDMST      FULL AUTHORITY            *\n*  ADCDA THRU ADCDZ    - TEST         LIMITED AUTHORITY(NO OMVS)*\n*  OPEN1 THRU OPEN3    - SYS1         UID(0) (NO TSO)           *\n*                                                               *\n*****************************************************************\n \nREADY \n"
    },
    "startReady": false,
    "zosmfResponse": [
      {
        "servletKey": "USER01-102-aabaaaai",
        "ver": "0100",
        "tsoData": [
          {
            "TSO MESSAGE": {
              "VERSION": "0100",
              "DATA": "USER=USER01  NAME=UNKNOWN  OWNER=SYS1      CREATED=18.232  "
            }
          }
        ],
        "reused": false,
        "timeout": false
      }
    ],
    "commandResponse": "USER=USER01  NAME=UNKNOWN  OWNER=SYS1      CREATED=18.232  \n DEFAULT-GROUP=SYS1     PASSDATE=19.115 PASS-INTERVAL=180 PHRASEDATE=N/A    \n ATTRIBUTES=SPECIAL OPERATIONS  \n REVOKE DATE=NONE   RESUME DATE=NONE \n LAST-ACCESS=19.152/09:18:40   \n CLASS AUTHORIZATIONS=NONE  \n NO-INSTALLATION-DATA\n NO-MODEL-NAME\n LOGON ALLOWED   (DAYS)          (TIME)\n ---------------------------------------------\n ANYDAY                          ANYTIME\n  GROUP=SYS1      AUTH=USE      CONNECT-OWNER=SYS1      CONNECT-DATE=18.232\n    CONNECTS=   139  UACC=NONE     LAST-CONNECT=19.152/09:18:40\n    CONNECT ATTRIBUTES=NONE  \n    REVOKE DATE=NONE   RESUME DATE=NONE    \n  GROUP=IZUADMIN  AUTH=USE      CONNECT-OWNER=USER01    CONNECT-DATE=19.116\n    CONNECTS=    00  UACC=NONE     LAST-CONNECT=UNKNOWN        \n    CONNECT ATTRIBUTES=NONE  \n    REVOKE DATE=NONE   RESUME DATE=NONE    \nSECURITY-LEVEL=NONE SPECIFIED\nCATEGORY-AUTHORIZATION\n NONE SPECIFIED\nSECURITY-LABEL=NONE SPECIFIED\nREADY \n",
    "stopResponse": {
      "success": true,
      "zosmfTsoResponse": {
        "servletKey": "USER01-102-aabaaaai",
        "ver": "0100",
        "reused": false,
        "timeout": false
      },
      "servletKey": "USER01-102-aabaaaai"
    }
  }
}
```
ほほう。

```xxx:ヘルプ抜粋
   issue      Issue TSO commands
   ping       Ping a TSO address space
   send       Send data to TSO
   start | st Start TSO/E address space
   stop | sp  Stop TSO/E address space
```

## zos-uss

ls -la コマンドを打ってみる。

```
c:\>zowe zos-uss issue ssh "ls -la"

$ ls -la
total 514
drwxr-xr-x   7 USER01   SYS1        8192 Jun 11 10:30 .
drwxr-xr-x  25 OMVSKERN SYS1       16384 Aug 29  2018 ..
-rw-------   1 USER01   SYS1          61 May  8 02:30 .bash_history
-rw-r--r--   1 USER01   SYS1        1372 Jun  7 09:12 .profile
-rw-------   1 USER01   SYS1        1667 Jun 11 10:30 .sh_history
drwxr-xr-x   2 USER01   SYS1        8192 Dec  3  2018 .ssh
-rw-r-----   1 USER01   SYS1       75802 May 29 10:18 CEEDUMP.20190528.191839.16843394
drwxr-xr-x   2 USER01   SYS1        8192 Jun 10 20:05 JCL
drwxr-xr-x   2 USER01   SYS1        8192 Dec  4  2018 REXX
drwxr-xr-x   2 USER01   SYS1        8192 Dec  4  2018 Shell
drwxr-xr-x   3 USER01   SYS1        8192 Jun  3 18:21 Util
-rw-r-----   1 USER01   SYS1       61440 Jun  7 09:11 Util.tar
-rw-r--r--   1 USER01   SYS1        8706 May 10 08:52 setropts_list.txt
-rw-r--r--   1 USER01   SYS1           4 Apr 26 08:46 test.txt
```

ssh経由でコマンド打っているだけなので、あんまりありがたみがないですね。
無駄にnode.jsが動いているので、素でssh経由で実行するよりレスポンスもだいぶ悪いようです。
インターフェースが統一されていることが一つのメリットではありますが。

## cics

参考: [Zowe CLI Plug-in for IBM CICS](https://zowe.github.io/docs-site/latest/user-guide/cli-cicsplugin.html)

CICSアクセス用のプロファイルというのがあるので、そこで指定する情報を見てみます。

```
c:\>zowe profiles create cics-profile -h

 COMMAND NAME
 ------------

   cics-profile | cics

 DESCRIPTION
 -----------

   A cics profile is required to issue commands in the cics command group that
   interact with CICS regions. The cics profile contains your host, port, user
   name, and password for the IBM CICS management client interface (CMCI) server of
   your choice.

 USAGE
 -----

   zowe profiles create cics-profile <profileName> [options]

 POSITIONAL ARGUMENTS
 --------------------

   profileName           (string)

      Specifies the name of the new cics profile. You can load this profile by using
      the name on commands that support the "--cics-profile" option.

 REQUIRED OPTIONS
 ----------------

   --host  | -H (string)

      The CMCI server host name

   --user  | -u (string)

      Your username to connect to CICS

   --password  | -p (string)

      Your password to connect to CICS

 OPTIONS
 -------

   --port  | -P (number)

      The CMCI server port

      Default value: 1490

   --region-name  (string)

      The name of the CICS region name to interact with

   --cics-plex  (string)

      The name of the CICSPlex to interact with

   --overwrite  | --ow (boolean)

      Overwrite the cics profile when a profile of the same name exists.

 GLOBAL OPTIONS
 --------------

   --response-format-json  | --rfj (boolean)

      Produce JSON formatted data from a command

   --help  | -h (boolean)

      Display help text


 EXAMPLES
 --------

   - Create a cics profile named 'cics123' to connect to CICS at
   host zos123 and port 1490:

      $ zowe profiles create cics-profile cics123 --host zos123 --port 1490 --user ibmuser --password myp4ss

```

これを見ると、CMCIでCICSの管理を行うようなので、CICS側にはCMCIの構成を行っておく必要があるようです。
CICS側にCMCIの構成を行って、それに合わせてプロファイルを作成します。

```
c:\>zowe profiles create cics-profile prof_zdtpe01_ct55v4a1 --host zdtpe01.mk.ise.com --port 55432 --user USER01 --password xxx
Profile created successfully! Path:
C:\Users\TomohiroTaguchi\.zowe\profiles\cics\prof_zdtpe01_ct55v4a1.yaml

host:     zdtpe01.mk.ise.com
port:     55432
user:     USER01
password: xxx

Review the created profile and edit if necessary using the profile update command.

c:\>zowe profiles list cics --sc
-
  name:     prof_zdtpe01_ct55v4a1 (default)
  contents:
    host:     zdtpe01.mk.ise.com
    port:     55432
    user:     USER01
    password: xxx
```

CICS用のコマンドで出来ること。

```
c:\>zowe cics -h

 DESCRIPTION
 -----------

   Interact with IBM CICS programs and transactions.

 USAGE
 -----

   zowe cics <group>

   Where <group> is one of the following:

 GROUPS
 ------

   define | def  Define new resources to CICS
   delete | del  Delete resources from CICS
   discard | dis Discard resources from CICS
   get           Get resources from CICS
   install | ins Install resources to CICS
   refresh | ref Refresh program on CICS

 GLOBAL OPTIONS
 --------------

   --response-format-json  | --rfj (boolean)

      Produce JSON formatted data from a command

   --help  | -h (boolean)

      Display help text
```

資源定義の操作(追加、削除、インストールなど)を、裏ではCMCI経由で実施するイメージのようです。

以下、CPSM構成ではなく、単発のCICSリージョンにCMCIの構成をしている環境の操作例です。

TAGGRPというCSDグループのリソース一覧を取得してみます。

```
c:\>zowe cics get resource CICSCSDResource --region-name CT55V4A1 --criteria "CSDGROUP=TAGGRP"
-
  _keydata: E3C1C7C7D9D74040C4C6C8D5D1C9E5D70000049C
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  DFHNJIVP
  deftype:  BUNDLE
-
  _keydata: E3C1C7C7D9D74040C4C6C8F0E7C3D4F20000009A
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  DFH0XCM2
  deftype:  PROGRAM
-
  _keydata: E3C1C7C7D9D74040C8C5D3D3D64040400000049C
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  HELLO
  deftype:  BUNDLE
-
  _keydata: E3C1C7C7D9D74040C8C5D3D3D6F240400000049C
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  HELLO2
  deftype:  BUNDLE
-
  _keydata: E3C1C7C7D9D74040C9D5D8E2C9D5C7F200000495
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  INQSING2
  deftype:  URIMAP
-
  _keydata: E3C1C7C7D9D74040D1E2D7C9D7C5F0F100000464
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  JSPIPE01
  deftype:  PIPELINE
-
  _keydata: E3C1C7C7D9D74040D1E2E3C3D7F0F1400000048E
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  JSTCP01
  deftype:  TCPIPSERVICE
-
  _keydata: E3C1C7C7D9D74040D7C7D4E6C2C3D3F10000009A
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  PGMWBCL1
  deftype:  PROGRAM
-
  _keydata: E3C1C7C7D9D74040E3C5E2E3C3C1D3F10000049C
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  TESTCAL1
  deftype:  BUNDLE
-
  _keydata: E3C1C7C7D9D74040E6C2C3F14040404000000493
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  WBC1
  deftype:  TRANSACTION
-
  _keydata: E3C1C7C7D9D74040E6D3D7F140404040000004A9
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  WLP1
  deftype:  JVMSERVER
-
  _keydata: E3C1C7C7D9D74040E6D3D7F240404040000004A9
  cicssys:  CT55V4A1
  csdgroup: TAGGRP
  defname:  WLP2
  deftype:  JVMSERVER
```

同じ情報をJSON形式で取得するために--rfj(response-format-json)を指定してみます。

```
c:\>zowe cics get resource CICSCSDResource --region-name CT55V4A1 --criteria "CSDGROUP=TAGGRP" --rfj
{
  "success": true,
  "exitCode": 0,
  "message": "",
  "stdout": "\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040C4C6C8D5D1C9E5D70000049C\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m DFHNJIVP\n  \u001b[33mdeftype: \u001b[39m BUNDLE\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040C4C6C8F0E7C3D4F20000009A\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m DFH0XCM2\n  \u001b[33mdeftype: \u001b[39m PROGRAM\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040C8C5D3D3D64040400000049C\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m HELLO\n  \u001b[33mdeftype: \u001b[39m BUNDLE\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040C8C5D3D3D6F240400000049C\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m HELLO2\n  \u001b[33mdeftype: \u001b[39m BUNDLE\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040C9D5D8E2C9D5C7F200000495\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m INQSING2\n  \u001b[33mdeftype: \u001b[39m URIMAP\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040D1E2D7C9D7C5F0F100000464\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m JSPIPE01\n  \u001b[33mdeftype: \u001b[39m PIPELINE\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040D1E2E3C3D7F0F1400000048E\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m JSTCP01\n  \u001b[33mdeftype: \u001b[39m TCPIPSERVICE\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040D7C7D4E6C2C3D3F10000009A\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m PGMWBCL1\n  \u001b[33mdeftype: \u001b[39m PROGRAM\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040E3C5E2E3C3C1D3F10000049C\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m TESTCAL1\n  \u001b[33mdeftype: \u001b[39m BUNDLE\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040E6C2C3F14040404000000493\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m WBC1\n  \u001b[33mdeftype: \u001b[39m TRANSACTION\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040E6D3D7F140404040000004A9\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m WLP1\n  \u001b[33mdeftype: \u001b[39m JVMSERVER\n\u001b[32m- \u001b[39m\n  \u001b[33m_keydata: \u001b[39mE3C1C7C7D9D74040E6D3D7F240404040000004A9\n  \u001b[33mcicssys: \u001b[39m CT55V4A1\n  \u001b[33mcsdgroup: \u001b[39mTAGGRP\n  \u001b[33mdefname: \u001b[39m WLP2\n  \u001b[33mdeftype: \u001b[39m JVMSERVER\n",
  "stderr": "",
  "data": {
    "response": {
      "xmlns": "http://www.ibm.com/xmlns/prod/CICS/smw2int",
      "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
      "xsi:schemaLocation": "http://www.ibm.com/xmlns/prod/CICS/smw2int http://zdtpe01.mk.ise.com:55432/CICSSystemManagement/schema/CICSSystemManagement.xsd",
      "version": "3.0",
      "connect_version": "0550",
      "resultsummary": {
        "api_response1": "1024",
        "api_response2": "0",
        "api_response1_alt": "OK",
        "api_response2_alt": "",
        "recordcount": "12",
        "displayed_recordcount": "12"
      },
      "records": {
        "cicscsdresource": [
          {
            "_keydata": "E3C1C7C7D9D74040C4C6C8D5D1C9E5D70000049C",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "DFHNJIVP",
            "deftype": "BUNDLE"
          },
          {
            "_keydata": "E3C1C7C7D9D74040C4C6C8F0E7C3D4F20000009A",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "DFH0XCM2",
            "deftype": "PROGRAM"
          },
          {
            "_keydata": "E3C1C7C7D9D74040C8C5D3D3D64040400000049C",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "HELLO",
            "deftype": "BUNDLE"
          },
          {
            "_keydata": "E3C1C7C7D9D74040C8C5D3D3D6F240400000049C",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "HELLO2",
            "deftype": "BUNDLE"
          },
          {
            "_keydata": "E3C1C7C7D9D74040C9D5D8E2C9D5C7F200000495",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "INQSING2",
            "deftype": "URIMAP"
          },
          {
            "_keydata": "E3C1C7C7D9D74040D1E2D7C9D7C5F0F100000464",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "JSPIPE01",
            "deftype": "PIPELINE"
          },
          {
            "_keydata": "E3C1C7C7D9D74040D1E2E3C3D7F0F1400000048E",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "JSTCP01",
            "deftype": "TCPIPSERVICE"
          },
          {
            "_keydata": "E3C1C7C7D9D74040D7C7D4E6C2C3D3F10000009A",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "PGMWBCL1",
            "deftype": "PROGRAM"
          },
          {
            "_keydata": "E3C1C7C7D9D74040E3C5E2E3C3C1D3F10000049C",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "TESTCAL1",
            "deftype": "BUNDLE"
          },
          {
            "_keydata": "E3C1C7C7D9D74040E6C2C3F14040404000000493",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "WBC1",
            "deftype": "TRANSACTION"
          },
          {
            "_keydata": "E3C1C7C7D9D74040E6D3D7F140404040000004A9",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "WLP1",
            "deftype": "JVMSERVER"
          },
          {
            "_keydata": "E3C1C7C7D9D74040E6D3D7F240404040000004A9",
            "cicssys": "CT55V4A1",
            "csdgroup": "TAGGRP",
            "defname": "WLP2",
            "deftype": "JVMSERVER"
          }
        ]
      }
    }
  }
}
```

このコマンドを使う場合は、CMCIの作法にがっつり依存するので、その辺りを調べながら使う必要がありますね。

CMCIはHTTP経由でCICSの管理が行えるインターフェースを提供しているのですが、やり取りされるデータはXMLなんですよね。それを無理やりJSONに変換しているせいか、xmlnsとかXMLの名残がありますね。まぁこの辺は無視すればよいのですが、stdoutの情報とか要らない情報も無駄に載ってきてしまうのはちょっとイケてないです...

#雑感
このCLIはnodejsとして実装されているのと、HTTPでデータ取ってくることが多く、レスポンスとしてはモッサリな感じです。
コマンドやオプションもちょっと分かりにくいので、日常のオペレーションでこれを利用する(PCOMの代替として利用する)というのは厳しそうです。
どちらかというと、自動化、Dev/Ops、CD/CIといった所につなげるのが主要なターゲットなんだと思います。
各種オペレーションが統一されたコマンド体系で実行できたり、JSON形式で結果を取得出来たりと、スクリプトでハンドリングしやすいという所に大いなる価値があるのだと思います。