43%macro mv_getfoldermembers(root=/
44 ,access_token_var=ACCESS_TOKEN
45 ,grant_type=sas_services
49%
if &grant_type=detect %then %
do;
50 %
if %symexist(&access_token_var) %then %let grant_type=authorization_code;
51 %
else %let grant_type=sas_services;
53%
if &grant_type=sas_services %then %
do;
54 %let oauth_bearer=oauth_bearer=sas_services;
55 %let &access_token_var=;
58%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
59 and &grant_type ne sas_services
62 ,msg=%str(Invalid value
for grant_type: &grant_type)
65%
if %mf_isblank(&root)=1 %then %let root=/;
71%let fname1=%mf_getuniquefileref();
72%let libref1=%mf_getuniquelibref();
75%let base_uri=%mf_getplatform(VIYARESTAPI);
77%
if "&root"=
"/" %then %
do;
79 proc http method=
'GET' out=&fname1 &oauth_bearer
80 url=
"&base_uri/folders/rootFolders?limit=1000";
81 %
if &grant_type=authorization_code %then %
do;
82 headers
"Authorization"=
"Bearer &&&access_token_var";
85 libname &libref1 JSON fileref=&fname1;
92 proc http method=
'GET' out=&fname1 &oauth_bearer
93 url=
"&base_uri/folders/folders/@item?path=&root";
94 %
if &grant_type=authorization_code %then %
do;
95 headers
"Authorization"=
"Bearer &&&access_token_var";
99 libname &libref1 JSON fileref=&fname1;
104 length rel href $512;
105 call missing(rel,href);
107 if rel=
'members' then
do;
108 url=cats(
"'",
"&base_uri",href,
"?limit=10000'");
109 call symputx(
'href',url,
'l');
110 call symputx(
'cnt',1,
'l');
113 %
if &cnt=0 %then %
do;
114 %put NOTE:;%put NOTE- No members found in &root!!;%put NOTE-;
117 %local fname2 libref2;
118 %let fname2=%mf_getuniquefileref();
119 %let libref2=%mf_getuniquelibref();
120 proc http method=
'GET' out=&fname2 &oauth_bearer
121 url=%unquote(%superq(href));
122 %
if &grant_type=authorization_code %then %
do;
123 headers
"Authorization"=
"Bearer &&&access_token_var";
126 libname &libref2 JSON fileref=&fname2;
128 length
id $36 name $128 uri $64 type $32 description $256;
129 if _n_=1 then call missing (of _all_);
132 filename &fname2 clear;
133 libname &libref2 clear;
138filename &fname1 clear;
139libname &libref1 clear;
141%mend mv_getfoldermembers;