Jetstream Bookmark Create : Using the API to create a new bookmark

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered

I am attempting to use the API to create a bookmark.  (I can do it via the CLI without an issue) I have tried many, many variations in an attempt to get the proper syntax for the API.  I've had good success with the API to refresh and restore, but am struggling with the bookmark createion.  Here's the latest. 

$create_body_1 = '

{

"type":"JSBookmarkCreateParameters",

"bookmark": {

      "type": "JSBookmark",

      "name":"DX_API_generated",

      "bookmarkType": "DATA_CONTAINER",

      "branch": {

           "type": "JSBranch",

           "dataLayout": "MARKITEDM_UNITTEST_DX/default"

                     }

               },


"timelinePointParameters": {

      "type": "JSTimelinePointLatestTimeInput",

      "sourceDataLayout":"JS_DATA_CONTAINER-26"

      }

}'


Invoke-WebRequest -Verbose -WebSession $myWebSession -Uri "$DX_uri/jetstream/bookmark" -Method Post -ContentType "application/json" -Body $create_body_1


Any suggestions? 

Photo of Joseph Elsbernd

Joseph Elsbernd

  • 112 Points 100 badge 2x thumb
  • cautiously optimistic

Posted 2 years ago

  • 0
  • 1
Photo of Adam Bowen

Adam Bowen, Official Rep

  • 17,418 Points 10k badge 2x thumb
Official Response
Hey Joe. Here is an excerpt from something I wrote that creates a bookmark on a container branch from a PIT on the template. You could easily modify it to create one from a PIT on a container. 

DEIP = "Delphix Engine IP"
BOOKMARKNAME = "Whatever you want the title to be"
TEMPLATENAME = "The name of the template you are creating the bookmark from"

function GET_ACTIVE_BRANCH_REF { TEMPLATE=$(curl -X GET -k "http://${DEIP}/resources/json/delphix/jetstream/template"; \
-b ~/cookies.txt -H "Content-Type: application/json" | jq -r ".result[]| select (.name ==\"${TEMPLATENAME}\")")
TEMPLATEREF=$(echo $TEMPLATE| jq -r '.reference')
BRANCHREF=$(echo $TEMPLATE| jq -r '.activeBranch')
echo "Template Ref, Branch Ref:"
echo "${TEMPLATEREF}, ${BRANCHREF}"
}

GET_ACTIVE_BRANCH_REF

curl -X POST -k --data @- "http://${DEIP}/resources/json/delphix/jetstream/bookmark"; \ -b ~/cookies.txt -H "Content-Type: application/json" <<-EOF
{
   "type": "JSBookmarkCreateParameters",
   "bookmark": {
       "type": "JSBookmark",
       "name": "${BOOKMARKNAME}",
       "branch": "${BRANCHREF}",
       "tags": ["SugarCRM", "Masked", "Validated"]
   },
   "timelinePointParameters": {
       "type": "JSTimelinePointLatestTimeInput",
       "sourceDataLayout": "${TEMPLATEREF}"
   }
}
EOF