diff --git a/flowservice.js b/flowservice.js index c6ddfbc..42ccf33 100644 --- a/flowservice.js +++ b/flowservice.js @@ -58,7 +58,7 @@ function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyPrint,proje timeout = inTimeout; prettyprint = inPrettyPrint; - url = "https://" + domainName + "/enterprise/v1/rest/projects/" + projectId ; + url = "https://" + domainName + "/apis/v1/rest/projects/" + projectId ; debug("Username [" + username + "]"); debug("URL [" + url + "]"); debug("Timeout [" + timeout + "]"); diff --git a/projects.js b/projects.js index 05a309e..31c1145 100644 --- a/projects.js +++ b/projects.js @@ -157,6 +157,26 @@ $ node wmiocli.js -u user -p password project-triggers-delete project-uid trigger-uid + +\x1b[32mList Reference Data List:\x1b[0m +$ node wmiocli.js + -d tenant.int-aws-us.webmethods.io + -u user + -p password + referencedata project_name + e.g. + project-ref-data project-uid + +\x1b[32mList Reference Data List:\x1b[0m +$ node wmiocli.js + -d tenant.int-aws-us.webmethods.io + -u user + -p password + referencedata project_name ref-data-name + + e.g. + project-ref-data project-uid ref-data-name json + project-ref-data project-uid ref-data-name csv `; } function init(inDomainName, inUsername, inPassword, inTimeout, inPrettyprint) { @@ -190,6 +210,32 @@ function processResponse(data, status) { } } +/* reference data */ +function listRefData(projectId){ + debug("List Reference Data - Project [" + projectId + "]"); + url += "/" + projectId + "/referencedata"; + request.get(url, username, password, timeout, processResponse); +} + +function getRefData(projectId,refDataName,format){ + debug("Getting Reference Data - Project [" + projectId + "] name [" + refDataName + "] format [" + format + "]"); + url += "/" + projectId + "/referencedata + "/ + refDataName; + if(format && format.toLowerCase()=="csv")request.getPlain(url, username, password, timeout, processResponse); + else request.get(url, username, password, timeout, processResponse); +} + +function addRefData(projectId,name,description,filename,encoding,separator,qualifier){ + debug("Adding Reference Data to project [" + projectId + "]"); + var body={}; + body.name = name; + body.description = description; + //file + body.file_encoding = encoding; + body.field_separator = separator; + body.text_qualifier=qualifier; +} + + /* Projects */ function list(projectId) { @@ -349,5 +395,6 @@ module.exports = { listAssets, listAssetsDetailed, pub, deploy, createParam, updateParam, listParam, deleteParam, listWebhooks, regenWebhook, setWebhookAuth, - listTriggers, deleteTrigger + listTriggers, deleteTrigger, + listRefData, getRefData }; diff --git a/rest.js b/rest.js index 68796f3..0e31ee9 100644 --- a/rest.js +++ b/rest.js @@ -61,7 +61,17 @@ function requestModifiers(options){ setignoreTLS(options); } + +function getPlain(restEndPoint,user,pass,timeout,callback) +{ + get(restEndPoint,user,pass,timeout,callback,"text/plain") +} + function get(restEndPoint,user,pass,timeout,callback) +{ + get(restEndPoint,user,pass,timeout,callback,"application/json") +} +function get(restEndPoint,user,pass,timeout,callback,accept) { debug("GET:" + restEndPoint); var options = { @@ -71,7 +81,7 @@ function get(restEndPoint,user,pass,timeout,callback) timeout: timeout*1000, headers: { 'Content-Type': 'application/json', - 'Accept': 'application/json' + 'Accept': accept }, auth: { username: user, @@ -425,4 +435,4 @@ function custom(restEndPoint,user,pass,timeout,jsonBody,formBody,type,callback,c }); } -module.exports = { get, post, put, del, postDownloadFile, postUploadFile, downloadFile, httpDelete, custom, addCookieToJar, displayCookies }; +module.exports = { get, getPlain, post, put, del, postDownloadFile, postUploadFile, downloadFile, httpDelete, custom, addCookieToJar, displayCookies }; diff --git a/webmethods-io-integration-apicli.code-workspace b/webmethods-io-integration-apicli.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/webmethods-io-integration-apicli.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file