mirror of
https://github.com/sasjs/core.git
synced 2026-01-02 23:30:06 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f5fa414e1 | ||
|
|
4b142f1f45 | ||
|
|
3f73a565a6 | ||
|
|
d3f1c8e960 | ||
|
|
0d10441b89 | ||
|
|
85e1f56400 | ||
|
|
c5ec21c7a0 | ||
|
|
e049ab99a7 | ||
|
|
e9deab3885 | ||
|
|
8d2f084316 |
21
README.md
21
README.md
@@ -147,16 +147,17 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
||||
- macro names must be lowercase
|
||||
- one macro per file
|
||||
- prefixes:
|
||||
- _mcf_ for macro compiled functions (proc fcmp)
|
||||
- _mddl_ for macros containing DDL (Data Definition Language)
|
||||
- _mf_ for macro functions (can be used in open code).
|
||||
- _ml_ for macros that are used to compile LUA modules
|
||||
- _mm_ for metadata macros (interface with the metadata server).
|
||||
- _mmx_ for macros that use metadata and are XCMD enabled (working on both windows and unix)
|
||||
- _mp_ for macro procedures (which generate sas code)
|
||||
- _ms_ for macro procedures that will only work with [@sasjs/server](https://github.com/sasjs/server)
|
||||
- _mv_ for macro procedures that will only work in Viya
|
||||
- _mx_ for macros that work on Viya, SAS 9 EBI and SASjs Server
|
||||
- _mcf__: macro compiled functions (proc fcmp)
|
||||
- _mddl__: macros containing DDL (Data Definition Language)
|
||||
- _mf__: macro functions (can be used in open code).
|
||||
- _mfv__: macro functions that work only in Viya
|
||||
- _ml__: macros that are used to compile LUA modules
|
||||
- _mm__: metadata macros (interface with the metadata server).
|
||||
- _mmx__: macros that use metadata and are XCMD enabled (working on both windows and unix)
|
||||
- _mp__: macro procedures (which generate sas code)
|
||||
- _ms__: macro procedures that will only work with [@sasjs/server](https://github.com/sasjs/server)
|
||||
- _mv__: macro procedures that will only work in Viya
|
||||
- _mx__: macros that work on Viya, SAS 9 EBI and SASjs Server
|
||||
- follow verb-noun convention
|
||||
- unix style line endings (lf)
|
||||
- individual lines should be no more than 80 characters long
|
||||
|
||||
68
all.sas
68
all.sas
@@ -24379,26 +24379,28 @@ run;
|
||||
%end;
|
||||
"Accept"="*/*";
|
||||
run;
|
||||
%put &sysmacroname DELETE &base_uri&fileuri
|
||||
&=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%put &sysmacroname DELETE &base_uri&fileuri;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 204 %then %do;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%end;
|
||||
%end;
|
||||
|
||||
%local url mimetype;
|
||||
%local url mimetype ext;
|
||||
%let url=&base_uri/files/files?parentFolderUri=&self_uri;
|
||||
%let ext=%upcase(%scan(&name,-1,.));
|
||||
|
||||
/* fetch job info */
|
||||
%local fname1;
|
||||
%let fname1=%mf_getuniquefileref();
|
||||
proc http method='POST' out=&fname1 &oauth_bearer in=&fref
|
||||
%if "&ctype" = "0" %then %do;
|
||||
%let mimetype=%mf_mimetype(%scan(&name,-1,.));
|
||||
%let mimetype=%mf_mimetype(&ext);
|
||||
ct="&mimetype"
|
||||
%end;
|
||||
%else %do;
|
||||
ct="&ctype"
|
||||
%end;
|
||||
%if "&mimetype"="text/html" or "&mimetype"="text/css"
|
||||
or "&mimetype"="text/javascript" %then %do;
|
||||
%if "&ext"="HTML" or "&ext"="CSS" or "&ext"="JS" or "&ext"="SVG" %then %do;
|
||||
url="&url%str(&)typeDefName=file";
|
||||
%end;
|
||||
%else %do;
|
||||
@@ -24409,9 +24411,16 @@ proc http method='POST' out=&fname1 &oauth_bearer in=&fref
|
||||
%if &grant_type=authorization_code %then %do;
|
||||
"Authorization"="Bearer &&&access_token_var"
|
||||
%end;
|
||||
"Content-Disposition"= "&contentdisp filename=""&name""; name=""&name"";";
|
||||
"Content-Disposition"=
|
||||
%if "&ext"="SVG" %then %do;
|
||||
"filename=""&name"";"
|
||||
%end;
|
||||
%else %do;
|
||||
"&contentdisp filename=""&name""; name=""&name"";"
|
||||
%end;
|
||||
;
|
||||
run;
|
||||
%put &sysmacroname POST &=url
|
||||
%if &mdebug=1 %then %put &sysmacroname POST &=url
|
||||
&=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||
,mac=MV_CREATEFILE
|
||||
@@ -24420,7 +24429,7 @@ run;
|
||||
%local libref2;
|
||||
%let libref2=%mf_getuniquelibref();
|
||||
libname &libref2 JSON fileref=&fname1;
|
||||
%put Grabbing the follow on link ;
|
||||
/* Grab the follow on link */
|
||||
data &outds;
|
||||
set &libref2..links end=last;
|
||||
if rel='createChild' then do;
|
||||
@@ -24429,10 +24438,8 @@ data &outds;
|
||||
end;
|
||||
run;
|
||||
|
||||
%put &sysmacroname: File &name successfully created:;%put;
|
||||
%put &base_uri%mfv_getpathuri(&path/&name);%put;
|
||||
%put &sysmacroname: &name created at %mfv_getpathuri(&path/&name);%put;
|
||||
%put &base_uri/SASJobExecution?_file=&path/&name;%put;
|
||||
%put &sysmacroname:;
|
||||
|
||||
%mend mv_createfile;/**
|
||||
@file mv_createfolder.sas
|
||||
@@ -24483,7 +24490,7 @@ run;
|
||||
%else %let dbg=*;
|
||||
|
||||
%if %mfv_existfolder(&path)=1 %then %do;
|
||||
%put &sysmacroname: &path already exists;
|
||||
%&dbg.put &sysmacroname: &path already exists;
|
||||
data &outds;
|
||||
self_uri="%mfv_getpathuri(&path)";
|
||||
output;
|
||||
@@ -24600,8 +24607,9 @@ options noquotelenmax;
|
||||
'Content-Type'='application/vnd.sas.content.folder+json'
|
||||
'Accept'='application/vnd.sas.content.folder+json';
|
||||
run;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE;
|
||||
%put &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 200 %then %do;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%end;
|
||||
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||
,mac=&sysmacroname
|
||||
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
||||
@@ -25108,7 +25116,7 @@ options noquotelenmax;
|
||||
%let path=%substr(&path,1,%length(&path)-1);
|
||||
|
||||
/* ensure folder exists */
|
||||
%put &sysmacroname: Path &path being checked / created;
|
||||
%&dbg.put &sysmacroname: Path &path being checked / created;
|
||||
%mv_createfolder(path=&path)
|
||||
|
||||
%local base_uri; /* location of rest apis */
|
||||
@@ -25941,13 +25949,8 @@ run;
|
||||
libname &libref1 clear;
|
||||
%end;
|
||||
|
||||
%put &sysmacroname: Job &name successfully created in &path;
|
||||
%put &sysmacroname:;
|
||||
%put &sysmacroname: Check it out here:;
|
||||
%put &sysmacroname:;%put;
|
||||
%put &url/SASJobExecution?_PROGRAM=&path/&name;%put;
|
||||
%put &sysmacroname:;
|
||||
%put &sysmacroname:;
|
||||
%put &sysmacroname: Job &name created! Check it out:;
|
||||
%put &url/SASJobExecution?_PROGRAM=&path/&name;
|
||||
|
||||
%mend mv_createwebservice;
|
||||
/**
|
||||
@@ -26063,13 +26066,15 @@ proc http method='GET' out=&fname1a &oauth_bearer
|
||||
headers "Authorization"="Bearer &&&access_token_var";
|
||||
%end;
|
||||
run;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 200 %then %do;
|
||||
%put &=sysmacroname &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%end;
|
||||
%local libref1a;
|
||||
%let libref1a=%mf_getuniquelibref();
|
||||
libname &libref1a JSON fileref=&fname1a;
|
||||
%local uri found;
|
||||
%let found=0;
|
||||
%put Getting object uri from &libref1a..items;
|
||||
/* %put Getting object uri from &libref1a..items; */
|
||||
data _null_;
|
||||
length contenttype name $1000;
|
||||
set &libref1a..items;
|
||||
@@ -26174,8 +26179,7 @@ libname &libref1a clear;
|
||||
options noquotelenmax;
|
||||
%local base_uri; /* location of rest apis */
|
||||
%let base_uri=%mf_getplatform(VIYARESTAPI);
|
||||
|
||||
%put &sysmacroname: fetching details for &path ;
|
||||
/* fetch the members of the folder to get the uri */
|
||||
%local fname1;
|
||||
%let fname1=%mf_getuniquefileref();
|
||||
proc http method='GET' out=&fname1 &oauth_bearer
|
||||
@@ -26195,7 +26199,7 @@ run;
|
||||
)
|
||||
%end;
|
||||
|
||||
%put &sysmacroname: grab the follow on link ;
|
||||
/* grab the follow on link */
|
||||
%local libref1;
|
||||
%let libref1=%mf_getuniquelibref();
|
||||
libname &libref1 JSON fileref=&fname1;
|
||||
@@ -26213,13 +26217,15 @@ proc http method='GET' out=&fname1a &oauth_bearer
|
||||
headers "Authorization"="Bearer &&&access_token_var";
|
||||
%end;
|
||||
run;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 200 %then %do;
|
||||
%put &=sysmacroname &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%end;
|
||||
%local libref1a;
|
||||
%let libref1a=%mf_getuniquelibref();
|
||||
libname &libref1a JSON fileref=&fname1a;
|
||||
%local uri found;
|
||||
%let found=0;
|
||||
%put Getting object uri from &libref1a..items;
|
||||
/* %put Getting object uri from &libref1a..items; */
|
||||
data _null_;
|
||||
length contenttype name $1000;
|
||||
set &libref1a..items;
|
||||
@@ -26245,7 +26251,7 @@ run;
|
||||
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
||||
)
|
||||
%end;
|
||||
%else %put &sysmacroname: &path/&name successfully deleted;
|
||||
%else %put &sysmacroname: &path/&name deleted;
|
||||
|
||||
/* clear refs */
|
||||
filename &fname1 clear;
|
||||
|
||||
@@ -157,26 +157,28 @@ run;
|
||||
%end;
|
||||
"Accept"="*/*";
|
||||
run;
|
||||
%put &sysmacroname DELETE &base_uri&fileuri
|
||||
&=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%put &sysmacroname DELETE &base_uri&fileuri;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 204 %then %do;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%end;
|
||||
%end;
|
||||
|
||||
%local url mimetype;
|
||||
%local url mimetype ext;
|
||||
%let url=&base_uri/files/files?parentFolderUri=&self_uri;
|
||||
%let ext=%upcase(%scan(&name,-1,.));
|
||||
|
||||
/* fetch job info */
|
||||
%local fname1;
|
||||
%let fname1=%mf_getuniquefileref();
|
||||
proc http method='POST' out=&fname1 &oauth_bearer in=&fref
|
||||
%if "&ctype" = "0" %then %do;
|
||||
%let mimetype=%mf_mimetype(%scan(&name,-1,.));
|
||||
%let mimetype=%mf_mimetype(&ext);
|
||||
ct="&mimetype"
|
||||
%end;
|
||||
%else %do;
|
||||
ct="&ctype"
|
||||
%end;
|
||||
%if "&mimetype"="text/html" or "&mimetype"="text/css"
|
||||
or "&mimetype"="text/javascript" %then %do;
|
||||
%if "&ext"="HTML" or "&ext"="CSS" or "&ext"="JS" or "&ext"="SVG" %then %do;
|
||||
url="&url%str(&)typeDefName=file";
|
||||
%end;
|
||||
%else %do;
|
||||
@@ -187,9 +189,16 @@ proc http method='POST' out=&fname1 &oauth_bearer in=&fref
|
||||
%if &grant_type=authorization_code %then %do;
|
||||
"Authorization"="Bearer &&&access_token_var"
|
||||
%end;
|
||||
"Content-Disposition"= "&contentdisp filename=""&name""; name=""&name"";";
|
||||
"Content-Disposition"=
|
||||
%if "&ext"="SVG" %then %do;
|
||||
"filename=""&name"";"
|
||||
%end;
|
||||
%else %do;
|
||||
"&contentdisp filename=""&name""; name=""&name"";"
|
||||
%end;
|
||||
;
|
||||
run;
|
||||
%put &sysmacroname POST &=url
|
||||
%if &mdebug=1 %then %put &sysmacroname POST &=url
|
||||
&=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||
,mac=MV_CREATEFILE
|
||||
@@ -198,7 +207,7 @@ run;
|
||||
%local libref2;
|
||||
%let libref2=%mf_getuniquelibref();
|
||||
libname &libref2 JSON fileref=&fname1;
|
||||
%put Grabbing the follow on link ;
|
||||
/* Grab the follow on link */
|
||||
data &outds;
|
||||
set &libref2..links end=last;
|
||||
if rel='createChild' then do;
|
||||
@@ -207,9 +216,7 @@ data &outds;
|
||||
end;
|
||||
run;
|
||||
|
||||
%put &sysmacroname: File &name successfully created:;%put;
|
||||
%put &base_uri%mfv_getpathuri(&path/&name);%put;
|
||||
%put &sysmacroname: &name created at %mfv_getpathuri(&path/&name);%put;
|
||||
%put &base_uri/SASJobExecution?_file=&path/&name;%put;
|
||||
%put &sysmacroname:;
|
||||
|
||||
%mend mv_createfile;
|
||||
@@ -47,7 +47,7 @@
|
||||
%else %let dbg=*;
|
||||
|
||||
%if %mfv_existfolder(&path)=1 %then %do;
|
||||
%put &sysmacroname: &path already exists;
|
||||
%&dbg.put &sysmacroname: &path already exists;
|
||||
data &outds;
|
||||
self_uri="%mfv_getpathuri(&path)";
|
||||
output;
|
||||
@@ -164,8 +164,9 @@ options noquotelenmax;
|
||||
'Content-Type'='application/vnd.sas.content.folder+json'
|
||||
'Accept'='application/vnd.sas.content.folder+json';
|
||||
run;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE;
|
||||
%put &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 200 %then %do;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%end;
|
||||
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||
,mac=&sysmacroname
|
||||
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
||||
|
||||
@@ -122,7 +122,7 @@ options noquotelenmax;
|
||||
%let path=%substr(&path,1,%length(&path)-1);
|
||||
|
||||
/* ensure folder exists */
|
||||
%put &sysmacroname: Path &path being checked / created;
|
||||
%&dbg.put &sysmacroname: Path &path being checked / created;
|
||||
%mv_createfolder(path=&path)
|
||||
|
||||
%local base_uri; /* location of rest apis */
|
||||
@@ -955,12 +955,7 @@ run;
|
||||
libname &libref1 clear;
|
||||
%end;
|
||||
|
||||
%put &sysmacroname: Job &name successfully created in &path;
|
||||
%put &sysmacroname:;
|
||||
%put &sysmacroname: Check it out here:;
|
||||
%put &sysmacroname:;%put;
|
||||
%put &url/SASJobExecution?_PROGRAM=&path/&name;%put;
|
||||
%put &sysmacroname:;
|
||||
%put &sysmacroname:;
|
||||
%put &sysmacroname: Job &name created! Check it out:;
|
||||
%put &url/SASJobExecution?_PROGRAM=&path/&name;
|
||||
|
||||
%mend mv_createwebservice;
|
||||
|
||||
@@ -111,13 +111,15 @@ proc http method='GET' out=&fname1a &oauth_bearer
|
||||
headers "Authorization"="Bearer &&&access_token_var";
|
||||
%end;
|
||||
run;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 200 %then %do;
|
||||
%put &=sysmacroname &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%end;
|
||||
%local libref1a;
|
||||
%let libref1a=%mf_getuniquelibref();
|
||||
libname &libref1a JSON fileref=&fname1a;
|
||||
%local uri found;
|
||||
%let found=0;
|
||||
%put Getting object uri from &libref1a..items;
|
||||
/* %put Getting object uri from &libref1a..items; */
|
||||
data _null_;
|
||||
length contenttype name $1000;
|
||||
set &libref1a..items;
|
||||
|
||||
@@ -69,8 +69,7 @@
|
||||
options noquotelenmax;
|
||||
%local base_uri; /* location of rest apis */
|
||||
%let base_uri=%mf_getplatform(VIYARESTAPI);
|
||||
|
||||
%put &sysmacroname: fetching details for &path ;
|
||||
/* fetch the members of the folder to get the uri */
|
||||
%local fname1;
|
||||
%let fname1=%mf_getuniquefileref();
|
||||
proc http method='GET' out=&fname1 &oauth_bearer
|
||||
@@ -90,7 +89,7 @@ run;
|
||||
)
|
||||
%end;
|
||||
|
||||
%put &sysmacroname: grab the follow on link ;
|
||||
/* grab the follow on link */
|
||||
%local libref1;
|
||||
%let libref1=%mf_getuniquelibref();
|
||||
libname &libref1 JSON fileref=&fname1;
|
||||
@@ -108,13 +107,15 @@ proc http method='GET' out=&fname1a &oauth_bearer
|
||||
headers "Authorization"="Bearer &&&access_token_var";
|
||||
%end;
|
||||
run;
|
||||
%put &=SYS_PROCHTTP_STATUS_CODE;
|
||||
%if &SYS_PROCHTTP_STATUS_CODE ne 200 %then %do;
|
||||
%put &=sysmacroname &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||
%end;
|
||||
%local libref1a;
|
||||
%let libref1a=%mf_getuniquelibref();
|
||||
libname &libref1a JSON fileref=&fname1a;
|
||||
%local uri found;
|
||||
%let found=0;
|
||||
%put Getting object uri from &libref1a..items;
|
||||
/* %put Getting object uri from &libref1a..items; */
|
||||
data _null_;
|
||||
length contenttype name $1000;
|
||||
set &libref1a..items;
|
||||
@@ -140,7 +141,7 @@ run;
|
||||
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
||||
)
|
||||
%end;
|
||||
%else %put &sysmacroname: &path/&name successfully deleted;
|
||||
%else %put &sysmacroname: &path/&name deleted;
|
||||
|
||||
/* clear refs */
|
||||
filename &fname1 clear;
|
||||
|
||||
Reference in New Issue
Block a user