92%macro mv_getjobresult(uri=0
93 ,access_token_var=ACCESS_TOKEN
94 ,grant_type=sas_services
101%
if &mdebug=1 %then %
do;
102 %put &sysmacroname entry vars:;
108%
if &grant_type=detect %then %
do;
109 %
if %symexist(&access_token_var) %then %let grant_type=authorization_code;
110 %
else %let grant_type=sas_services;
112%
if &grant_type=sas_services %then %
do;
113 %let oauth_bearer=oauth_bearer=sas_services;
114 %let &access_token_var=;
117%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
118 and &grant_type ne sas_services
121 ,msg=%str(Invalid value
for grant_type: &grant_type)
129 if length(uri)<12 then
do;
130 call symputx(
'errflg',1);
131 call symputx(
'errmsg',
"URI is invalid (too short) - '&uri'",
'l');
133 if scan(uri,-1)=
'state' or scan(uri,1) ne 'jobExecution' then do;
134 call symputx('errflg',1);
135 call symputx('errmsg',
136 "URI should be in format /jobExecution/jobs/$$$$UUID$$$$"
137 !!" but is actually like: &uri",'l');
141%mp_abort(iftrue=(&errflg=1)
146%if &outref ne 0 and %mf_existfileref(&outref) ne 1 %then %do;
147 filename &outref temp;
150options noquotelenmax;
152%let base_uri=%mf_getplatform(VIYARESTAPI);
156%let fname1=%mf_getuniquefileref();
157proc http method='GET' out=&fname1 &oauth_bearer
159 headers "Accept"="application/json"
160 %if &grant_type=authorization_code %then %do;
161 "Authorization"="Bearer &&&access_token_var"
165%if &SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201 %then
167 data _null_;infile &fname1;input;putlog _infile_;run;
168 %mp_abort(mac=&sysmacroname
169 ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
172%if &mdebug=1 %then %do;
174 infile &fname1 lrecl=32767;
182%let lib1=%mf_getuniquelibref();
183libname &lib1 JSON fileref=&fname1;
186 call symputx('resuri',_&result,'l');
187 &dbg putlog "&sysmacroname results: " (_all_)(=);
189%mp_abort(iftrue=("&resuri"=".")
191 ,msg=%str(Variable _&result did not exist in the response json)
196%let fname2=%mf_getuniquefileref();
197proc http method='GET' out=&fname2 &oauth_bearer
198 url="&base_uri&resuri/content?limit=10000";
199 headers "Accept"="application/json"
200 %if &grant_type=authorization_code %then %do;
201 "Authorization"="Bearer &&&access_token_var"
205%if &mdebug=1 %then %do;
208 infile &fname2 recfm=n;
210 putlog
char $char1. @;
214%if &outref ne 0 %then %do;
215 filename &outref temp;
216 %mp_binarycopy(inref=&fname2,outref=&outref)
218%if &outlib ne 0 %then %do;
219 libname &outlib JSON fileref=&fname2;
222%if &mdebug=0 %then %do;
223 filename &fname1 clear;
224 filename &fname2 clear;
228 %put &sysmacroname exit vars:;
232%mend mv_getjobresult;