37%macro mv_getViyaFileExtParms(
42 viyaFileExtRespLibDs=work.mv_getViyaFileExtParmsResponse,
49 iftrue=(%mf_isBlank(&ext))
50 ,msg=%str(No file extension provided.)
51 ,mac=MV_GETVIYAFILEEXTPARMS
55 iftrue=(%mf_isBlank(&typeDefNameVar) and
56 %mf_isBlank(&propertiesVar) and
57 %mf_isBlank(&mediaTypeVar))
58 ,msg=%str(MV_GETVIYAFILEEXTPARMS - No parameter was requested.)
59 ,mac=MV_GETVIYAFILEEXTPARMS
63 iftrue=(%mf_isBlank(&viyaFileExtRespLibDs))
64 ,msg=%str(No <libname.>dataset name provided to cache inital response.)
65 ,mac=MV_GETVIYAFILEEXTPARMS
69 %
if not %mf_isBlank(&typeDefNameVar) %then %
do;
70 %global &typeDefNameVar;
71 %let &typeDefNameVar = %str();
73 %
if not %mf_isBlank(&propertiesVar) %then %
do;
74 %global &propertiesVar;
75 %let &propertiesVar = %str();
77 %
if not %mf_isBlank(&mediaTypeVar) %then %
do;
78 %global &mediaTypeVar;
79 %let &mediaTypeVar = %str();
82 %let base_uri=%mf_getplatform(VIYARESTAPI);
83 %
if &mdebug=1 %then %put DEBUG: &=base_uri;
85 %let ext=%lowcase(&ext);
89 %
if not %mf_existds(&viyaFileExtRespLibDs) %then %
do;
93 %let viyatypedefs=%mf_getuniquefileref();
94 filename &viyatypedefs temp;
96 %let url = &base_uri/types/types?limit=999999;
98 proc http oauth_bearer=sas_services out=&viyatypedefs
102 %
if &mdebug=1 %then %put DEBUG: &sysmacroname &=url
103 &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
105 %
if (&SYS_PROCHTTP_STATUS_CODE ne 200) %then %
do;
108 %put INFO: &sysmacroname File extension details were not retrieved.;
109 filename &viyatypedefs clear;
113 %
if &mdebug=1 %then %
do;
118 infile &viyatypedefs dlm=
null lrecl=120 recfm=n;
120 if _n_ = 1 then put
"DEBUG:";
127 %local jsonworkfolder jsonlib opt_dlcreatedir;
128 %let jsonworkfolder=%sysfunc(pathname(work))/%mf_getuniquename(prefix=jsn_);
129 %let jsonlib=%mf_getuniquelibref(prefix=json);
131 %let opt_dlcreatedir = %sysfunc(getoption(dlcreatedir));
132 options dlcreatedir; libname &jsonlib
"&jsonworkfolder";
133 options &opt_dlcreatedir;
137 %let libref1=%mf_getuniquelibref();
138 libname &libref1 JSON fileref=&viyatypedefs automap=create;
139 proc copy in=&libref1 out=&jsonlib; run;
141 libname &libref1 clear;
144 data &viyaFileExtRespLibDs;
145 length _viyaItemIdx 8;
146 set &jsonlib..alldata;
147 retain _viyaItemIdx 0;
149 if P=1 and P1=
'items' then _viyaItemIdx + 1;
152 %
if &mdebug=0 %then %
do;
154 proc datasets library=&jsonlib nolist kill; quit;
155 libname &jsonlib clear;
158 filename &viyatypedefs clear;
162 %
if &mdebug %then %put DEBUG: Find the row-group
for extension &ext;
165 set &viyaFileExtRespLibDs;
166 where p1=
'items' and p2=
'extensions' and value=
"&ext";
167 call symputx(
'itemRowGroup',_viyaItemIdx,
'l');
168 %
if &mdebug %then %
do;
173 %
if &mdebug %then %put DEBUG: &=itemRowGroup;
175 %
if %mf_isBlank(&itemRowGroup) %then %
do;
177 %
if &mdebug %then %put DEBUG: No type details found
for extension
"&ext";
183 %let dsItems = %mf_getuniquename(prefix=dsItems_);
185 set &viyaFileExtRespLibDs;
186 where _viyaItemIdx = &itemRowGroup;
190 %
if (not %mf_isBlank(&typeDefNameVar)) %then %
do;
191 %let &typeDefNameVar = %mf_getvalue(
192 &dsItems,value,filter=%quote(p1=
"items" and p2=
"name"));
194 %put DEBUG: &=typeDefNameVar &typeDefNameVar=&&&typeDefNameVar;
198 %
if (not %mf_isBlank(&mediaTypeVar)) %then %
do;
199 %let &mediaTypeVar = %mf_getvalue(
200 &dsItems,value,filter=%quote(p1=
"items" and p2=
"mediaType"));
201 %
if &mdebug %then %put DEBUG: &=mediaTypeVar &mediaTypeVar=&&&mediaTypeVar;
205 %
if not %mf_isBlank(&propertiesVar) %then %
do;
209 %let dsProperties = %mf_getuniquename(prefix=dsProperties_);
210 data work.&dsProperties ( rename=(p3 = propertyName) );
212 where p2=
"properties" and v=1;
216 %
if ( %mf_nobs(&dsProperties) = 0 ) %then %
do;
217 %let &propertiesVar = %str();
218 %
if &mdebug %then %put DEBUG: &SYSMACRONAME - No Viya properties %trim(
219 )found for file suffix %str(%')&ext%str(%');
229 set &dsProperties end=last;
230 if _n_ = 1 then properties = '{
';
232 line = cats(quote(trim(propertyName)),':
');
233 /* Only strings and bools appear in properties */
234 if value not in ("true","false") then value = quote(trim(value));
235 line = catx(' ',line,value);
236 /* Add a comma separator to all except the last line */
237 if not last then line = cats(line,',
');
239 /* Add this line to the output value */
240 properties = catx(' ',properties,line);
243 /* Close off the properties object and output to the macro variable */
244 properties=catx(' ',properties,'}
');
245 call symputx("&propertiesVar",properties);
250 %put DEBUG: &=propertiesVar &propertiesVar=&&&propertiesVar;
255%mend mv_getViyaFileExtParms;