API/Python/Open-Source Solutions

Expand all | Collapse all

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

Jump to Best Answer
  • 1.  Jetstream Bookmark Create : Using the API to create a new bookmark

    Posted 01-25-2016 01:21:00 PM

    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? 



  • 2.  RE: Jetstream Bookmark Create : Using the API to create a new bookmark
    Best Answer

    Posted 01-25-2016 03:18:00 PM
    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


  • 3.  RE: Jetstream Bookmark Create : Using the API to create a new bookmark

    Posted 01-25-2016 03:57:00 PM

    Thanks for the quick reply. Could you share what BRANCHREF in the line

    "branch": "${BRANCHREF}",

    resolves out to be?  I believe it is this specific syntax which is plaguing me.  In my example, it nets out to be the following:

    "type": "JSBranch",

    "dataLayout": "MARKITEDM_UNITTEST_DX/default"



  • 4.  RE: Jetstream Bookmark Create : Using the API to create a new bookmark

    Posted 01-25-2016 04:03:00 PM
    That is because the CLI resolves the reference to the name. In the cli, do "setopt trace=true" and you will see the json it posts to complete the commands you execute via the CLI. There you will see your branch reference.

    But, you can get your branch reference in the /jetstream/branch space. Just "select <branch name" and then "ls" and you will see the branch reference there.


  • 5.  RE: Jetstream Bookmark Create : Using the API to create a new bookmark

    Posted 01-25-2016 04:43:00 PM
    Huzzah!  Success before lunchtime.  Thank you very much.