Skip to content

Instantly share code, notes, and snippets.

View nuwanbando's full-sized avatar

Nuwan Bandara nuwanbando

View GitHub Profile
function readLog(string limit) (json){
sql:ClientConnector foodlog = create sql:ClientConnector(dbprops);
sql:Parameter[] params = [];
sql:Parameter para1 = {sqlType:"integer",value:limit};
params = [para1];
datatable dt = sql:ClientConnector.select(foodlog, "select * from log ORDER BY id DESC LIMIT ?", params);
var jsonRes,err = <json>dt;
import ballerina.net.http;
import ballerina.lang.messages;
import ballerina.lang.jsons;
import ballerina.lang.system;
@http:BasePath { value: "/"}
service transformService {
@http:Path { value: "/location"}
@http:POST {}
import ballerina.net.http;
service transformService {
@http:Path { value: "/location"}
@http:POST {}
resource createLocation (message m) {
Address a = {number: "123",street: "glenwood",state: "NJ",city: "bloomfield",zip: "07003"};
Location l;
import ballerina.net.http;
import ballerina.lang.system;
import ballerina.lang.messages;
function main (string[] args) {
system:println(getEmployees());
}
function getEmployees() {
http:ClientConnector empService = create http:ClientConnector("http://empdir-nuwanbando.herokuapp.com/employees/");
@nuwanbando
nuwanbando / api-sequence.xml
Last active February 9, 2017 22:26
api-sequence.xml
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="chain" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log>
<property name="INITIAL-LOG" value="###INITIAL-LOG####"/>
</log>
<call blocking="true">
<endpoint>
<http method="get" uri-template="http://localhost:9773/odata/ODataSampleService/default/CUSTOMERS?$filter=CUSTOMERNUMBER%20eq%20363"/>
</endpoint>
</call>
{
"Q1":{
"title": "api calls per day",
"description": "API calls per days at peak",
"type": "string", /* slider is better*/
"enum": [
{"val":"100K<", "weight":"L0"},
{"val":"100K-500K", "weight":"L0"},
{"val":"500K-1Mil", "weight":"L0"},
{"val":"1Mil-10Mil", "weight":"L1"},
nuwanbando@bandosMac~/repos/WSO2-AM-API-Import-Export-Tool/setup$ curl -X POST -H "Authorization: Basic XXXXX" -H "Content-Type: application/json" -d @payload.json https://api.cloud.wso2.com/client-registration/v0.10/register?tenant=wso2us
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<link rel="stylesheet" href="https://error.cloud.wso2.com/style/style.css">
<link rel="stylesheet" href="https://error.cloud.wso2.com/style/font-mf.css">
</head>
<?xml version="1.0" encoding="UTF-8"?>
<api context="/insurance" name="insurance-api" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" uri-template="/policy">
<inSequence>
<log description="" level="full">
<property name="FIRST_LOG" value="##INITIAL_LOG###"/>
</log>
<payloadFactory description="" media-type="json">
<format>{"customerId":$1,"limit":$2,"deductible":$3,"effectiveDate":$4,"premium":$5,"term":$6}</format>
<args>
[2016-10-20 16:44:23,771] DEBUG - wire HTTP-Listener I/O dispatcher-5 >> "POST /insurance/policy HTTP/1.1[\r][\n]"
[2016-10-20 16:44:23,772] DEBUG - wire HTTP-Listener I/O dispatcher-5 >> "Host: 192.168.1.7:8280[\r][\n]"
[2016-10-20 16:44:23,772] DEBUG - wire HTTP-Listener I/O dispatcher-5 >> "Connection: keep-alive[\r][\n]"
[2016-10-20 16:44:23,772] DEBUG - wire HTTP-Listener I/O dispatcher-5 >> "Content-Length: 160[\r][\n]"
[2016-10-20 16:44:23,772] DEBUG - wire HTTP-Listener I/O dispatcher-5 >> "Postman-Token: db4bd57b-730f-d7d5-5bab-001ce4a061e8[\r][\n]"
[2016-10-20 16:44:23,772] DEBUG - wire HTTP-Listener I/O dispatcher-5 >> "Cache-Control: no-cache[\r][\n]"
[2016-10-20 16:44:23,772] DEBUG - wire HTTP-Listener I/O dispatcher-5 >> "Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop[\r][\n]"
[2016-10-20 16:44:23,772] DEBUG - wire HTTP-Listener I/O dispatcher-5 >> "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36[\
POST /emp/v1/1 HTTP/1.1
Host: 192.168.1.3:8280
Authorization: Bearer e7c37026-e299-3cfd-8343-22536ad2b814
SOAPAction: urn:employeesByNumber
Content-Type: text/xml
Cache-Control: no-cache
Postman-Token: 4f12e1b7-a37a-69e3-e617-742afd3cc16e