API/Python/Open-Source Solutions

Expand all | Collapse all

Rewind using APIs

Jump to Best Answer
  • 1.  Rewind using APIs

    Posted 04-18-2016 02:16:00 PM
    Hi,



    Can you give an example for rewind using API Note: This conversation was created from a reply on: Tip of the Day: Rewinding to a Timeflow Bookmark Using the CLI.


  • 2.  RE: Rewind using APIs
    Best Answer

    Posted 04-18-2016 07:40:00 PM
    To rewind a VDB, you need a reference to the Database object. See the topic, API Cookbook: List dSources and VDBs (https://docs.delphix.com/display/DOCS50/API+Cookbook%3A+List+dSources+and+VDBs), for information on how to obtain the database reference.

    Rewind of a VDB is done in 3 steps
    1) Create session
    2) Authenticate/Login to delphix engine
    3) Rewind VDB. This operation is named as rollback in delphix Rest API

    The following sample script includes a working example for creating a session, authenticating to the Delphix Engine, and rewinding the VDB. Please update the script variables to match your environment before using it.

    #!/bin/bash
    #
    # sample script to start or stop a VDB.
    #
    # set this to the FQDN or IP address of the Delphix Engine
    DE="192.168.2.131"
    # set this to the Delphix admin user name
    DELPHIX_ADMIN="delphix_admin"
    # set this to the password for the Delphix admin user
    DELPHIX_PASS="delphix"
    # set this to the object reference for the VDB
    VDB="ORACLE_DB_CONTAINER-57"
    #
    # create our session
    curl -s -X POST -k --data @- http://${DE}/resources/json/delphix/session \
        -c ~/cookies.txt -H "Content-Type: application/json" <<EOF
    {
        "type": "APISession",
        "version": {
            "type": "APIVersion",
            "major": 1,
            "minor": 4,
            "micro": 1
        }
    }
    EOF
    echo
    #
    # authenticate to the DE
    curl -s -X POST -k --data @- http://${DE}/resources/json/delphix/login \
        -b ~/cookies.txt -H "Content-Type: application/json" <<EOF
    {
        "type": "LoginRequest",
        "username": "${DELPHIX_ADMIN}",
        "password": "${DELPHIX_PASS}"
    }
    EOF
    echo
    #
    # rewind VDB
    curl -s -X POST -k --data @- http://${DE}/resources/json/delphix/database/${VDB}/rollback \
        -b ~/cookies.txt -H "Content-Type: application/json" <<EOF
    {
        "type": "OracleRollbackParameters",
        "timeflowPointParameters": {
        "type" : "TimeflowPointSnapshot",
        "snapshot" : "ORACLE_SNAPSHOT-172"
        }
    }
    EOF
    echo

    Note: While rewinding VDB, you can use different parameter types. In the above example "timeflowPointParameters" type is used as "TimeflowPointSnapshot" and a appropriate snapshot name is provided. Instead of "TimeflowPointSnapshot" , you can also choose from "TimeflowPointLocation" OR "TimeflowPointTimestamp" OR "TimeflowPointBookmark" etc. and pass the relevant parameters.


  • 3.  RE: Rewind using APIs

    Posted 04-19-2016 12:57:00 PM
    Hello,

    If you want to specify time using a TimeflowPointTimestamp type, keep in mind that timestamp in API calls has to be provided in GMT timezone like '2016-01-01T14:40:30.000Z"

    regards,
    Marcin