35%macro mv_getViyaFileExtParms(
40 viyaFileExtRespLibDs=work.mv_getViyaFileExtParmsResponse,
47 iftrue=(%mf_isBlank(&ext))
48 ,msg=%str(No file extension provided.)
49 ,mac=MV_GETVIYAFILEEXTPARMS
53 iftrue=(%mf_isBlank(&typeDefNameVar) and
54 %mf_isBlank(&propertiesVar) and
55 %mf_isBlank(&mediaTypeVar))
56 ,msg=%str(MV_GETVIYAFILEEXTPARMS - No parameter was requested.)
57 ,mac=MV_GETVIYAFILEEXTPARMS
61 iftrue=(%mf_isBlank(&viyaFileExtRespLibDs))
62 ,msg=%str(No <libname.>dataset name provided to cache inital response.)
63 ,mac=MV_GETVIYAFILEEXTPARMS
67 %
if not %mf_isBlank(&typeDefNameVar) %then %
do;
68 %global &typeDefNameVar;
69 %let &typeDefNameVar = %str();
71 %
if not %mf_isBlank(&propertiesVar) %then %
do;
72 %global &propertiesVar;
73 %let &propertiesVar = %str();
75 %
if not %mf_isBlank(&mediaTypeVar) %then %
do;
76 %global &mediaTypeVar;
77 %let &mediaTypeVar = %str();
80 %let base_uri=%mf_getplatform(VIYARESTAPI);
81 %
if &mdebug=1 %then %put DEBUG: &=base_uri;
83 %let ext=%lowcase(&ext);
87 %
if not %mf_existds(&viyaFileExtRespLibDs) %then %
do;
91 %let viyatypedefs=%mf_getuniquefileref();
92 filename &viyatypedefs temp;
94 %let url = &base_uri/types/types?limit=999999;
96 proc http oauth_bearer=sas_services out=&viyatypedefs
100 %
if &mdebug=1 %then %put DEBUG: &sysmacroname &=url
101 &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
103 %
if (&SYS_PROCHTTP_STATUS_CODE ne 200) %then %
do;
106 %put INFO: &sysmacroname File extension details were not retrieved.;
107 filename &viyatypedefs clear;
111 %
if &mdebug=1 %then %
do;
116 infile &viyatypedefs dlm=
null lrecl=120 recfm=n;
118 if _n_ = 1 then put
"DEBUG:";
125 %local jsonworkfolder jsonlib opt_dlcreatedir;
126 %let jsonworkfolder=%sysfunc(pathname(work))/%mf_getuniquename(prefix=jsn_);
127 %let jsonlib=%mf_getuniquelibref(prefix=json);
129 %let opt_dlcreatedir = %sysfunc(getoption(dlcreatedir));
130 options dlcreatedir; libname &jsonlib
"&jsonworkfolder";
131 options &opt_dlcreatedir;
135 %let libref1=%mf_getuniquelibref();
136 libname &libref1 JSON fileref=&viyatypedefs automap=create;
137 proc copy in=&libref1 out=&jsonlib; run;
139 libname &libref1 clear;
142 data &viyaFileExtRespLibDs;
143 length _viyaItemIdx 8;
144 set &jsonlib..alldata;
145 retain _viyaItemIdx 0;
147 if P=1 and P1=
'items' then _viyaItemIdx + 1;
150 %
if &mdebug=0 %then %
do;
152 proc datasets library=&jsonlib nolist kill; quit;
153 libname &jsonlib clear;
156 filename &viyatypedefs clear;
160 %
if &mdebug %then %put DEBUG: Find the row-group
for extension &ext;
163 set &viyaFileExtRespLibDs;
164 where p1=
'items' and p2=
'extensions' and value=
"&ext";
165 call symputx(
'itemRowGroup',_viyaItemIdx,
'l');
166 %
if &mdebug %then %
do;
171 %
if &mdebug %then %put DEBUG: &=itemRowGroup;
173 %
if %mf_isBlank(&itemRowGroup) %then %
do;
175 %
if &mdebug %then %put DEBUG: No type details found
for extension
"&ext";
181 %let dsItems = %mf_getuniquename(prefix=dsItems_);
183 set &viyaFileExtRespLibDs;
184 where _viyaItemIdx = &itemRowGroup;
188 %
if (not %mf_isBlank(&typeDefNameVar)) %then %
do;
189 %let &typeDefNameVar = %mf_getvalue(
190 &dsItems,value,filter=%quote(p1=
"items" and p2=
"name"));
192 %put DEBUG: &=typeDefNameVar &typeDefNameVar=&&&typeDefNameVar;
196 %
if (not %mf_isBlank(&mediaTypeVar)) %then %
do;
197 %let &mediaTypeVar = %mf_getvalue(
198 &dsItems,value,filter=%quote(p1=
"items" and p2=
"mediaType"));
199 %
if &mdebug %then %put DEBUG: &=mediaTypeVar &mediaTypeVar=&&&mediaTypeVar;
203 %
if not %mf_isBlank(&propertiesVar) %then %
do;
207 %let dsProperties = %mf_getuniquename(prefix=dsProperties_);
208 data work.&dsProperties ( rename=(p3 = propertyName) );
210 where p2=
"properties" and v=1;
214 %
if ( %mf_nobs(&dsProperties) = 0 ) %then %
do;
215 %let &propertiesVar = %str();
216 %
if &mdebug %then %put DEBUG: &SYSMACRONAME - No Viya properties %trim(
217 )found for file suffix %str(%')&ext%str(%');
227 set &dsProperties end=last;
228 if _n_ = 1 then properties = '{
';
230 line = cats(quote(trim(propertyName)),':
');
231 /* Only strings and bools appear in properties */
232 if value not in ("true","false") then value = quote(trim(value));
233 line = catx(' ',line,value);
234 /* Add a comma separator to all except the last line */
235 if not last then line = cats(line,',
');
237 /* Add this line to the output value */
238 properties = catx(' ',properties,line);
241 /* Close off the properties object and output to the macro variable */
242 properties=catx(' ',properties,'}
');
243 call symputx("&propertiesVar",properties);
248 %put DEBUG: &=propertiesVar &propertiesVar=&&&propertiesVar;
253%mend mv_getViyaFileExtParms;