Is it possible to get data from REST APIs in SpagoBI? - spagobi

I try to use Tuleap REST API with SpagoBI and it can't find any information.
So, is it possible to get data from REST APIs in SpagoBI?
Thanks for your answer,
Sandra

Yes, it is possible. I've spent a while trying to get this working.
Below is a link with the technique that worked for me.
In short:
I'm using a Script Data-Set, the Groovy language, and the Groovy WSLite web service library. This required updating the version of Groovy shipped with SpagoBI and dropping in the Groovy WSLite library.
The Groovy script retrieves any parameters passed
Makes the web service calls with the parameters
Parses the results
Creates the output in SpagoBI's DataSet XML format
SpagoBI DataSet REST Webservice via Groovy
//Sample code: Using Groovy and Groovy WSLite to call a RESTful web service
//Then, the response is parsed and returned in SpagoBI DataSet's XML format
import wslite.rest.*
def param_ip = parameters['param_ip'] ?: ''
def client = new RESTClient("http://ip-api.com/json/${param_ip.toString()}")
def response = client.get()
assert response.statusCode == 200
def str = response.json
"""
<ROWS>
<ROW
params="${parameters['param_ip'].toString()}"
status="${str.status.toString()}"
country="${str.country.toString()}"
countryCode="${str.countryCode.toString()}"
region="${str.region.toString()}"
regionName="${str.regionName.toString()}"
city="${str.city.toString()}"
zip="${str.zip.toString()}"
lat="${str.lat.toString()}"
lon="${str.lon.toString()}"
timezone="${str.timezone.toString()}"
isp="${str.isp.toString()}"
org="${str.org.toString()}"
as="${str.as.toString()}"
/>
</ROWS>
""".toString()

It is possible to use REST 2.0 API, but you have to have FIWARE version of SpagoBI.
Versions are the same, excpet that FIWARE have REST API services.
Check this links:
http://catalogue.fiware.org/enablers/data-visualization-spagobi/documentation
and Apiary:
http://docs.spagobi.apiary.io/#reference/0/the-content-subresource/return-the-document-content

Related

Send messages to AWS SQS using JMeter

I want to test the scenarios of sending message to AWS SQS from Jmeter. But i dont find any relevant procedure to do it. I came to know about awsmaster plugin but after installing it, it doesnot get installed(seems like a corrupted version)
I am trying with Custom code but there also, the attribute builder() of "sqs client" shows a warning as "This static method of interface SqsClient can only be accessed as SqsClient.builder"
So, can someone please guide how to send messages to SQS queue using Jmeter and the steps.Thanks
If you're willing to copy and paste the code to initialize the SqsClient you can take a look at AWS Java SDK Examples repository:
SqsClient sqsClient = SqsClient.builder()
.region(Region.US_WEST_2)
.credentialsProvider(ProfileCredentialsProvider.create())
.build();
Then you can send the message like it's described here:
CreateQueueRequest request = CreateQueueRequest.builder()
.queueName(queueName)
.build();
sqsClient.createQueue(request);
GetQueueUrlRequest getQueueRequest = GetQueueUrlRequest.builder()
.queueName(queueName)
.build();
String queueUrl = sqsClient.getQueueUrl(getQueueRequest).queueUrl();
SendMessageRequest sendMsgRequest = SendMessageRequest.builder()
.queueUrl(queueUrl)
.messageBody(message)
.delaySeconds(5)
.build();
sqsClient.sendMessage(sendMsgRequest);
The code can be placed in i.e. JSR223 Sampler, use Groovy as the scripting language.
Make sure to add necessary import statements, copy AWS Java SDK with all its dependencies to JMeter classpath and restart JMeter to pick up the jars.

Try to load CDN and invoke method in CDN js in JMeter

