- 06 Jul 2023
- 19 Minutes to read
- Contributors
- Print
- DarkLight
Example ZSA API Requests
- Updated on 06 Jul 2023
- 19 Minutes to read
- Contributors
- Print
- DarkLight
Introduction
This article describes using some of the APIs related to the ZSA module. The examples below assume you have already done the following:
- Obtained your user token (according to Obtaining the Token Parameter).
- Have opened the ZSA API page (by clicking the Data API () icon and clicking Show APIs in the ZSA panel).
Listing Existing ZSA Messaging Agents
You can list the existing ZSA messaging agents as follows:
- Within the MvsServer functional group, expand the API GET method /zsa/api/v1/servers and click Try it out.
- In the ZHB Security Token field, specify your user token and click Execute.
The Response body area returns a JSON for every messaging agent that has been created. In the example above we see how two of the visible JSONs correspond to two messaging agents that are displayed in the messaging panels of the ZSA Configuration - Messaging page.
It is interesting to observe the JSON for a messaging agent, and how it corresponds to the messaging agent's configuration.
Four types of messaging agent can be created and edited via the ZSA Configuration - Messaging page (see this article) as well as via the API POST method /zsa/api/v1/servers/ (see Creating ZSA Messaging Agents below). The table below summarizes the four messaging types and the properties used by the JSON to define a messaging agent.
Messaging Agent Type / JSON Property | CSV | RAW | Connection | CSV Parser Only |
---|---|---|---|---|
type | 0 | 1 | 2 | 3 |
name | Name given to the messaging agent. | |||
description | Description given to the messaging agent (optional). | |||
hostName | Hostname that the messaging agent uses to connect to the datasource. For the CSV (type : 0), RAW (type : 1), and Connection (type : 2) this will be an IP address or hostname of the datasource. For the CSV Parser Only (type : 3) this will be localhost as it is running locally on the server hosting the ZSA module. Note: If the datasource is a LPAR on a mainframe the IP address or hostname will be that of the LPAR. | |||
portNumber | Port used by the messaging agent to connect to the datasource (typically 9999 for a mainframe). | |||
lparName | The name of LPAR on the mainframe. When the messaging agent has been created in the Zetaly Portal's ZSA Configuration - Messaging page or via the API POST method /zsa/api/v1/servers, the LPAR name is automatically retrieved by the messaging agent upon its creation (i.e. when it connects to the mainframe for the first time). The lparName property never needs specifying and is for informational purposes only. When using the API POST method /zsa/api/v1/servers to create a new CSV or RAW messaging agent, you can observe the returned value for the lparName property in the Response body area to confirm that you created the messaging agent on the intended mainframe LPAR. | |||
systemName | System name used by the mainframe. When the messaging agent has been created in the Zetaly Portal's ZSA Configuration - Messaging page or via the API POST method /zsa/api/v1/servers, the system name is automatically retrieved by the messaging agent upon its creation (i.e. when it connects to the mainframe for the first time). The systemName property never needs specifying and is for informational purposes only. When using the API POST method /zsa/api/v1/servers to create a new CSV or RAW messaging agent, you can observe the returned value for the systemName property in the Response body area to confirm that you created the messaging agent on the intended mainframe LPAR. | |||
sid | The system identifier (SID) used by all the mainframe's SMF records. When the messaging agent has been created in the Zetaly Portal's ZSA Configuration - Messaging page or via the API POST method /zsa/api/v1/servers, the SID is automatically retrieved by the messaging agent upon its creation (i.e. when it connects to the mainframe for the first time). The sid property never needs specifying and is for informational purposes only. When using the API POST method /zsa/api/v1/servers to create a new CSV or RAW messaging agent, you can observe the returned value for the sid property in the Response body area to confirm that you created the messaging agent on the intended mainframe LPAR. | |||
keepUnknownRecord | Determines whether the messaging agent will keep an unknown record. Possible values are false (do not keep) and true (keep). | |||
instanceQuantity | Determines the number of connection instances created by the messaging agent to use with the datasource. |
Creating ZSA Messaging Agents
To create a messaging agent that connects to a mainframe's LPAR you must know the following details:
- hostname or IP address of the LPAR
- port (typically 9999)
- LPAR name
- System name
- SID used by all the mainframe's SMF records
You do not need to know the LPAR name, system name or SID for defining the messaging agent. They are only required for verifying you have configured the messaging agent on the intended mainframe LPAR.
:::
In the example below we use the API POST method /zsa/api/v1/servers to create three different messaging agents as summarized in the table below.
Messaging Agent / Property | CSV 1 | RAW 2 | Connection 1 |
---|---|---|---|
type | 0 | 1 | 2 |
name | CSV 1 | CSV RAW 1 | Datasource 1 |
description | CSV data on LPAR 1 | Raw data on LPAR 1 | Datasource on LPAR 1 |
hostName | 17.105.9.56 | 17.105.9.56 | 17.105.9.56 |
portNumber | 9999 | 9999 | 9999 |
lparName see note 1 below | Not applicable | Not applicable | Not applicable |
systemName see note 1 below | Not applicable | Not applicable | Not applicable |
sid see note 1 below | Not applicable | Not applicable | Not applicable |
cell | cell | cell | cell |
keepUnknownRecord see note 2 below | Not applicable | true | Not applicable |
instanceQuantity | 2 | 3 | 2 |
The properties lparName
, systemName
, sid
never need specifing. They are for informational purposes only. When using the API POST method /zsa/api/v1/servers to create a new CSV or RAW messaging agent, you can observe the returned values for the lparName
, systemName
, sid
properties in the Response body area to confirm that you created the messaging agent on the intended mainframe LPAR.
The keepUnknownRecord
is not used by the CSV (type 0), Connection (type 2) or CSV Parser Only (type 3) messaging agent types. Therefore, the line keepUnknownRecord
is not required for the CSV (type 0), Connection (type 2) or CSV Parser Only (type 3) messaging agent types.
To create messaging agents based on the example above, do the following:
- Within the MvsServer functional group, expand the API POST method /zsa/api/v1/servers and click Try it out.
- In the ZHB Security Token specify your user token.
- In the Request body area, specify the following JSON for the messaging agent CSV 1.
{
"name": "CSV 1",
"description": "CSV data on LPAR 1",
"hostName": "17.105.9.56",
"portNumber": 9999,
"type": 0,
"instanceQuantity": 3
}
- Click Execute.
- In the Response body area verify that the lparName, systemName, and sid properties provided by the mainframe correspond to the values you expect.
- In the Request body area, specify the following JSON for the messaging agent RAW 1.
{
"name": "RAW 1",
"description": "CSV data on LPAR 1",
"hostName": "17.105.9.56",
"portNumber": 9999,
"type": 1,
"keepUnknownRecord": true,
"instanceQuantity": 2
}
- Click Execute.
- In the Response body area verify that the lparName, systemName, and sid properties provided by the mainframe correspond to the values you expect.
- In the Request body area, specify the following JSON for the messaging agent Connection 1.
{
"name": "Datasource 1",
"description": "Datasource on LPAR 1",
"hostName": "17.105.9.56",
"portNumber": 9999,
"type": 2,
"instanceQuantity": 2
}
- Click Execute.
The connection (type 2) messaging agent can be used on other datasource types in addition to a mainframe. The mainframe intentionally does not provide lparName, systemName, and sid as they are not required. Therefore, in the Response body area the lparName, systemName, and sid properties provided by the mainframe are blank.
Updating Messaging Agents
You can use the API PUT method /zsa/api/v1/servers/{mvsName} to update the connection configuration of an existing messaging agent. You need to know the name of the messaging agent that you want to update.
If you forget the name of the messaging agent that you want to modify you can quickly find it by listing all the messaging agents as described in Listing Existing ZSA Messaging Agents.
For example, the RAW 1 messaging agent created in Creating ZSA Messaging Agents was configured to keep unknown records and have two connection instances. If you want to change the RAW 1 messaging agent to not keep unknown records and have three connection instances you would do the following:
Within the MvsServer functional group, expand the API POST method /zsa/api/v1/servers/{mvsName} and click Try it out.
In the mvsName field type the name of the messaging agent you want to update (e.g. RAW 1).
In the ZHB Security Token specify your user token.
In the Request body area, specify a JSON with the all of the properties for the messaging agent that you want to update (i.e. the properties that you do not want to update and the properties that you do want to update).
{
"name": "RAW 1",
"description": "CSV data on LPAR 1",
"hostName": "17.105.9.56",
"portNumber": 9999,
"lparName": "IBMSYS1",
"systemName": "S0W1",
"sid": "S0W1",
"type": 1,
"keepUnknownRecord": false,
"instanceQuantity": 3
}
You must specify all the properties for the messaging agent even if you do not want to modify all of them. In our example, we only want to modify the two properties keepUnknownRecord
and instanceQuantity
, however we still need to specify the other unmodified properties name
, description
, hostName
, portNumber
, lparName
, systemName
, sid
and type
.
- Click Execute.
Deleting Messaging Agents
You can use the API DELETE method /zsa/api/v1/servers/{mvsName} to delete an existing messaging agent. You need to know the name of the messaging agent that you want to delete.
If you forget the name of the messaging agent that you want to delete you can quickly find it by listing all the messaging agents as described in Listing Existing ZSA Messaging Agents.
For example, if you want to delete the RAW 1 messaging agent created in Creating ZSA Messaging Agents you would do the following:
- Within the MvsServer functional group, expand the API DELETE method /zsa/api/v1/servers/{mvsName} and click Try it out.
- In the mvsName field type the name of the messaging agent you want to delete (e.g. RAW 1).
- In the ZHB Security Token specify your user token.
- Click Execute.
Duplicating Messaging Agents
You can use the API POST method /zsa/api/v1/servers/{mvsName} to duplicate an existing messaging agent. You need to know the name of the messaging agent that you want to duplicate.
If you forget the name of the messaging agent that you want to duplicate you can quickly find it by listing all the messaging agents as described in Listing Existing ZSA Messaging Agents.
For example, if you want to duplicate the CSV 1 messaging agent created in Creating ZSA Messaging Agents you would do the following:
- Within the MvsServer functional group, expand the API POST method /zsa/api/v1/servers/{mvsName} and click Try it out.
- In the mvsName field type the name of the messaging agent you want to duplicate (e.g. CSV 1).
- In the duplicateName field type the name of the duplicate messaging agent that will be created (e.g. CSV 2).
- In the ZHB Security Token specify your user token.
- Click Execute.
- Once the duplicated messaging agent is created you can optionally modify it according to Updating Messaging Agents.
Starting a Messaging Agent
You can use the API POST method /zsa/api/v1/servers/{mvsName}/messaging/start to start an existing messaging agent. You need to know the name of the messaging agent that you want to start.
If you forget the name of the messaging agent that you want to start you can quickly find it by listing all the messaging agents as described in Listing Existing ZSA Messaging Agents.
For example, if you want to start the CSV 1 messaging agent created in Creating ZSA Messaging Agents you would do the following:
- Within the MvsServer functional group, expand the API POST method /zsa/api/v1/servers/{mvsName}/messaging/start and click Try it out.
- In the mvsName field type the name of the messaging agent you want to start (e.g. CSV 1).
- In the ZHB Security Token specify your user token.
- Click Execute.
Stopping a Messaging Agent
You can use the API POST method /zsa/api/v1/servers/{mvsName}/messaging/stop to stop an existing messaging agent. You need to know the name of the messaging agent that you want to stop.
If you forget the name of the messaging agent that you want to stop you can quickly find it by listing all the messaging agents as described in Listing Existing ZSA Messaging Agents.
For example, if you want to stop the CSV 1 messaging agent created in Creating ZSA Messaging Agents you would do the following:
- Within the MvsServer functional group, expand the API POST method /zsa/api/v1/servers/{mvsName}/messaging/stop and click Try it out.
- In the mvsName field type the name of the messaging agent you want to stop (e.g. CSV 1).
- In the ZHB Security Token specify your user token.
- Click Execute.
Getting the Current Messaging Configuration of a Messaging Agent
You can use the API GET method /zsa/api/v1/servers/{mvsName}/messaging/configuration to obtain the current messaging configuration of an existing messaging agent. You need to know the name of the messaging agent whose messaging configuration you want to obtain.
If you forget the name of the messaging agent you can quickly find it by listing all the messaging agents as described in Listing Existing ZSA Messaging Agents.
The API GET method /zsa/api/v1/servers/{mvsName}/messaging/configuration supports the CSV (type 0), Connection (type 2) and CSV Parser (type 3) messaging agent types because they have additional configuration properties.
Since the RAW (type 1) messaging agent type does not have additional configuration properties, it is not supported. If you attempt to use the API GET method /zsa/api/v1/servers/{mvsName}/messaging/configuration with a RAW (type 1) messaging agent, the Response body area intentionally responds with the 500 : Internal server error
For example, if you want to obtain the configuration of the CSV 1 messaging agent created in Creating ZSA Messaging Agents you would do the following:
- Within the MvsServer functional group, expand the API GET method /zsa/api/v1/servers/{mvsName}/messaging/configuration and click Try it out.
- In the mvsName field type the name of the messaging agent whose configuration that you want to obtain (e.g. CSV 1).
- In the ZHB Security Token specify your user token.
- Click Execute.
The Response body area returns the messaging configuration properties of the messaging agent that you specified, which vary according to the messaging agent type as summarized in Table 1, Table 2 and Table 3 located in the Updating the Current Configuration of a Messaging Agent section.
The Response body area also returns additional configuration properties that are never processed by the API POST method /zsa/api/v1/servers/{mvsName}/messaging/configuration described in the Updating the Current Configuration of a Messaging Agent section. They are ignored and used for rendering the Configure dialog box within the ZSA's Configuration - Messaging page.
The defaultValue
is for informational purposes and never processed. It is useful for identifying the default value of a property.
Updating the Current Messaging Configuration of a Messaging Agent
You can use the API POST method /zsa/api/v1/servers/{mvsName}/messaging/configuration to update the current messaging configuration of an existing messaging agent. You need to know the name of the messaging agent whose messaging configuration you want to update.
If you forget the name of the messaging agent you can quickly find it by listing all the messaging agents as described in Listing Existing ZSA Messaging Agents.
The API POST method /zsa/api/v1/servers/{mvsName}/messaging/configuration supports the CSV (type 0), Connection (type 2) and CSV Parser (type 3) messaging agent types because they have additional configuration properties.
Since the RAW (type 1) messaging agent type does not have additional configuration properties, it is not supported. If you attempt to use the API POST method /zsa/api/v1/servers/{mvsName}/messaging/configuration with a RAW (type 1) messaging agent, the Response body area intentionally responds with the 500 : Internal server error.
The properties that you can use to update messaging agent's configuration vary according to the messaging agent type as summarized in Table 1, Table 2 and Table 3.
Table 1: Properties for a CSV (type 0) messaging agent
Property | Description | Default Value |
---|---|---|
MsgSize | Number of records polled from the mainframe at once. | 100 |
MsgSizeWaiting | Message size threshold. If there are less records in the mainframe queue, the poll time is waited before polling. | 100 |
PollTime | Duration to wait in seconds if there are less records than the message size threshold in the mainframe queue. | 30 |
FlushTime | Delay in seconds after which records are inserted in the database, regardless if the threshold was reached. | 180 |
MaxBulkInsertRows | Number of records inserted at once in the database. | 1000 |
StatisticsTime | Interval in ms at which statistics are produced. | 5000 |
ThreadPriority | Priority of the agent's threads (0 to 4). | 0 |
ParserWorkerThreads | Number of threads dedicated solely to parse records within ZSA. | 1 |
ConnectionThreads | Number of threads dedicated solely dedicated to fetching records from the mainframe. Each thread opens a socket. | 1 |
Table 2: Properties for a Connection (type 2) messaging agent
Property | Description | Default Value |
---|---|---|
MsgSize | Number of records polled from the mainframe at once. | 100 |
ConnectionSleepTime | Duration to wait if there are no records in the mainframe queue. | 5 |
Table 3: Properties for a CSV Parser (type 3) messaging agent
Property | Description | New Value |
---|---|---|
MsgSize | Number of entries pulled at once from the Zetaly queue. | 120 |
PollTime | Duration to wait in seconds if there are no records in the Zetaly queue. | 30 |
FlushTime | Delay in seconds after which records inserted in the database, regardless if the threshold was reached. | 180 |
MaxBulkInsertRows | Number of records inserted at once in the database. | 1000 |
StatisticsTime | Interval in ms at which statistics are produced. | 5000 |
In our example below we update the configuration of the CSV 1 messaging agent (type 0) according to the table 4.
Table 4: Example of updating properties for a CSV (type 0) messaging agent
Property | Description | Updated Value |
---|---|---|
MsgSize | Number of records polled from the mainframe at once. | 125 |
MsgSizeWaiting | Message size threshold. If there are less records in the mainframe queue, the poll time is waited before polling. | 125 |
PollTime | Duration to wait in seconds if there are less records than the message size threshold in the mainframe queue. | 35 |
FlushTime | Delay in seconds after which records are inserted in the database, regardless if the threshold was reached. | 180 - no change from default/existing value |
MaxBulkInsertRows | Number of records inserted at once in the database. | 1000 - no change from default/existing value |
StatisticsTime | Interval in ms at which statistics are produced. | 5000 - no change from default/existing value |
ThreadPriority | Priority of the agent's threads (0 to 4). | 1 |
ParserWorkerThreads | Number of threads dedicated solely to parse records within ZSA. | 2 |
ConnectionThreads | Number of threads dedicated solely dedicated to fetching records from the mainframe. Each thread opens a socket. | 2 |
To update the messaging configuration of the CSV 1 according to Table 4, you would do the following:
- Within the MvsServer functional group, expand the API POST method /zsa/api/v1/servers/{mvsName}/messaging/configuration and click Try it out.
- In the mvsName field type the name of the messaging agent whose configuration that you want to update (e.g. CSV 1).
- In the ZHB Security Token specify your user token.
- In the Request body area, specify one of the following JSONs:
JSON example 1: with only the necessary properties (i.e. the ones you are changing).
{
"configurationProperties": [
{
"name": "MsgSize",
"value": "125"
},
{
"name": "MsgSizeWaiting",
"value": "125"
},
{
"name": "PollTime",
"value": "35"
},
{
"name": "ThreadPriority",
"value": "1"
},
{
"name": "ParserWorkerThreads",
"value": "2"
},
{
"name": "ConnectionThreads",
"value": "2"
}
]
}
JSON example 2: includes all the properties (i.e. the ones you are changing and the ones you are not changing).
{
"configurationProperties": [
{
"name": "MsgSize",
"value": "125"
},
{
"name": "MsgSizeWaiting",
"value": "125"
},
{
"name": "PollTime",
"value": "35"
},
{
"name": "FlushTime",
"value": "180"
},
{
"name": "MaxBulkInsertRows",
"value": "1000"
},
{
"name": "StatisticsTime",
"value": "5000"
},
{
"name": "ThreadPriority",
"value": "1"
},
{
"name": "ParserWorkerThreads",
"value": "2"
},
{
"name": "ConnectionThreads",
"value": "2"
}
]
}
- Click Execute.
In the example above we see that you only need to include the properties in the JSON that you intend to update (i.e. Example 1). However, Example 2 which contains a complete set of properties is included so you can copy the model JSON structure for changing all the messaging properties of a messaging agent.
Obtaining the Default Messaging Configuration for Messaging Agents
You can use the API GET method /zsa/api/v1/servers/messaging/configuration to obtain the default messaging configuration that can then be used to reset your messaging agents back to their defult values.
To do this, proceed as follows:
- Within the MvsServer functional group, expand the API GET method /zsa/api/v1/servers/{mvsName}/messaging/configuration and click Try it out.
- In the ZHB Security Token specify your user token.
- Click Execute.
The Response body updates with an output similar to the following.
The Response body area returns the default messaging configuration properties for all the types of messaging agent, as summarized in Table 1, Table 2 and Table 3 located in the Updating the Current Configuration of a Messaging Agent section. - You can use the copy to clipboard icon to copy the JSON defining the default messaging configuration and paste it into the Request body area of the API POST method /zsa/api/v1/servers/{mvsName}/messaging/configuration in order to reset a messaging agent back to its default values.
The Response body area also returns additional configuration properties that are never processed by the API POST method /zsa/api/v1/servers/{mvsName}/messaging/configuration described in the Updating the Current Configuration of a Messaging Agent section. They are ignored and used for rendering the Configure dialog box within the ZSA's Configuration - Messaging page.
The Response body area returns the default messaging configuration properties for all the types of messaging agent, as summarized in Table 1, Table 2 and Table 3 located in the Updating the Current Configuration of a Messaging Agent section. Some of these messaging configuration properties are not used for cetain types of messaging agent. This is not a problem. When you use the API POST method /zsa/api/v1/servers/{mvsName}/messaging/configuration described in the Updating the Current Configuration of a Messaging Agent to reset a messaging agent back to its default messaging configuration, the API method ignores the unnecessary messaging properties.
Starting All Messaging Agents of a Certain Type
You can use the API POST method /zsa/api/v1/servers/{type}/start to start all messaging agents of a certain type.
To start all messaging agents of a certain type do the following:
- Within the MvsServer functional group, expand the API POST method /zsa/api/v1/servers/{type}/start and click Try it out.
- In the Agent Type drop-down field select the type (0, 1, 2, or 3) corresponding to the messaging agent types that you want to start.
- 0 - all messaging agents of the type RAW will be started
- 1 - all messaging agents of the type CSV will be started
- 2 - all messaging agents of the type Connector will be started
- 3 - all messaging agents of the type CSV Parser will be started
- In the ZHB Security Token specify your user token.
- Click Execute.
Stopping All Messaging Agents of a Certain Type
You can use the API POST method /zsa/api/v1/servers/{type}/stop to stop all messaging agents of a certain type.
To stop all messaging agents of a certain type do the following:
- Within the MvsServer functional group, expand the API POST method /zsa/api/v1/servers/{type}/stop and click Try it out.
- In the Agent Type drop-down field select the type (0, 1, 2, or 3) corresponding to the messaging agent types that you want to stop.
- 0 - all messaging agents of the type RAW will be stopped
- 1 - all messaging agents of the type CSV will be stopped
- 2 - all messaging agents of the type Connector will be stopped
- 3 - all messaging agents of the type CSV Parser will be stopped
- In the ZHB Security Token specify your user token.
- Click Execute.