Hi All
I'm trying to write something to extract which SAS VIYA users have access to which SAS VIYA VISUAL ANALYTICS dashboards. Is this possible?
I've looked into the identities REST API which can list all users and their membership groups, and the reports REST API which lists some simple summary stats for each dashboard and any tables they may use, but i've had no luck determining which reports are shared with an individual user or membership group.
https://developer.sas.com/apis/rest/Visualization/
Any help is appreciated!
%let BASE_URI = %sysfunc(getoption(servicesbaseurl));
%let BASE_DIR = /SAS Content;
%macro report_get_all();
filename rrep temp;
proc http
oauth_bearer=sas_services
method="GET"
url="&BASE_URI./reports/reports?%nrstr(start=0&limit=200)"
out=rrep;
headers "Accept"="application/json";
run;
libname rrep json;
proc sql;
insert into work.report(id, name)
select id, name
from rrep.items
;
run;
libname rrep clear;
filename rrep clear;
%mend;
%macro report_get_tables(REPORT_ID);
filename rcontent temp;
proc http
oauth_bearer=sas_services
method="GET"
url="&BASE_URI./reports/reports/&REPORT_ID./content"
out=rcontent;
headers "Accept"="application/vnd.sas.report.content+json";
run;
libname rcontent json;
%if %sysfunc(exist(rcontent.datasources_casresource)) %then %do;
proc sql;
insert into work.report_table(id, server, library, table, locale)
select "&REPORT_ID."
, server
, library
, table
, locale
from rcontent.datasources_casresource
;
quit;
%end;
libname rcontent clear;
filename rcontent clear;
%mend;
%macro report_get_path(REPORT_ID);
filename rpath temp;
proc http
oauth_bearer=sas_services
method='GET'
url="&BASE_URI./folders/ancestors?childUri=/reports/reports/&REPORT_ID."
out=rpath;
headers 'Accept'='application/vnd.sas.content.folder.ancestor+json';
run;
libname rpath json;
proc sql noprint;
select name into :file_path separated by '/'
from rpath.ancestors
order by ordinal_ancestors desc
;
insert into work.report_path(id, directory)
values("&REPORT_ID.", "&file_path.")
;
quit;
libname rpath clear;
filename rpath clear;
%mend;
%macro report();
proc sql;
create table work.report(
id char(64),
name char(64),
constraint primary_key primary key(id)
);
create table work.report_path(
id char(64),
directory char(256),
constraint primary_key primary key(id)
);
create table work.report_table(
id char(64),
server char(32),
library char(32),
table char(64),
locale char(8),
constraint primary_key primary key(id, server, library, table)
);
quit;
%report_get_all();
data _null_;
set work.report;
call execute('%nrstr(%report_get_path(' || trim(id) || '))');
call execute('%nrstr(%report_get_tables(' || trim(id) || '))');
run;
%mend;
%report();
I would probably start with a call to the authorization microservice to see what rules exist against report object URIs, then call that object uri to get the name of the report, etc.
This filter says to only return rules against Object URIs that start with "/report/reports" and a description containing "shared", as sharing adds a description to saying who shared it.
/authorization/rules?filter=and(startsWith(objectUri,"/reports/reports/"),contains(description,"shared"))
I would probably start with a call to the authorization microservice to see what rules exist against report object URIs, then call that object uri to get the name of the report, etc.
This filter says to only return rules against Object URIs that start with "/report/reports" and a description containing "shared", as sharing adds a description to saying who shared it.
/authorization/rules?filter=and(startsWith(objectUri,"/reports/reports/"),contains(description,"shared"))
Thanks for the response, using the authorization microservice and your approached worked perfectly! There also looks to be a specific endpoint that just returns a list of shared items too.
/authorization/shares
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.
Find more tutorials on the SAS Users YouTube channel.