92%macro mv_getjobstate(uri=0,outds=work.mv_getjobstate
93 ,contextName=SAS Job Execution compute context
94 ,access_token_var=ACCESS_TOKEN
95 ,grant_type=sas_services
98%
if &grant_type=detect %then %
do;
99 %
if %symexist(&access_token_var) %then %let grant_type=authorization_code;
100 %
else %let grant_type=sas_services;
102%
if &grant_type=sas_services %then %
do;
103 %let oauth_bearer=oauth_bearer=sas_services;
104 %let &access_token_var=;
107%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
108 and &grant_type ne sas_services
111 ,msg=%str(Invalid value
for grant_type: &grant_type)
118 if length(uri)<12 then
do;
119 call symputx(
'errflg',1);
120 call symputx(
'errmsg',
"URI is invalid (too short) - '&uri'",
'l');
122 if scan(uri,-1) ne 'state' or scan(uri,1) ne 'jobExecution' then do;
124 call symputx('errflg',1);
125 call symputx('errmsg',
126 "URI should be in format /jobExecution/jobs/$$$$UUID$$$$/state"
127 !!" but is actually like: &uri",'l');
131%mp_abort(iftrue=(&errflg=1)
136options noquotelenmax;
138%let base_uri=%mf_getplatform(VIYARESTAPI);
141%let fname0=%mf_getuniquefileref();
143proc http method='GET' out=&fname0 &oauth_bearer url="&base_uri/&uri";
144 headers "Accept"="text/plain"
145 %if &grant_type=authorization_code %then %do;
146 "Authorization"="Bearer &&&access_token_var"
149%if &SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201 %then
151 data _null_;infile &fname0;input;putlog _infile_;run;
152 %mp_abort(mac=&sysmacroname
153 ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
158 format uri $128. state $32. timestamp datetime19.;
161 timestamp=datetime();
166proc append base=&outds data=&syslast;
169filename &fname0 clear;