Using your Local API Mediation Layer with REST clients and Zowe CLI
Article 2 of 2 — Access z/OS objects like files, jobs, applications, etc. through the Local API ML installed in the Minikube instance.
{Core} In my previous article (1 of 2) ‘Local Zowe API Mediation Layer on Windows 10 using Minikube’ you have learnt how to install and configure The Open Mainframe Project’s Zowe API Mediation Layer in a Minikube instance with access to the outside world.
In this article, you will see how to interact against your z/OS LPAR through your new Local API ML in the Minikube cluster, using the Swagger UI on the API Catalog interface, REST client applications and Zowe CLI.
✔️ API Catalog Swagger interface.
1️⃣ Get the Gateway Service URL using the Minikube command:
minikube service gateway-service --url -n zowe
2️⃣ Choose ‘The API Catalog is running” hyperlink:
3️⃣ Authenticate using your z/OS Security System user and password:
4️⃣ Select the “z/OS Datasets and Unix Files services” API Service:
5️⃣ Scroll down until the “Data Sets v2 APIs” and select “GET /api/v2/datasets/{filter}”
6️⃣ Select “Try it out” button:
7️⃣ Specify a value for the filter field (e.g. sys1.proc*) and click on Execute:
The Responses section will show: cURL command template, Request URL, Server Response Return Code, Response Body in json format and Response headers.
✔️ Using REST Client Applications.
You can execute an API query against the Local API ML using any REST client application of your choice. You will need the gateway services URL gotten in the above Swagger example, the HTTP method, the endpoint (e.g. /api/v2/datasets/{filter}), and your z/OS Security System Userid and password for the Authorization Header.
☀️ Talend API Tester
☀️ Insomnia REST Client
✔️ Zowe Command Line Interface (CLI).
1️⃣ Zowe CLI installation:
Follow the Zowe CLI installation instructions in the Installation Zowe CLI section of Setup documentation.
2️⃣ Base Profile Creation:
Create a Zowe Base Profile using the following syntax:
zowe profiles create base-profile <Base Profile Name> --host <Minikube Instance IP> --port <gateway-service port> --user <SAF User> --password <User Password> --ru false
Validate the Base Profile just created using ‘zowe profiles list base -sc’:
3️⃣ Login to API ML:
Login to the API ML using the base profile created in the above step:
zowe auth login apiml --base-p <Base Profile>
4️⃣ Commands & Plug-ins Execution
You can execute Zowe commands or plug-ins using the base profile created above. The authentication token stored in the profile during login will be used for validation against your Local API ML.
⭐️Listing data sets matching a pattern using Zowe command:
zowe zos-files list data-set <filter> --base-p <Base Profile Name>
⭐️Retrieving an element from Endevor to a local file using Endevor Plug-in:
zowe endevor retrieve element <Elem> <Endevor Inventory Location> --tf localfile.txt -i ENDEVOR --base-p <Base Profile Name> --endevor-p <Endevor Profile Name>
You can also use the token issued by the API ML login command in a REST Client application supporting Bearer Token:
- Login to the API ML using the Show Token option:
zowe auth login apiml --base-p <Base Profile Name> --st
- Open the REST client application that supports Bearer Token and paste the token issued by API ML in the Authentication Header. Execute an API query using an endpoint like the examples shown in previous section:
Conclusion
You can install a Local Zowe API Mediation Layer on an Open Kubernetes solution like Minikube and use it for Development/Testing purposes. The approach let you connect to the z/OS partition by sharing the IP with the private Minikube IP range.
“If you enjoyed this blog checkout more Zowe blogs here. Or, ask a question and join the conversation on the Open Mainframe Project Slack Channel #Zowe-dev, #Zowe-user or #Zowe-onboarding. If this is your first time using the OMP slack channel register here.”