Dear All,
We are storing some values in customised table for cloud and app platform and we need to purge/delete those data post some specific period of time. We can manually delete/truncate the data but we need to schedule a scheduler which will auto purge the data on specific time. Appreciate quick help on it.
Thank you.
hi @javed.sayyad
app.log(args, "in truncateDateBase")
// const { database } = args
// console.log(database, "check DB name")
const BOT = app.bot
const apiKeyObject = {
"sandbox": "your api key",
"staging": "your api key",
"production": "your api key"
}
const API_KEY = apiKeyObject[app.BOT_ENV];
let headers = { "x-api-key": API_KEY };
let body = {
"ttl": 75,
"table": "test_table"
}
const options = {
method: 'post',
url: `https://app.yellow.ai/api/data/datastore/purge-records?bot=${BOT}`,
headers,
body,
'json': true
};
//console.log(config, "config in truncateDateBase")
app.request(options, (err, resp, body) => {
if (!err && resp.statusCode == 200) {
console.log(resp);
return resolve({ status: resp })
}
return resolve({ status: false, name: '' })
})
Hope it helps. Let me know what it is.
1 Like
Thanks for the quick revert @Subhrajit_Gupta . Let me try this.
This is the curl
curl --location --request POST 'https://app.yellow.ai/api/data/datastore/purge-records?bot=botid' \
--header 'authority: app.yellow.ai' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-api-key: apikey' \
--data-raw '{
"ttl": 0,
"table": "table_name"
}'
Place table_name, bot id,apikey for your bot.
Is it working?
1 Like
BOT is in cloud platform. I guess you have provided solution for app platform.
I have tried the same for app platform as well. but its seems not working. attaching postman screenshot FYR.
Share the curl please for app.
Have you used table_name, bot id,apikey for your own bot? Can you give me the app bot access?
Please make sure you have given x-api-key…
It works for app platform. Thanks. But we would need similar solution for cloud platform as well. appreciate your help for cloud platform as well. Thank you.
@Subhrajit_Gupta I have tested the same using https://cloud.yellow.ai/api/data/datastore/purge-records?bot=botid API URL as well for cloud platform. I have received the success response for cloud but data was still there in table. Please find the SS of success response of API using postman.
Hi @javed.sayyad
I spoke internally and i came to know that there is no open API in cloud for truncation of DB.
Please raise a JIRA ticket for feature request from product for cloud.
1 Like
@Subhrajit_Gupta Thanks for the help. We will raise JIRA ticket for the same.