WebSphere Automation "How To" Series #10 : How to view WebSphere Automation REST APIs using Swagger UI
Previous blogs in this WebSphere Automation "How To" series :
WebSphere Automation "How To" Series #1 : How to get WebSphere Automation UI URL WebSphere Automation "How To" Series #2 : How to specify user roles and permissions WebSphere Automation "How To" Series #3 : How to configure WebSphere Automation with an Enterprise LDAP WebSphere Automation "How To" Series #4 : How to register WebSphere Application Server traditional servers using configuretWasUsageMetering.py script WebSphere Automation "How To" Series #5 : How to register WebSphere Liberty servers WebSphere Automation "How To" Series #6 : How to configure email server and email addresses for notifications WebSphere Automation "How To" Series #7 : How to setup Instana to send alerts to WebSphere Automation WebSphere Automation "How To" Series #8 : How to setup secure access to Linux or UNIX servers WebSphere Automation "How To" Series #9 : How to trigger a memory leak health investigation when used heap is over 80 percent This post will focus on how to view WebSphere Automation REST APIs using Swagger UI.
The WebSphere Automation REST APIs are technology preview in this release. IBM Docs directly related to WebSphere Automation REST API are located at
https://www.ibm.com/docs/en/ws-automation?topic=technology-preview-viewing-rest-api.
Swagger UI can be utilized as the initial web interface to learn about and use the WebSphere Automation REST APIs. In the OCP console, under your namespace navigate to Networking -> Routes to view the available entries. The following is a screenshot of the Routes page.
Click the URL in the Location column for
wsa-secure-apis
. To open Swagger UI, you need to append
/openapi/ui
to the existing URL and press Enter to load the page. The following screenshot shows the top of the Swagger UI page.
Notice that initially the 'Authorize' button icon shows as unlocked because no authorization has yet occurred.
Before utilizing the WebSphere Automation REST APIs, you need to authorize using JWT. When you click on the 'Authorize' button, the following pop-up will appear.
To get the token value, you first need the password for the administrator account, which you can get with the following command :
oc -n WSA_INSTANCE_NAMESPACE get secret admin-user-details -o jsonpath='{.data.initial_admin_password}' | base64 -d && echo
Using that password, you can get the token value with the following command :
curl -k -X POST -H 'Content-Type: application/json' -d '{"username":"admin","password":"<password>"}' https://$(oc get route -n WSA_INSTANCE_NAMESPACE -o jsonpath='{.items[?(@.spec.to.name=="ibm-nginx-svc")].spec.host}')/icp4d-api/v1/authorize | jq -r .token
Enter the token value and click 'Authorize'. Finally, click 'Close' to close the pop-up for authorization as shown in the following screenshot.
Notice that the 'Authorize' button icon shows as locked because we have successfully authorized with a valid token.
You are now ready to use Swagger UI to execute the WebSphere Automation REST APIs. The following is a screenshot showing Swagger UI display of WebSphere Automation REST APIs for Assets.
An asset resource models application servers and JDKs that have been registered with WebSphere Automation. An application server can be either a traditional WebSphere Application Server or Liberty Server. The following is a screenshot of the Get Assets showing the top with a 'Try it out' button on the right hand side.
After clicking the 'Try it out' button, you can enter any specific parameters and then click the 'Execute' button. The following is an example where we have entered a couple of parameters (fromVersion=9.0.5.11 and type=traditional). There is only one traditional WebSphere Application Server at v9.0.5.11 or later registered in our current environment as the results will show. Here are the Swagger UI screenshots showing the request and results.
You can find more IBM Docs related to WebSphere Automation at https://www.ibm.com/docs/en/ws-automation.
#websphere#automation #WSA#WebSphereAutomation