- Community Home
- >
- Software
- >
- HPE Morpheus Software
- >
- HPE Morpheus Enterprise
- >
- How to create the custom report using API instead ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 09:39 PM
06-27-2022 09:39 PM
How to create the custom report using API instead of SQL query?
We are planning to fetch the data using API instead of SQL query do you have any examples.
- Tags:
- API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 06:13 AM
06-28-2022 06:13 AM
Re: How to create the custom report using API instead of SQL query?
Hi @ibrahim.k_Ibrahim, I’ve grabbed this directly from the developer.morpheusdata.com docs here. This shows an example in [any] plugin type utilizing a REST call:
HTTP API Client
The morpheus-plugin-api
library comes with a utility for facilitating quick and easy API calls to external integrations. This is called teh HttpApiClient
and replaces the use of the RestApiUtil
.
The developer is, of course, able to utilize any HTTP or SDK/API client they choose within the java ecosystem if so desired. However, this client provides some common functions such as SSL Validation, Throttling, Keep-Alive, Etc. and is based on the Apache HTTP Client.
TIP Reuse the same client instance when dealing with periodic refresh methods related to caching for best performance. Be mindful that throttling might be necessary to slow down the calls to the service.
Example
Below is an example API Call taken from the Infoblox
plugin.
import com.morpheusdata.core.util.HttpApiClient
HttpApiClient infobloxClient = new HttpApiClient()
try {
def results = infobloxClient.callJsonApi(serviceUrl, apiPath, poolServer.serviceUsername, poolServer.servicePassword, new HttpApiClient.RequestOptions(headers:['Content-Type':'application/json'],
queryParams:pageQuery, ignoreSSL: poolServer.ignoreSsl), 'GET')
} catch(e) {
log.error("verifyPoolServer error: ${e}", e)
} finally {
infobloxClient.shutdownClient()
}
return rtn
There are several methods to call the api and automatically handle certain payload formats such as callJsonApi
, callXmlApi
, or plain callApi
.
Options can be passed relating to the request via the HttpApiClient.RequestOptions
object. Please refer to the java api doc for available options.
TIP Remember to always shutdown the client after it is used to clean up the connection manager in a try{} finally{}
type block

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2022 02:26 AM
06-29-2022 02:26 AM
Re: How to create the custom report using API instead of SQL query?
Thanks for the details. I am planning to retrieve the few information using API and show it in the custom report. In that document I didn’t see any details for renderer maping.
Below is the example code:
import groovy.json.JsonSlurper
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.OutputStream;
import java.util.Base64.Encoder
// Create a trust manager that does not validate certificate chains like the default
TrustManager trustAllCerts = new TrustManager{
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers()
{
return null;
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
{
//No need to implement.
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
{
//No need to implement.
}
}
};
// Install the all-trusting trust manager
try
{
SSLContext sc = SSLContext.getInstance(“SSL”);
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
catch (Exception e)
{
System.out.println(e);
}
def message = ‘{“username”:“eve.holt@reqres.in”, “password”:“cityslicka”}’
def post = new URL(“https://reqres.in/api/login”).openConnection();
post.setRequestMethod(“POST”)
post.setDoOutput(true)
post.setRequestProperty(“Content-Type”, “application/json”)
post.getOutputStream().write(message.getBytes(“UTF-8”))
def postRC = post.getResponseCode()
def results = post.getInputStream().getText()
println(results)
def slurper = new groovy.json.JsonSlurper()
def json = slurper.parseText(results)
println(json)
It will return the token I wants to store and return the value in renderer.hbs