Delphix Products

Expand all | Collapse all

SelfService - API call

Jump to Best Answer
  • 1.  SelfService - API call

    Posted 16 days ago
    ​Hi team,

    Am trying to get a container reference for a VDB from delphix engine using an API.

    Please find the below

    function get_cntr_ref
    {
    echo "retrieveing branch $ContainerRef to find for the container sepcified..."
    result=$(curl -s -X GET -k http://${engine}/resources/json/delphix/selfservice/container/${container} \
    -b ~/cookies.txt -H "Content-Type: application/json")

    echo "URL parsed ok"

    check_result

    # Get everything in the result that comes after dataLayout.
    temp=${result#*\"reference\":\"}
    # Get rid of everything after creat
    ContainerRef=${temp%%\"*}

    echo "temp" $temp

    echo "ContainerRef" $ContainerRef
    }

    # Get the one positional arguments
    container=$1

    when run it says invalid reference ${container}, but when selected in the ssh session it is working.

    Please advice with an example what would be the container input to be given

    ------------------------------
    Anusha Gadiraju
    Support Executive
    HSBC UK
    ------------------------------


  • 2.  RE: SelfService - API call
    Best Answer

    Posted 15 days ago
    Hello Anusha,

    Good afternoon.

    An example of a container reference would be --> JS_DATA_CONTAINER-1:

    === GET /resources/json/delphix/selfservice/container/JS_DATA_CONTAINER-1 ===
    === RESPONSE ===
    {
    "type": "OKResult",
    "status": "OK",
    "result": {
    "type": "JSDataContainer",
    "reference": "JS_DATA_CONTAINER-1",
    "namespace": null,
    "name": "container1",
    "notes": null,
    "properties": {},
    "activeBranch": "JS_BRANCH-2",
    "lastUpdated": "2020-06-26T16:58:34.764Z",
    "firstOperation": "JS_OPERATION-2",
    "lastOperation": "JS_OPERATION-3",
    "template": "JS_DATA_TEMPLATE-1",
    "state": "ONLINE",
    "operationCount": 1,
    "owner": null,
    "lockUserReference": null,
    "lockUserName": null
    },
    "job": null,
    "action": null
    }
    === END ===



    Since I believe you are trying to find that value with this BASH code, it would be better to first  list all available Self service containers and based on the Container name, get the reference value.

    This a sample output:

    === GET /resources/json/delphix/selfservice/container ===
    === RESPONSE ===
    {
    "type": "ListResult",
    "status": "OK",
    "result": [
    {
    "type": "JSDataContainer",
    "reference": "JS_DATA_CONTAINER-1",      ---> Container reference
    "namespace": null,
    "name": "container1",                                      ---> Container name
    "notes": null,
    "properties": {},
    "activeBranch": "JS_BRANCH-2",
    "lastUpdated": "2020-06-26T16:58:34.764Z",
    "firstOperation": "JS_OPERATION-2",
    "lastOperation": "JS_OPERATION-3",
    "template": "JS_DATA_TEMPLATE-1",
    "state": "ONLINE",
    "operationCount": 1,
    "owner": null,
    "lockUserReference": null,
    "lockUserName": null
    }
    ],
    "job": null,
    "action": null,
    "total": 1,
    "overflow": false
    }
    === END ===



    This is a quick sample bash script that you can use to find a Self Service container reference with  its name:


    ###############################
    # Var section #
    ###############################
    DE=$1
    USER=$2
    PASSWORD=$3
    SELFCONT=$4


    URL=http://${DE}

    export URL

    echo "Create API session"
    curl -s -X POST -k --data @- ${URL}/resources/json/delphix/session \
    -c ~/cookies.txt -H "Content-Type: application/json" <<EOF
    {
    "type": "APISession",
    "version": {
    "type": "APIVersion",
    "major": 1,
    "minor": 10,
    "micro": 5
    }
    }
    EOF
    echo


    echo "Authenticating to $DE..."
    echo
    # Authenticate to the DelphixEngine
    curl -s -X POST -k --data @- ${URL}/resources/json/delphix/login \
    -b ~/cookies.txt -c ~/cookies.txt -H "Content-Type: application/json" <<EOF1
    {
    "type": "LoginRequest",
    "username": "$USER",
    "password": "$PASSWORD"
    }
    EOF1
    echo

    echo "Retrieving Self Service containers info to find for the container $SELFCONT specified..."

    export container=`curl --silent -X GET -k ${URL}/resources/json/delphix/selfservice/container -b ~/cookies.txt -H "Content-Type: application/json"`
    IFS=',' read -a containerarray <<< "${container}"
    counter=0
    for i in "${containerarray[@]}"
    do
    export js_col=`echo $i|awk -F":" '{ print $1}'`
    export js_val=`echo $i|awk -F\":\" '{ print $2}'`
    if [ "$js_col" == "\"name\"" ] ||[ "$js_col" == "\"reference\"" ]; then
    export js_val_f2=`echo $js_val|sed 's/"//g'`
    reference_template[$counter]="$js_val_f2"
    counter=`expr $counter + 1`
    fi
    done

    c=0
    for i in "${reference_template[@]}"
    do
    if [ "$i" == "$SELFCONT" ]; then
    f=c-1
    SELFCONTREF=${reference_template[$f]}
    fi
    c=`expr $c + 1`
    done
    echo "Reference for $SELFCONT is:"
    echo $SELFCONTREF
    exit 0


    Sample execution is :
    [root@singlenode ~]# ./community.sh 172.16.126.235 admin *** container1
    Create API session
    {"type":"OKResult","status":"OK","result":{"type":"APISession","version":{"type":"APIVersion","major":1,"minor":10,"micro":5},"locale":null,"client":null},"job":null,"action":null}
    Authenticating to 172.16.126.235...
    {"type":"OKResult","status":"OK","result":"USER-2","job":null,"action":null}
    Retrieving Self Service containers info to find for the container container1 specified...
    Reference for container1 is:
    JS_DATA_CONTAINER-1

    Hope this helps!

    Thanks and regards.



    ------------------------------
    Carlos Cuellar
    Technical Consultant
    Delphix
    ------------------------------



  • 3.  RE: SelfService - API call

    Posted 12 days ago
    Thank you Carlos, Will give a try and get back in case of any concerns.

    ------------------------------
    Anusha Gadiraju
    Support Executive
    HSBC UK
    ------------------------------