93%macro mv_getjobstate(uri=0,outds=work.mv_getjobstate
94 ,contextName=SAS Job Execution compute context
95 ,access_token_var=ACCESS_TOKEN
96 ,grant_type=sas_services
99%
if &grant_type=detect %then %
do;
100 %
if %symexist(&access_token_var) %then %let grant_type=authorization_code;
101 %
else %let grant_type=sas_services;
103%
if &grant_type=sas_services %then %
do;
104 %let oauth_bearer=oauth_bearer=sas_services;
105 %let &access_token_var=;
108%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
109 and &grant_type ne sas_services
112 ,msg=%str(Invalid value
for grant_type: &grant_type)
119 if length(uri)<12 then
do;
120 call symputx(
'errflg',1);
121 call symputx(
'errmsg',
"URI is invalid (too short) - '&uri'",
'l');
123 if scan(uri,-1) ne 'state' or scan(uri,1) ne 'jobExecution' then do;
125 call symputx('errflg',1);
126 call symputx('errmsg',
127 "URI should be in format /jobExecution/jobs/$$$$UUID$$$$/state"
128 !!" but is actually like: &uri",'l');
132%mp_abort(iftrue=(&errflg=1)
137options noquotelenmax;
139%let base_uri=%mf_getplatform(VIYARESTAPI);
142%let fname0=%mf_getuniquefileref();
144proc http method='GET' out=&fname0 &oauth_bearer url="&base_uri/&uri";
145 headers "Accept"="text/plain"
146 %if &grant_type=authorization_code %then %do;
147 "Authorization"="Bearer &&&access_token_var"
150%if &SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201 %then
152 data _null_;infile &fname0;input;putlog _infile_;run;
153 %mp_abort(mac=&sysmacroname
154 ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
159 format uri $128. state $32. timestamp datetime19.;
162 timestamp=datetime();
167proc append base=&outds data=&syslast;
170filename &fname0 clear;