Delphix Products

 View Only
  • 1.  Data Virtualization - dSource API Integration

    Posted 11-09-2022 03:36:00 AM
    Edited by ArunKumar Shanmugam 11-09-2022 03:36:23 AM
    Hello!

    Below is our delphix platform properties and we were leveraging python delphixpy package to create an API Integration wrapper that communicate with underline delphix APIs. While calling dSource API (code as below), we end up with TypeError: Object of type module is not JSON serializable. Kindly please advise
    <dx-labeled-value _nghost-jye-c307="" ng-reflect-condensed="true" ng-reflect-label="Product" ng-reflect-value="Continuous Data" class="ng-star-inserted">
    Continuous Data
    Continuous Data 6.0.13.0
    Mar 10, 2022 6:49:33 AM 
    Code:
    _engine = dx_EngineLogin(_cookie['engine'], _cookie['user'], _cookie['password'], _cookie['domain'])
    link_params = LinkParameters()
    link_params.name = 'dScrc_API'
    link_params.group = find_item_by_name(_engine, group, 'API Group').reference
    link_params.link_data = MSSqlLinkData()
    link_params.link_data.sync_parameters=MSSqlSyncParameters()
    link_params.link_data.sync_parameters.type=MSSqlNewCopyOnlyFullBackupSyncParameters
    link_params.link_data.config = find_item_by_name(_engine, sourceconfig, 'DB_API').reference
    link_params.link_data.ppt_repository = find_dbrepo_envInstanceName(_engine,"MSSqlInstance",find_item_by_name(_engine, environment, <ENVNAME>).reference,'MSSQLSERVER').reference
    link_params.link_data.sourcing_policy = SourcingPolicy()
    link_params.link_data.db_user =<DBUSER>
    link_params.link_data.db_credentials = {"type": "PasswordCredential",""password":<DBPWD>}
    database.link(_engine, link_params)
    </dx-labeled-value>

    ------------------------------
    Arun


  • 2.  RE: Data Virtualization - dSource API Integration

    Posted 11-09-2022 03:45:00 AM
    Hi Arun

    The error TypeError: Object of type module is not JSON serializable is a python error message, indicating that the built in json module cannot interpret a json object, see - https://linuxpip.org/object-of-type-is-not-json-serializable/

    Looking at the sample you have provided, I think you have some invalid json in this line

    link_params.link_data.db_credentials = {"type": "PasswordCredential",""password":<DBPWD>}

    this should be 

    link_params.link_data.db_credentials = {"type": "PasswordCredential","password":<DBPWD>}

    Please let me know if that helps

    Regards

    ------------------------------
    Andrew McLennan
    Senior Technical Support Engineer
    Delphix
    ------------------------------



  • 3.  RE: Data Virtualization - dSource API Integration

    Posted 11-09-2022 03:57:00 AM
    Edited by ArunKumar Shanmugam 11-09-2022 03:58:02 AM
    Hi Andrew- Thank you quick response. Still the same error post correcting. Please find below full error message.


    ------------------------------
    ArunKumar Shanmugam
    TDM Specialist
    Cognizant Technology Solutions
    ------------------------------



  • 4.  RE: Data Virtualization - dSource API Integration
    Best Answer

    Posted 11-09-2022 04:11:00 AM

    I believe that


    link_params.link_data.sync_parameters=MSSqlSyncParameters()
    link_params.link_data.sync_parameters.type=MSSqlNewCopyOnlyFullBackupSyncParameters


    is incorrect, as the "type" property should be a String, and anyways the expectation is to use python objects to represent types, something like

    link_params.link_data.sync_parameters=MSSqlNewCopyOnlyFullBackupSyncParameters()

    Eyal



    ------------------------------
    Eyal Kaspi
    Principal Engineer
    Delphix
    ------------------------------



  • 5.  RE: Data Virtualization - dSource API Integration

    Posted 11-09-2022 05:31:00 AM
      |   view attached
    Below is my modified python code, kindly please advise if I am missing anything or something wrong the same. Attaching the error message for your reference

    link_params = LinkParameters()
    link_params.name = 'dSRC_API'
    link_params.group = find_item_by_name(_engine, group, 'API Group').reference

    link_params.link_data = MSSqlLinkData()
    link_params.link_data.sourcing_policy = SourcingPolicy()
    link_params.link_data.sourcing_policy.load_from_backup = False
    link_params.link_data.sourcing_policy.logsync_enabled = True

    link_params.link_data.config = find_item_by_name(_engine, sourceconfig, 'dSRC_API').reference
    link_params.link_data.shared_backup_location = 'auto'

    # link_params.link_data.sync_parameters=MSSqlSyncParameters()
    link_params.link_data.sync_parameters=MSSqlNewCopyOnlyFullBackupSyncParameters()
    link_params.link_data.sync_parameters.compression_enabled=False

    link_params.link_data.ppt_repository = find_dbrepo_envInstanceName(_engine,"MSSqlInstance",find_item_by_name(_engine, environment, '<ENVNAME>').reference,'MSSQLSERVER').reference

    link_params.link_data.db_user = '<DBUSER>'
    link_params.link_data.db_credentials = {"type": "PasswordCredential","password":'<DBPWD>'}
    link_params.link_data.validated_sync_mode = 'TRANSACTION_LOG'







    ------------------------------
    ArunKumar Shanmugam
    TDM Specialist
    Cognizant Technology Solutions
    ------------------------------



  • 6.  RE: Data Virtualization - dSource API Integration

    Posted 11-09-2022 08:31:00 AM

    You might need

    link_params.link_data.db_credentials = PasswordCredential()

    link_params.link_data.db_credentials.password = <DBPWD>


    You can find many examples where https://github.com/delphix/delphixpy-examples



    ------------------------------
    Eyal Kaspi
    Principal Engineer
    Delphix
    ------------------------------



  • 7.  RE: Data Virtualization - dSource API Integration

    Posted 11-11-2022 03:04:00 AM
    I followed the same code repo from Gitlab for my reference and build the below code. I believe example were created 2 years ago which was refering to old delphix engine and api version and I also understand from the documentation that were huge change happened in the structure in the latest version. Can you review below my code and suggest if I am missing anything , also please let me know if its possible to recreate my code in your platfirm to know if its challenge with instance.
    link_params = LinkParameters()
    link_params.name = 'dSRC_API'
    link_params.group = find_item_by_name(_engine, group, 'API Group').reference

    link_params.link_data = MSSqlLinkData()
    link_params.link_data.sourcing_policy = SourcingPolicy()
    link_params.link_data.sourcing_policy.load_from_backup = False
    link_params.link_data.sourcing_policy.logsync_enabled = True

    link_params.link_data.config = find_item_by_name(_engine, sourceconfig, 'dSRC_API').reference
    link_params.link_data.shared_backup_location = 'auto'

    # link_params.link_data.sync_parameters=MSSqlSyncParameters()
    link_params.link_data.sync_parameters=MSSqlNewCopyOnlyFullBackupSyncParameters()
    link_params.link_data.sync_parameters.compression_enabled=False

    link_params.link_data.ppt_repository = find_dbrepo_envInstanceName(_engine,"MSSqlInstance",find_item_by_name(_engine, environment, '<ENVNAME>').reference,'MSSQLSERVER').reference

    link_params.link_data.db_user = '<DBUSER>'
    link_params.link_data.db_credentials = {"type": "PasswordCredential","password":'<DBPWD>'}
    link_params.link_data.validated_sync_mode = 'TRANSACTION_LOG'

    ------------------------------
    ArunKumar Shanmugam
    TDM Specialist
    Cognizant Technology Solutions
    ------------------------------