In our App, we are using Video Publishing API (https://static.opentok.com/v2/js/opentok.js).
The problem with my test case is, we are externally invoking a method "Connect(-,-)" in openttok.js.
But how we can achieve through JMeter to Test Video Publishing?
I tried with following way,
Test Plan
Thread Group
Http Request
call cdn: https://static.opentok.com/v2/js/opentok.js
Post Request:
JSR223 PostProcessor: use variable in CDN JS
//OT varible is available in OpenTok JS.
var session = OT.initSession(apiKey, sessionID);
These are the Screens:
Http Request for OpenTok.js
Post Processor:
But it throws an error
Caused by: jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "OT" is not defined
I think, OpenTok not loading or not available to Post Processor Script.
How can I load OpenTok and use a variable within this Js?
You won't be able to do it this way as JMeter is not a browser and cannot execute JavaScript.
I would recommend the following approach
Download Opentok Server jar
Obtain all the dependencies, for OpenTok Server 3.0.0 they would be
async-http-client-1.9.40.jar
commons-beanutils-1.9.2.jar
commons-digester-1.8.1.jar
commons-lang-2.6.jar
commons-logging-1.2.jar
commons-validator-1.6.jar
jackson-annotations-2.9.0.pr4.jar
jackson-core-2.9.0.pr4.jar
jackson-databind-2.9.0.pr4.jar
jose4j-0.5.1.jar
netty-3.10.6.Final.jar
Put all the .jars under JMeter Classpath
Restart JMeter to pick the jars pu
Add JSR223 Sampler to your Test Plan
Use the following code to create a session:
import com.opentok.OpenTok
def apiKey = 123456789
def apiSecret = 'your_api_secret'
OpenTok opentok = new OpenTok(apiKey,apiSecret)
def session = opentok.createSession()
References:
OpenTok Java SDK Usage
OpenTok Documentation
Apache Groovy - Why and How You Should Use It

Oracle MAF-MCS Connection

I have created one Custom API in Oracle MCS for login authentication and I have an Application built in MAF. My doubt is how to call this Custom API from Oracle MAF application?
If you are using OEPE (Oracle Enterprise Pack for Eclipse), you can use this tutorial for consuming any REST service API,
Building MAF Applications using OEPE and REST Services
For MCS-MAF support, the following YouTube should help,
MAF: (OEPE) Using a RAML document to help consume REST services
You can get the latest version of OEPE from here.
Check out the MAF MCS Utility app (should be in your public examples folder) especially the source code.
More info can also be found in this link.
Short code example:
MBEConfiguration mbeConfiguration =
new MBEConfiguration(
<mbe rest connection>,<mobileBackendId>,
<anonymous key string>,<application key string>,
MBEConfiguration.AuthenticationType.BASIC_AUTH);
mbeConfiguration.setEnableAnalytics(true);
mbeConfiguration.setLoggingEnabled(false)
mbeConfiguration.setMobileDeviceId(
DeviceManagerFactory.getDeviceManager().getName());
MBE mobileBackend = MBEManager.getManager().
createOrRenewMobileBackend(<mobile backend Id>, mbeConfiguration);
CustomAPI customApiProxy = mbe.getServiceProxyCustomApi();
UserInfo userInfo = mobileBackend.getServiceProxyUserInfo();
Analytics analyticsProxy = mobileBackend.getServiceProxyAnalytics();
Storage storageProxy = mobileBackend.getServiceProxyStorage();

Anyone using Serilog.Extras.MSOwin

I was wondering if anyone has seen a demo/example of using the Serilog.Extras.MSOwin package with a web api project or a example/tutorial of using Serilog with a web api project.
Any help greatly appreciated,
Jim
I will take this as question as "How do I used Serilog.Extras.MSOwin?" and given it is currently a rather small library answer here.
This reflects the current library (1.4.102) and is subject to change in the future.
Serilog.Extras.MSOwin provides two things: a Microsoft.Owin.Logging.ILoggerFactory implementation to have OWIN's logging infrastructure write to Serilog (more details about logging in OWIN in this blog post) and Guid identifier (RequestId) for each web request to aid in associating logged events.
The Logging integration is done with the following:
IAppBuilder app = ...;
Serilog.ILogger logger = ...'
app.SetLoggerFactory( new Serilog.Extras.MSOwin.LoggerFactory( logger ) );
The request id functionality needs to be registered in the OWIN pipeline:
IAppBuilder app = ...;
app.UseSerilogRequestContext("RequestId");
You will want to register that very early in the pipeline because any logging occurring before that pipeline step will not have the request id available.
You also need will need to retrieve it from the LogContext using Enrich.FromLogContext() and add that property to what you write to your sinks. For example,
const string DefaultOutputTemplate =
"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} ({RequestId}) {Message}{NewLine}{Exception}";
ILogger logger =
new LoggerConfiguration().Enrich.FromLogContext()
.WriteTo
.RollingFile(
"log.txt",
outputTemplate: DefaultOutputTemplate)
.CreateLogger();
Serilog.Extras.MSOwin was superseded by SerilogWeb.Owin (which has since also been discontinued.)

Accessing entire netflix catalog via API v1.5

Netflix recently updated their API methods for obtaining the full Netflix catalog. I'm curious if anyone has had any success accessing these new xml documents and downloading them via API v1.5 (9/2012). Previously, you could download the entire Netflix catalog via one API call (which I had working perfectly). Now, there are supposedly two calls to make: one for dvd's and one for streaming movies.
I cannot make these calls return anything except for an empty array. Please don't offer an answer unless you have personally downloaded the entire catalog via these new API's.
Bonus points if you can tell me how to do it in Ruby.
http://developer.netflix.com/blog/read/Update_Changes_for_the_Public_API
This did it for me (download the netflix instant cat)...it's in php but can prob be easily rewritten in ruby..this is using JR Collings OAuthsimple
args = Array(
max_results=> 20,
start_index=>0
);
//args don't matter, netflix doesn't listen here
// this is the URL path (note the lack of arguments.)
$rpath = "http://api-public.netflix.com/catalog/titles/streaming";
// Create the Signature object.
$roauth = new OAuthSimple();
$rsigned = $roauth->sign(Array(path=>$rpath,
parameters=>$args,
signatures=> Array('consumer_key'=>YOURKEY,
'shared_secret'=>YOURSECRET,
)));
$getxml = file_get_contents($rsigned['signed_url']);
file_put_contents("streaming.xml", $getxml);

Resources