Calling IBM Function through HTTP - ibm-cloud

I created a function in IBM cloud which displays some JSON data when invoked. I am trying to figure out how client can consume this information. I am unable to find any information on net. I would like to preferable access the function through HTTP request or if that is not possible do it through some python script. Does anyone have more information on how this can be achieved?

Depending on the nature of your action/function, there are different ways to call it. In any case, you can find the required information about URL (and API key), by clicking the action in the action panel, and select 'endpoints' from there.
If you created a 'plain' action (i.e. one that accepts JSON and returns JSON), you will have to use the API key shown on the panel mentioned above. You can find it -- and the URL to use, in the 'Rest API' section. At the bottom of this page, there is also a complete curl command, which you can just copy & paste (and where you only need to insert the API key).
In case you created a web action (see here for details: https://console.bluemix.net/docs/openwhisk/openwhisk_webactions.html#openwhisk_webactions) , you can call it anonymously. The URL for that is different than the one referred to above -- you can find it in the 'web actions' section of the 'Endpoints' tab.

Related

Confluence Cloud - How to update content status via the API

I'm struggling with how to find the content status of a page in Confluence.
My end goal is to be able to change/update via the API.
I've added the list of statuses already in the Manage space section. I have successfully pulled the content of a page as well as its properties, but I can’t seem to find where the content status is stored.
Here is the URI I'm using:
https://MyDomain.atlassian.net/wiki/rest/api/content/145468621376?expand=space,body.storage,view,version.status,container,extentions
That Status is not present in OOB Confluence, so I suppose it is some third-party app from Atlassian Marketplace and you need to check with their documentation how to interact with it.
Of course, you can directly use the REST API to get page content as a string (HTML) and change its content, e.g. using Python (Atlassian Python API’s documentation)
Page actions
def my_page = confluence.get_page_property(page_id, page_property_key)
def new_body = my_page.body.replace("<macro .....>", "<new status in HTML>")
confluence.update_or_create(parent_id, title, new_body, representation='storage')
Finally sorted it out with the help of Atlassian support. If their documentation was correct it would've been super easy to do this.
https://developer.atlassian.com/cloud/confluence/rest/api-group-content-states/#api-group-content-states
Heres the catch. when you GET the status you have to add on the parameter for status even though its optional. so your get string needs to look like this:
your-domain.atlassian.net/wiki/rest/api/content{id}/state?status=current
Same goes for setting the new state. You have to add on the status parameter to the uri.

Extract data from metadata list macro from Confluence's REST API

I'm trying to fetch the value of an item in a metadata list on a page in Confluence using the REST API. So far I have been able to extract fetch the body using a URL like this
https://acme.com/rest/api/content/105088446?expand=body.storage
(documentation here: https://developer.atlassian.com/confdev/confluence-server-rest-api/expansions-in-the-rest-api)
Or the full contents of the metadata list macro like this
https://acme.com/rest/api/content/105088446/history/10/macro/id/c65d00a3-49e2-40e5-a032-50b6c187d968
(documentation here: https://docs.atlassian.com/confluence/REST/latest/#content)
But neither of these are satisfactory. The first leaves a lot of parsing, the second requires I define the version of the page and even then returns the whole table that needs to be parsed.
I'm not sure if you are referring to the page properties (Page Properties Macro). If so you could try the masterdetails REST service.
rest/masterdetail/1.0/detailssummary/lines
You can use the REST API Browser to discover the parameters (note that this is part of the non-public API, so you need to check of the "Show only public APIs" checkbox to see it in the list).
There is a similar question on Atlassian Answers.

IFTTT recipe api - is there documentation to create recipe using API call

I have already created triggers and actions for IFTTT channel. Now I want to create a recipe using these triggers and actions, but I want to do it not through Maker, but using an API call. What would be the format of the API call (behind Maker UI) to create a recipe, I am seems to unable to see any documentation or examples?
Click the URL in your maker settings to see IFTTT's description, which reads as follows, and shows your individual API key which must be used in your code:
To trigger an Event Make a POST or GET web request to:
https://maker.ifttt.com/trigger/{event}/with/key/tIpcUAlqRkf8Mls9XepGN
With an optional JSON body of:
{ "value1" : "", "value2" : "", "value3" : "" }
The data is completely optional, and you can also
pass value1, value2, and value3 as query parameters or form variables.
This content will be passed on to the Action in your Recipe. You can
also try it with curl from a command line.
curl -X POST https://maker.ifttt.com/trigger/{event}/with/key/tIpcUAlqRkf8Mls9XepGN
Yes. There is a documentation for create / triggers and actions.
You need to create the API from your server like that:
http://api.test.com:8080/ifttt/v1/triggers/{{triggers}}
More information:
Login: https://developers.ifttt.com/channels/t4/triggers
Click triggers in left menu
Create trigger name
Then as the endpoint you need to give your api url.
There is no public API. With old-type call there is internal API you can see REST calls like create/api/state whilst building a recipe, yet it might be protected from use by third party and I did not check the traffic of new applet maker platform. Note, if you are a partner you can embed your recipes into your apps. Upper tier customers are allowed to request new features (such as API or templates).
I was looking for the same, but after wasting hours, NO LUCK. So, I have decided to create one. This might be too late, but here's one repo of IFTTT boilerplate (https://github.com/Dipen-Dedania/ifttt-boilerplate) using NodeJS and express to create your own recipe (custom triggers and actions)

Jira calls external REST Service

My Problem: I want to introduce a new field in JIRA with status information from external REST Service (response is json).
Plan: Every Jira issue has a input field with some reference string. Behind this field there should be a panel, what should display informations from the external REST call (parsing response JSON is required).
Can someone give me some good info pages, how to tell JIRA to call external REST Service?
If you don't want to build it see:
nFeed
HTTP Feed Custom Field
If you want to build it yourself then start by following this tutorial on Creating a custom field type which is to more or less store a basic String within the database. (This would be the reference string)
You then have two options, the first is within the JiraCustomField class override the getVelocityParameters which was taken from How to call a java method from velocity Atlassian Answers question.
Then create a method (fetchValueFromWebService(String val)) that you would call that would contain code to query the REST Service based off the fields value that would be passed in from the velocity template. (E.g. $instance.fetchValueFromWebService($value))
To perform the actual web service call you can use any library you want, just see the Managing Dependencies documentation so it gets included in the plugin. (For example using the Jira Jersey version see this)
Your other option would be to within the view-basictext.vm have it use javascript and perform an AJAX to the web service by calling a function in your own JS file and dump that into a span that you have defined: (See Including Javascript and CSS resources)
<span id="webServiceValue"></span>
<script type="text/javascript">
fetchValueFromWebService($value);
</script>
You would however need to ensure that the webservice has Cross-origin resource sharing (CORS) enabled if you go the AJAX route.

Why GWT URL doesn't change on an event or a service call?

I have two questions:
Q: 1
I'm currently developing a GWT app. The entry point for the app is: ImageViewer.java. I could well access it by http://127.0.0.1:8888/ImageViewer.html?gwt.codesvr=127.0.0.1:9997. I have a service called "Search" which has corresponding "Async" and "Impl"'s defined. Now, I call the service from client side, using RPC. I could call the service, obtain return value. Everything works fine.
However, I expect the application to show a behavioral change on URL. i.e. when a service is being accessed, I thought it would be reflected on the browser's URL something like: http://127.0.0.1:8888/search?gwt.codesvr=127.0.0.1:9997 as I've modified web.xml. However, this behavior is not realized. Any particular reason why this is not reflected??
Q:2
This one is a reverse of the previous ques. i.e. I have an application running. Let's say it has an entrypoint class(Imageviewer.java) and another composite class (searchClass.java) which would be loaded on the Imageviewer based on an event. This searchClass invokes the "search" service mentioned in the previous question.
I could load the "searchClass" in "Imageviewer", invoke the service, and the service also returns the value needed. Everything works fine... But,
I need something like this: by just typing this query string:
http://127.0.0.1:8888/search?value=John
I want the "searchClass" to be loaded on the "ImageViewer", call the service using the value(which is "john" in this case) and display the result. Is this possible at all?
what I've tried: I have tried to create a httpServletClass on the server and mapped it with the URL and could do the search. The search returns appropriate results. However, I want the results from the server to be displayed on the client. Remember, I'm directly using a servlet to read the URL and so there is no value being passed from client to server.
Thanks in advance.
A: 1. To change URL, the hash part, you need to set new history token in the History class. More about history management in this article.
A: 2. For the second part you could achieve it by changing the history token, for instance "http://127.0.0.1/search#value=John". The history service will trigger an event if the # part changes. You could also use the part with "?", as in your example, if you use Window.Location , but it will cause reload of the application, which would put the whole idea of using GWT in question.
RPC (AJAX) calls are done Via XHR and do not change the browser URL.
You can't (with the URL you presented). GWT apps normally run in one web page, i.e. the URL does not change (see how gmail changes browser url bar). What you can do is enable GWT history support. Then your url would be http://host/#search?value=queryu