Skip to main content
Delphix

Setting VDB Snapshot Policy when Provisioning via API (KBA4039)

 

 

KBA

KBA# 4039

Setting VDB Snapshot Policy

The provisioning API does not include a parameter to set the VDB snapshot policy.  To set the snapshot policy to the selected value, the GUI first calls the provision API and then immediately calls the policy API. This article provides the API calls required to apply a policy to a provisioned VDB.

Provision API

=== POST http://[delphix_platform]/resources/json/delphix/provision ===

API JSON POST Parameters:

{......}

Policy Apply API  

=== POST http://[delphix_platform]/resources/json/delphix/policy/POLICY_SNAPSHOT-2/apply ===

API JSON POST Parameters:

{"target":"ORACLE_DB_CONTAINER-46","type":"PolicyApplyTargetParameters"}

Where the "POLICY_SNAPSHOT-2" reference is the "None: SnapshotPolicy" and the

"ORACLE_DB_CONTAINER-46" is the VDB database reference.  

API Used for Database List 


=== GET /resources/json/delphix/database ===
=== RESPONSE ===
{
 "type": "ListResult",
 "status": "OK",
 "result": [
   {
     "type": "OracleDatabaseContainer",
     "reference": "ORACLE_DB_CONTAINER-46",
     "namespace": null,
     "name": "vorcl",
     "group": "GROUP-6",
     "provisionContainer": "ORACLE_DB_CONTAINER-2",
     "creationTime": "2019-04-05T07:08:16.223Z",
     "currentTimeflow": "ORACLE_TIMEFLOW-2",
     "previousTimeflow": null,
     "description": "",
     "runtime": {
       "type": "OracleDBContainerRuntime",
       "logSyncActive": true,
       "preProvisioningStatus": null,
       "crossPlatformEligible": false,
       "crossPlatformScriptUploaded": false,
       "liveSourceEligible": true
     },
... ... ... Etc ... ... ...

To get a specific vdb or dsource 

=== GET /resources/json/delphix/database/APPDATA_CONTAINER-8 ===
=== RESPONSE ===
{
 "type": "OKResult",
 "status": "OK",
 "result": {
   "type": "AppDataContainer",
   "reference": "APPDATA_CONTAINER-8",
   "namespace": null,
   "name": "C:\\Python27",
   "group": "GROUP-1",
   "provisionContainer": null,
   "creationTime": "2019-05-10T05:12:14.890Z",
   "currentTimeflow": "APPDATA_WINDOWS_TIMEFLOW-10",
   "previousTimeflow": null,
   "description": "",
   "runtime": {
     "type": "AppDataContainerRuntime",
     "logSyncActive": false,
     "preProvisioningStatus": null
   },
   "transformation": false,
   "masked": false,
   "os": "Windows",
   "processor": "x86",
   "sourcingPolicy": {
     "type": "SourcingPolicy",
     "logsyncEnabled": false
   },
   "performanceMode": "DISABLED",
   "toolkit": "APPDATA_TOOLKIT-1",
   "guid": "6c23096d-f2de-4fa4-a9ca-932b20d89076"
 },
 "job": null,
 "action": null
}

API Used for Policy List


=== GET /resources/json/delphix/policy ===
=== RESPONSE ===
{
   "type": "ListResult",
   "status": "OK",
   "result": [
       {
           "type": "SyncPolicy",
           "reference": "POLICY_SYNC-1",
           "namespace": null,
           "name": "None:SyncPolicy",
           "customized": false,
           "effectiveType": "DIRECT_APPLIED",
           "scheduleList": [],
           "timezone": {
               "type": "TimeZone",
               "id": "US/Pacific",
               "offset": 420,
               "offsetString": "UTC -07:00"
           },
           "default": false
       },
       {
           "type": "SnapshotPolicy",
           "reference": "POLICY_SNAPSHOT-2",
           "namespace": null,
           "name": "None:SnapshotPolicy",
           "customized": false,
           "effectiveType": "DIRECT_APPLIED",
           "scheduleList": [],
           "timezone": {
               "type": "TimeZone",
               "id": "US/Pacific",
               "offset": 420,
               "offsetString": "UTC -07:00"
           },
           "default": false
       },
... ... ... Etc ... ... ... 

To get a specific policy


=== GET /resources/json/delphix/policy/POLICY_SYNC-1 ===
=== RESPONSE ===
{
 "type": "OKResult",
 "status": "OK",
 "result": {
   "type": "SyncPolicy",
   "reference": "POLICY_SYNC-1",
   "namespace": null,
   "name": "None:SyncPolicy",
   "customized": false,
   "effectiveType": "DIRECT_APPLIED",
   "scheduleList": [],
   "timezone": {
     "type": "TimeZone",
     "id": "US/Pacific",
     "offset": 420,
     "offsetString": "UTC -07:00"
   },
   "default": false
 },
 "job": null,
 "action": null
}

Applying a Policy to a Provisioned VDB

For API Developers, you will need to use the above API's in this sequence to apply a Policy to a provisioned VDB.

  1. Provision Database API 
  2. Get Database API database list to get the respective database "reference" object value, for Oracle it's in this format: ORACLE_DB_CONTAINER-#

[ Optional: Create a New Policy ]

  1. Get Policy API policy list to get the respective policy "reference" object value,  POLICY_SYNC-#
  2. Apply the Policy to the Database, vie the policy/[reference]/apply API call, using the database and policy reference from steps 2 and 3.

 

Policy API Call 

json='{"target":"ORACLE_DB_CONTAINER-81","type":"PolicyApplyTargetParameters"}'
echo " "
echo "Policy "
STATUS=`curl -sX POST -k --data @- ${BaseURL}/policy/POLICY_SNAPSHOT-2/apply -b "${COOKIE}" -H "${CONTENT_TYPE}" <<EOF
${json}
EOF

{"type":"OKResult","status":"OK","result":"","job":null,"action":"ACTION-2402"}`

Related Articles

The following articles may provide more information or related information to this article: