by tomas.trnka@keboola.com -- 1) Create a metric returning one number 2) Log in to gooddata, that will make you authorized for your API calls in the same browser as well 3) Open a postman (chrome extension) to be able to send API calls 4) Create your notification channel (Email) by sending this API call configuration: type: POST url: https://secure.gooddata.com/gdc/account/profile/ 42aa65e482f6bf011758dd497c366650/channelConfigurations
WHERE red string is your user id in GD header: Content-Type: application/json body: { "channelConfiguration":{ "configuration":{ "emailConfiguration":{ "to":"tomas.trnka@keboola.com" } }, "meta":{ "title":"tt_channel" } } } GoodData returns: { "channelConfiguration": { "configuration": { "emailConfiguration": { "to": "tomas.trnka@keboola.com" } }, "meta": { "title": "tt_channel", "author": "/gdc/account/profile/42aa65e482f6bf011758dd497c366650", "category": "channelConfiguration", "updated": "2014-12-02 18:33:30", "created": "2014-12-02 18:33:30", "uri": "/gdc/account/profile/42aa65e482f6bf011758dd497c366650/channelConfigurations/547df7eae4b00789078f25ef" } } }
/* pink is the channel id /* 5) Create the Subscription by calling API again: type: POST url: https://secure.gooddata.com/gdc/projects/stlk37jfejj7p65haomte4n03j1a1cdb/users/42aa65e482f6bf011758dd497c366650/subscriptions
WHERE the blue is the GD project id and red is your user id header: Content-Type: application/json body: { "subscription":{ "triggers":[ { "timerEvent":{ "cronExpression":"0 8 * * * *" } } ], "condition":{ "condition":{ "expression":"f:executeMetric('/gdc/md/stlk37jfejj7p65haomte4n03j1a1cdb/obj/267426') > 0" } }, "message":{ "template":{ "expression":"abm Content is delayed ${f:executeMetric('/gdc/md/stlk37jfejj7p65haomte4n03j1a1cdb/obj/267426')} days" } }, "channels":[ "/gdc/account/profile/42aa65e482f6bf011758dd497c366650/channelConfigurations/547df7eae4b00789078f25ef" ], "meta":{ "title":"abm_Content is delayed" } } }
/* blue is your user id and pink is your channel id (cronExpresion - how often would you like to run the check, see details how to set it up below; executeMetric - paste your metric here and the condition at the end; expression - set up the email message and note you can use the result the metric is returning; channels - whats the url of your channel? - see step 4 and what GoodData returned; title - just title it) GoodData returns: { "subscription": { "triggers": [ { "timerEvent": { "cronExpression": "0 8 * * * *" } } ], "condition": { "condition": { "expression": "f:executeMetric('/gdc/md/stlk37jfejj7p65haomte4n03j1a1cdb/obj/267426') > 0" } }, "message": { "template": { "expression": "abm Content is delayed ${f:executeMetric('/gdc/md/stlk37jfejj7p65haomte4n03j1a1cdb/obj/267426')} days" } }, "channels": [ "/gdc/account/profile/42aa65e482f6bf011758dd497c366650/channelConfigurations/547df7eae4b00789078f25ef" ], "meta": { "title": "abm_Content is delayed", "author": "/gdc/account/profile/42aa65e482f6bf011758dd497c366650", "category": "subscription", "updated": "2014-12-02 18:41:53", "created": "2014-12-02 18:41:53", "uri": "/gdc/projects/stlk37jfejj7p65haomte4n03j1a1cdb/users/42aa65e482f6bf011758dd497c366650/subscriptions/547df9e1e4b00789078f25f4" } } } Thats it, you're all set! P.S. At any time, you can call just the url by the GET or DELETE type of call which would show you for example all your channel configurations, just send a blank API call: type: GET url: https://secure.gooddata.com/gdc/account/profile/42aa65e482f6bf011758dd497c366650/channelConfigurations header: Content-Type: application/json And to delete a subscription: type: DELETE url: https://secure.gooddata.com/gdc/projects/stlk37jfejj7p65haomte4n03j1a1cdb/users/42aa65e482f6bf011758dd497c366650/subscriptions/547dd806e4b0ae4bb39e33d1 header: Content-Type: application/json P.P.S. When GoodData returns "not authorized" try reloading the tab where you're logged in to GoodData in the same browser. More info at: https://developer.gooddata.com/article/setting-up-the-notifications-using-api http://docs.spring.io/spring/docs/3.0.x/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html |