42%macro mv_getfoldermembers(root=/
43 ,access_token_var=ACCESS_TOKEN
44 ,grant_type=sas_services
48%
if &grant_type=detect %then %
do;
49 %
if %symexist(&access_token_var) %then %let grant_type=authorization_code;
50 %
else %let grant_type=sas_services;
52%
if &grant_type=sas_services %then %
do;
53 %let oauth_bearer=oauth_bearer=sas_services;
54 %let &access_token_var=;
57%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
58 and &grant_type ne sas_services
61 ,msg=%str(Invalid value
for grant_type: &grant_type)
64%
if %mf_isblank(&root)=1 %then %let root=/;
70%let fname1=%mf_getuniquefileref();
71%let libref1=%mf_getuniquelibref();
74%let base_uri=%mf_getplatform(VIYARESTAPI);
76%
if "&root"=
"/" %then %
do;
78 proc http method=
'GET' out=&fname1 &oauth_bearer
79 url=
"&base_uri/folders/rootFolders?limit=1000";
80 %
if &grant_type=authorization_code %then %
do;
81 headers
"Authorization"=
"Bearer &&&access_token_var";
84 libname &libref1 JSON fileref=&fname1;
91 proc http method=
'GET' out=&fname1 &oauth_bearer
92 url=
"&base_uri/folders/folders/@item?path=&root";
93 %
if &grant_type=authorization_code %then %
do;
94 headers
"Authorization"=
"Bearer &&&access_token_var";
98 libname &libref1 JSON fileref=&fname1;
103 length rel href $512;
104 call missing(rel,href);
106 if rel=
'members' then
do;
107 url=cats(
"'",
"&base_uri",href,
"?limit=10000'");
108 call symputx(
'href',url,
'l');
109 call symputx(
'cnt',1,
'l');
112 %
if &cnt=0 %then %
do;
113 %put NOTE:;%put NOTE- No members found in &root!!;%put NOTE-;
116 %local fname2 libref2;
117 %let fname2=%mf_getuniquefileref();
118 %let libref2=%mf_getuniquelibref();
119 proc http method=
'GET' out=&fname2 &oauth_bearer
120 url=%unquote(%superq(href));
121 %
if &grant_type=authorization_code %then %
do;
122 headers
"Authorization"=
"Bearer &&&access_token_var";
125 libname &libref2 JSON fileref=&fname2;
127 length
id $36 name $128 uri $64 type $32 description $256;
128 if _n_=1 then call missing (of _all_);
131 filename &fname2 clear;
132 libname &libref2 clear;
137filename &fname1 clear;
138libname &libref1 clear;
140%mend mv_getfoldermembers;