33 %macro mv_deletejes(path=
35 ,access_token_var=ACCESS_TOKEN
36 ,grant_type=sas_services
39 %
if &grant_type=detect %then %
do;
40 %
if %symexist(&access_token_var) %then %let grant_type=authorization_code;
41 %
else %let grant_type=sas_services;
43 %
if &grant_type=sas_services %then %
do;
44 %let oauth_bearer=oauth_bearer=sas_services;
45 %let &access_token_var=;
47 %put &sysmacroname: grant_type=&grant_type;
48 %mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
49 and &grant_type ne sas_services
52 ,msg=%str(Invalid value
for grant_type: &grant_type)
54 %mp_abort(iftrue=(%mf_isblank(&path)=1)
56 ,msg=%str(path value must be provided)
58 %mp_abort(iftrue=(%mf_isblank(&name)=1)
60 ,msg=%str(name value must be provided)
62 %mp_abort(iftrue=(%length(&path)=1)
64 ,msg=%str(path value must be provided)
67 options noquotelenmax;
69 %let base_uri=%mf_getplatform(VIYARESTAPI);
71 %put &sysmacroname: fetching details
for &path ;
73 %let fname1=%mf_getuniquefileref();
74 proc http method=
'GET' out=&fname1 &oauth_bearer
75 url=
"&base_uri/folders/folders/@item?path=&path";
76 %
if &grant_type=authorization_code %then %
do;
77 headers
"Authorization"=
"Bearer &&&access_token_var";
80 %
if &SYS_PROCHTTP_STATUS_CODE=404 %then %
do;
81 %put &sysmacroname: Folder &path NOT FOUND - nothing to
delete!;
84 %
else %
if &SYS_PROCHTTP_STATUS_CODE ne 200 %then %
do;
86 %mp_abort(mac=&sysmacroname
87 ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
91 %put &sysmacroname: grab the follow on link ;
93 %let libref1=%mf_getuniquelibref();
94 libname &libref1 JSON fileref=&fname1;
97 if rel=
'members' then call symputx(
'mref',quote(
"&base_uri"!!trim(href)),
'l');
102 %let fname1a=%mf_getuniquefileref();
103 proc http method=
'GET' out=&fname1a &oauth_bearer
104 url=%unquote(%superq(mref));
105 %
if &grant_type=authorization_code %then %
do;
106 headers
"Authorization"=
"Bearer &&&access_token_var";
109 %put &=SYS_PROCHTTP_STATUS_CODE;
111 %let libref1a=%mf_getuniquelibref();
112 libname &libref1a JSON fileref=&fname1a;
115 %put Getting
object uri from &libref1a..items;
117 set &libref1a..items;
118 if contenttype=
'jobDefinition' and upcase(name)=
"%upcase(&name)" then
do;
119 call symputx(
'uri',cats(
"&base_uri",uri),
'l');
120 call symputx(
'found',1,
'l');
123 %
if &found=0 %then %
do;
124 %put NOTE:;%put NOTE- &sysmacroname: &path/&name NOT FOUND;%put NOTE- ;
127 proc http method=
"DELETE" url=
"&uri" &oauth_bearer;
129 %
if &grant_type=authorization_code %then %
do;
130 "Authorization"=
"Bearer &&&access_token_var"
134 %
if &SYS_PROCHTTP_STATUS_CODE ne 204 %then %
do;
135 data _null_; infile &fname2; input; putlog _infile_;run;
136 %mp_abort(mac=&sysmacroname
137 ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
140 %
else %put &sysmacroname: &path/&name successfully deleted;
143 filename &fname1 clear;
144 libname &libref1 clear;
145 filename &fname1a clear;
146 libname &libref1a clear;