Copying dataset pdp settings
Best Answer
-
I scripted it using PowerShell and the API... All you need to add is the access token and the dataset ids. there are comments in the code from past projects and it is not perfect but it worked for our purpose. We have thousands of PDP rules and the excel pugin bogs down. There is also a PDP utility but you have to create a dataset of PDP rules... This was easier.
function Get-Dataset($datasetId, $Authentication) {
#Write-Host $Authentication
$headers = @{
Accept = 'text/csv'
Authorization = $Authentication.access_token
}
#Write-Host "https://api.domo.com/v1/datasets/$datasetId/data?includeHeader=true&fileName=dump.csv" -Headers $headers
try {
$csv = Invoke-RestMethod -Method Get -Uri "https://api.domo.com/v1/datasets/$datasetId/data?includeHeader=true&fileName=dump.csv" -Headers $headers
$csv = $csv -replace '\\N', $null
$data = ConvertFrom-Csv $csv
#Write-Host "must have Successfully Read CSV File"
}
catch {
Write-Host "Failed to Read Dataset CSV File"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
Start-Sleep -Seconds 10
}
return $data
}function Get-Dataset-Object($datasetId, $Authentication) {
#Write-Host $Authentication
$NeedData = $true
While( $NeedData -eq $true -and $Cnct_Cntr -lt 100){
try {
$headers = @{
Accept = 'application/json'
Authorization = $Authentication.access_token
}
#Write-Host "https://api.domo.com/v1/datasets/$datasetId" -Headers $headers
$data = Invoke-RestMethod -Method Get -Uri "https://api.domo.com/v1/datasets/$datasetId" -Headers $headers
#Write-Host "must have Successfully Read CSV File"
$Cnct_Cntr++
$NeedData = $false
}
catch {
Write-Host "Failed to get dataset object"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
$Cnct_Cntr++
Write-Host $Cnct_Cntr
Start-Sleep -Seconds 10
}
}
return $data
}function Get-Dataset-PDP($datasetId, $Authentication) {
#Write-Host $Authentication
$NeedData = $true
While( $NeedData -eq $true -and $Cnct_Cntr -lt 100){
try {
$headers = @{
Accept = 'application/json'
Authorization = $Authentication.access_token
}
#Write-Host "https://api.domo.com/v1/datasets/$datasetId" -Headers $headers
$data = Invoke-RestMethod -Method Get -Uri "https://api.domo.com/v1/datasets/$datasetId/policies" -Headers $headers
#Write-Host "must have Successfully Read CSV File"
$Cnct_Cntr++
$NeedData = $false
}
catch {
Write-Host "Failed to get dataset object"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
$Cnct_Cntr++
Write-Host $Cnct_Cntr
Start-Sleep -Seconds 10
}
}
return $data
}function Get-Authorization($clientID, $clientSecret) {
$basicAuth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $clientID, $clientSecret)));
$authenticationHeader = @{
Authorization = ("Basic {0}" -f $basicAuth)
}
$NeedToken = $true
$Cnct_Cntr = 0#keep trying to get a token
While( $NeedToken -eq $true -and $Cnct_Cntr -lt 100){
try {
$data = Invoke-RestMethod -Method Post -Uri "https://api.domo.com/oauth/token?grant_type=client_credentials&scope=data%20user" -Headers $authenticationHeader
# $data = Invoke-RestMethod -Method Post -Uri "https://api.domo.com/oauth/token?grant_type=client_credentials&scope=full" -Headers $authenticationHeader
$data.access_token = "bearer $($data.access_token)"
# Write-Host "Got Token"
$Cnct_Cntr++
$NeedToken = $false
}
catch {
#$ErrorActionPreference = Stop #this does not recognize "Stop"
Write-Host "Failed to get Token"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
$Cnct_Cntr++
Write-Host $Cnct_Cntr
Start-Sleep -Seconds 10
}
}
return $data
}function Send-ToEmail([string]$email, [string]$body){
$message = new-object Net.Mail.MailMessage;
$message.From = "Domo@daltile.com";
$message.To.Add($email);
$message.Subject = "Error Running Vistex jobs Script";
$message.Body = $body;
$smtp = new-object Net.Mail.SmtpClient("smtpmail.mohawkind.com");
$smtp.send($message);
write-host "Mail Sent" ;
}
Write-Host "go get auth token"
$Authentication = Get-Authorization -clientID $apiKey -clientSecret $apiToken
Write-Host "have token"
#Write-Host $Authentication
#$MetData = Get-Dataset -datasetId $datasetmetadata -Authentication $Authentication$output = ''
$haserr = $true
$Have_PDP = $false
#get the list of WB jobs
while(!$Have_PDP){
try{
$Authentication = Get-Authorization -clientID $apiKey -clientSecret $apiToken
$DS_PDP = Get-Dataset-PDP -datasetId $PDPSourceDatasetID -Authentication $Authentication
$Have_PDP = $true
}
catch{
Write-Host "Failed to get dataset list of PDP rules"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
Start-Sleep -Seconds 10
}
}
# Cycle through the list of jobs ensuring they run successfully.
$PDPs = $DS_PDP.Where{$_."name" -like "z_rep_*" -or $_."name" -like "z_ssc_*" } #| Sort-Object -Property $_."Execution Order"| Sort-Object -Property $_."Execution Order"
foreach($PDP in $PDPs){
$haserr = $true
$output = ''
$msg = ''
$Count = 0
Try{
$hdrs = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$hdrs.Add("Content-Type", "application/json")
$hdrs.Add("Accept", 'application/json')
$hdrs.Add("Authorization", $Authentication.access_token)
$filter = $PDP.filters
$name = $PDP.name
$type = $PDP.type
$users = $PDP.users
$groups = $PDP.groups
$i = 0
$pdp_rule = '{ "name": "'+$name+'",'
$fString = '"filters": ['
foreach($f in $PDP.filters){
$fString += '{ "column": "'+$f.column+'", "values": [ "'+$f.values+'" ], "operator": "'+$f.operator+'" }'
$i++
if($i -lt $PDP.filters.count){$fString += ','}
}$pdp_rule += $fString +' ], "groups": [ "'+$groups+'" ] }'
# {
# "name": "z_ssc_4000",
# "filters": [ {
# "column": "business_area_number",
# "values": [ "4000" ],
# "operator": "EQUALS"
# } ],
# "groups": [ 612003576 ]
#}
$post = Invoke-WebRequest -Method POST -Uri "https://api.domo.com/v1/datasets/$DestinationDatasetId/policies" -UseBasicParsing -Body $pdp_rule -Headers $hdrs -ContentType 'application/json'Write-Host "updated $name in Proex dataset PDP "
}
catch {
Write-Host "Failed to add $email to Domo"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
}
}#end foreach job
$now = Get-Date -Format g
Write-Host "$now Done."1
Answers
-
There isn't a process currently place through the interface that lets you do this. I think there's a post on the Ideas Exchange for it, though. Ideally, I think, there would be a list of PDPs stored independent of datasets, and you could apply a group of policies to datasets at the click of a button.
That said, we're using a not-so-official software application that Domo skunkworks wrote that lets us apply policies across different datasets using a config file hosted in Domo via a webform dataset. It's saved us a ton of time and serves the same purpose. You should inquire with your success manager or rep about that.
Aaron
MajorDomo @ Merit Medical
**Say "Thanks" by clicking the heart in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"1 -
I was trying to search for this ap but couldn't. Is there anyway that I can access and use it to copy over PDP to differnt data set?
0 -
I'm sure this application isn't available to download. You'll have to ask Domo directly.
I'd also watch out in the coming months to see if something comes into the product. I wouldn't be surprised to see something at Domopalooza, for example.
Aaron
MajorDomo @ Merit Medical
**Say "Thanks" by clicking the heart in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
I'm revisiting this because I've continued to builed datasets that have the exact same PDP settings as previous datasets, and I still don't see a way to copy the settings from one dataset to another.
Does this exist or do I have to continue recreating the wheel on every dataset?
0 -
Have you tried the Excel plugin for DOMO, this allows you to apply PDP security to any dataset you want and is a fast and easy way to apply PDP policies that are exact copies to other datasets.
Just change the DatasetID and apply and your good.
This is also very easy to make slight modifications to PDP's that are close but not the same.
It is also an easy way to manage other components such as user accounts etc.
Randy
0 -
I will request the admin version of that.
Thanks.
0 -
You should be able to download it from the Admin/Tools Download section.
Randy
0 -
The admin one requires a special request, but I did get. It's not quite the elegant solution I was hoping for within DOMO, but it will work for when I have to add bulk permissions.
0 -
I scripted it using PowerShell and the API... All you need to add is the access token and the dataset ids. there are comments in the code from past projects and it is not perfect but it worked for our purpose. We have thousands of PDP rules and the excel pugin bogs down. There is also a PDP utility but you have to create a dataset of PDP rules... This was easier.
function Get-Dataset($datasetId, $Authentication) {
#Write-Host $Authentication
$headers = @{
Accept = 'text/csv'
Authorization = $Authentication.access_token
}
#Write-Host "https://api.domo.com/v1/datasets/$datasetId/data?includeHeader=true&fileName=dump.csv" -Headers $headers
try {
$csv = Invoke-RestMethod -Method Get -Uri "https://api.domo.com/v1/datasets/$datasetId/data?includeHeader=true&fileName=dump.csv" -Headers $headers
$csv = $csv -replace '\\N', $null
$data = ConvertFrom-Csv $csv
#Write-Host "must have Successfully Read CSV File"
}
catch {
Write-Host "Failed to Read Dataset CSV File"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
Start-Sleep -Seconds 10
}
return $data
}function Get-Dataset-Object($datasetId, $Authentication) {
#Write-Host $Authentication
$NeedData = $true
While( $NeedData -eq $true -and $Cnct_Cntr -lt 100){
try {
$headers = @{
Accept = 'application/json'
Authorization = $Authentication.access_token
}
#Write-Host "https://api.domo.com/v1/datasets/$datasetId" -Headers $headers
$data = Invoke-RestMethod -Method Get -Uri "https://api.domo.com/v1/datasets/$datasetId" -Headers $headers
#Write-Host "must have Successfully Read CSV File"
$Cnct_Cntr++
$NeedData = $false
}
catch {
Write-Host "Failed to get dataset object"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
$Cnct_Cntr++
Write-Host $Cnct_Cntr
Start-Sleep -Seconds 10
}
}
return $data
}function Get-Dataset-PDP($datasetId, $Authentication) {
#Write-Host $Authentication
$NeedData = $true
While( $NeedData -eq $true -and $Cnct_Cntr -lt 100){
try {
$headers = @{
Accept = 'application/json'
Authorization = $Authentication.access_token
}
#Write-Host "https://api.domo.com/v1/datasets/$datasetId" -Headers $headers
$data = Invoke-RestMethod -Method Get -Uri "https://api.domo.com/v1/datasets/$datasetId/policies" -Headers $headers
#Write-Host "must have Successfully Read CSV File"
$Cnct_Cntr++
$NeedData = $false
}
catch {
Write-Host "Failed to get dataset object"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
$Cnct_Cntr++
Write-Host $Cnct_Cntr
Start-Sleep -Seconds 10
}
}
return $data
}function Get-Authorization($clientID, $clientSecret) {
$basicAuth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $clientID, $clientSecret)));
$authenticationHeader = @{
Authorization = ("Basic {0}" -f $basicAuth)
}
$NeedToken = $true
$Cnct_Cntr = 0#keep trying to get a token
While( $NeedToken -eq $true -and $Cnct_Cntr -lt 100){
try {
$data = Invoke-RestMethod -Method Post -Uri "https://api.domo.com/oauth/token?grant_type=client_credentials&scope=data%20user" -Headers $authenticationHeader
# $data = Invoke-RestMethod -Method Post -Uri "https://api.domo.com/oauth/token?grant_type=client_credentials&scope=full" -Headers $authenticationHeader
$data.access_token = "bearer $($data.access_token)"
# Write-Host "Got Token"
$Cnct_Cntr++
$NeedToken = $false
}
catch {
#$ErrorActionPreference = Stop #this does not recognize "Stop"
Write-Host "Failed to get Token"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
$Cnct_Cntr++
Write-Host $Cnct_Cntr
Start-Sleep -Seconds 10
}
}
return $data
}function Send-ToEmail([string]$email, [string]$body){
$message = new-object Net.Mail.MailMessage;
$message.From = "Domo@daltile.com";
$message.To.Add($email);
$message.Subject = "Error Running Vistex jobs Script";
$message.Body = $body;
$smtp = new-object Net.Mail.SmtpClient("smtpmail.mohawkind.com");
$smtp.send($message);
write-host "Mail Sent" ;
}
Write-Host "go get auth token"
$Authentication = Get-Authorization -clientID $apiKey -clientSecret $apiToken
Write-Host "have token"
#Write-Host $Authentication
#$MetData = Get-Dataset -datasetId $datasetmetadata -Authentication $Authentication$output = ''
$haserr = $true
$Have_PDP = $false
#get the list of WB jobs
while(!$Have_PDP){
try{
$Authentication = Get-Authorization -clientID $apiKey -clientSecret $apiToken
$DS_PDP = Get-Dataset-PDP -datasetId $PDPSourceDatasetID -Authentication $Authentication
$Have_PDP = $true
}
catch{
Write-Host "Failed to get dataset list of PDP rules"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
Start-Sleep -Seconds 10
}
}
# Cycle through the list of jobs ensuring they run successfully.
$PDPs = $DS_PDP.Where{$_."name" -like "z_rep_*" -or $_."name" -like "z_ssc_*" } #| Sort-Object -Property $_."Execution Order"| Sort-Object -Property $_."Execution Order"
foreach($PDP in $PDPs){
$haserr = $true
$output = ''
$msg = ''
$Count = 0
Try{
$hdrs = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$hdrs.Add("Content-Type", "application/json")
$hdrs.Add("Accept", 'application/json')
$hdrs.Add("Authorization", $Authentication.access_token)
$filter = $PDP.filters
$name = $PDP.name
$type = $PDP.type
$users = $PDP.users
$groups = $PDP.groups
$i = 0
$pdp_rule = '{ "name": "'+$name+'",'
$fString = '"filters": ['
foreach($f in $PDP.filters){
$fString += '{ "column": "'+$f.column+'", "values": [ "'+$f.values+'" ], "operator": "'+$f.operator+'" }'
$i++
if($i -lt $PDP.filters.count){$fString += ','}
}$pdp_rule += $fString +' ], "groups": [ "'+$groups+'" ] }'
# {
# "name": "z_ssc_4000",
# "filters": [ {
# "column": "business_area_number",
# "values": [ "4000" ],
# "operator": "EQUALS"
# } ],
# "groups": [ 612003576 ]
#}
$post = Invoke-WebRequest -Method POST -Uri "https://api.domo.com/v1/datasets/$DestinationDatasetId/policies" -UseBasicParsing -Body $pdp_rule -Headers $hdrs -ContentType 'application/json'Write-Host "updated $name in Proex dataset PDP "
}
catch {
Write-Host "Failed to add $email to Domo"
Write-Host $_.ErrorDetails
Write-Host $_.Exception
Write-Host $_.FullyQualifiedErrorId
}
}#end foreach job
$now = Get-Date -Format g
Write-Host "$now Done."1 -
Hi @Randyb , can you provide some more information on how you accomplished this using the Excel plugin? I've got a massive PDP update project I need to undertake, and this sounds like a great option for us. Are you exporting a specific dataset into Excel then re-uploading with changes, or something else?
Thanks!
-Russell
0 -
@rhollander There are a couple of ways you can do this, you can download the excel plugin which then allows you to pull the data down along with the different PDP profiles. You can then build essentially a user list for a specific PDPPolicy and upload it.
Its been awhile since I've had to use it but it does make large scale PDP policy setups fairly easy.If you need to make changes that don't involve creating PDP policies you can also pull down the entire user list from DOMO in excel format and update access etc in the sheet and then re upload that in bulk. Another quick way to reassign access to entire pages etc.Randy0 -
https://knowledge.domo.com/Connect/Personalized_Data_Permissions_(PDP)/PDP_Policy_Autocreation
@rhollander , take a look at this utility, may help you automate the process
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 731 Beast Mode
- 55 App Studio
- 40 Variables
- 682 Automate
- 175 Apps
- 451 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 122 Manage
- 119 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 107 Community Announcements
- 4.8K Archive