IBM Cloud Databases - Structured Ideas

This Ideas portal is being closed.  Please enter new idea at

Simplify the boilerplate code generated by insert to code

Users tend to get confused by the boilerplate code. In most cases they don't need to see it, so it would be nice if we hid most of behind functions in a dsx 'utility' library.

For example, this code generated by insert to code ...

getObjectStorageFileWithCredentials_a98886102a7c4ee1b75850d9fc448f75 <- function(container, filename) {
# This functions returns a textConnection object for a file
# from Bluemix Object Storage.

if(!require(httr)) install.packages('httr')
if(!require(RCurl)) install.packages('RCurl')
library(httr, RCurl)
auth_url <- paste("",'/v3/auth/tokens', sep= '')
auth_args <- paste('{"auth": {"identity": {"password": {"user": {"domain": {"id": ', "xxxxx",'},"password": ',
"xxxxx",',"name": ', "xxxxx",'}},"methods": ["password"]}}}', sep='"')
auth_response <- httr::POST(url = auth_url, body = auth_args)
x_subject_token <- headers(auth_response)[['x-subject-token']]
auth_body <- content(auth_response)
access_url <- unlist(lapply(auth_body[['token']][['catalog']], function(catalog){
if((catalog[['type']] == 'object-store')){
lapply(catalog[['endpoints']], function(endpoints){
if(endpoints[['interface']] == 'public' && endpoints[['region_id']] == 'dallas') {
paste(endpoints[['url']], container, filename, sep='/')}
data <- content(httr::GET(url = access_url, add_headers ("Content-Type" = "application/json", "X-Auth-Token" = x_subject_token)), as="text")

... could be simplified a lot to something like:

dsx::getObjectStorageFile(username="username", password="secret", container="myfolder', file="myfile.txt", ... some_parameters_omitted)

  • chris snow
  • Dec 14 2018
  • In Plan
Why is it useful?
Who would benefit from this IDEA?
How should it work?
Idea Priority
Priority Justification
Customer Name
Submitting Organization
Submitter Tags
  • Dec 14, 2018

    Admin Response

    Hi Chris - thanks for submitting this request. Our notebook development team has been actively working on compressing/reducing the amount of code for the 'Insert to Code' function and actually taking it a set farther with a 'Project' library which will help with your idea.

    For more details, please reach out to me at or find me on slack! 

  • Attach files
  • Chris Snow commented
    December 14, 2018 17:59

    Hopefully this library will be open sourced?