1
0
mirror of https://github.com/sasjs/core.git synced 2025-12-10 22:14:35 +00:00

fix: changing replace to YES in mm_createwebservice.sas, also setting a default for code to ft15f001. More debugging added to mv_createfolder.sas

This commit is contained in:
Allan Bowe
2021-05-26 10:36:45 +03:00
parent 7915ba2c41
commit 9b2368443e
3 changed files with 92 additions and 38 deletions

65
all.sas
View File

@@ -8901,7 +8901,7 @@ Usage:
%webout(OBJ,example2) * Object format, easier to work with ; %webout(OBJ,example2) * Object format, easier to work with ;
%webout(CLOSE) %webout(CLOSE)
;;;; ;;;;
%mm_createwebservice(path=/Public/app/common,name=appInit) %mm_createwebservice(path=/Public/app/common,name=appInit,code=ft15f001)
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mm_createstp.sas @li mm_createstp.sas
@@ -8916,12 +8916,15 @@ Usage:
@param desc= The description of the service (optional) @param desc= The description of the service (optional)
@param precode= Space separated list of filerefs, pointing to the code that @param precode= Space separated list of filerefs, pointing to the code that
needs to be attached to the beginning of the service (optional) needs to be attached to the beginning of the service (optional)
@param code= Space seperated fileref(s) of the actual code to be added @param code=(ft15f001) Space seperated fileref(s) of the actual code to be
@param server= The server which will run the STP. Server name or uri is fine. added
@param mDebug= set to 1 to show debug messages in the log @param server=(SASApp) The server which will run the STP. Server name or uri
@param replace= select YES to replace any existing service in that location is fine.
@param adapter= the macro uses the sasjs adapter by default. To use another @param mDebug=(0) set to 1 to show debug messages in the log
adapter, add a (different) fileref here. @param replace=(YES) select NO to avoid replacing an existing service in that
location
@param adapter=(sasjs) the macro uses the sasjs adapter by default. To use
another adapter, add a (different) fileref here.
@version 9.2 @version 9.2
@author Allan Bowe @author Allan Bowe
@@ -8931,11 +8934,11 @@ Usage:
%macro mm_createwebservice(path= %macro mm_createwebservice(path=
,name=initService ,name=initService
,precode= ,precode=
,code= ,code=ft15f001
,desc=This stp was created automagically by the mm_createwebservice macro ,desc=This stp was created automagically by the mm_createwebservice macro
,mDebug=0 ,mDebug=0
,server=SASApp ,server=SASApp
,replace=NO ,replace=YES
,adapter=sasjs ,adapter=sasjs
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
@@ -9347,7 +9350,7 @@ run;
%put &url?_PROGRAM=&path/&name; %put &url?_PROGRAM=&path/&name;
%put ;%put ;%put ;%put ;%put ;%put ; %put ;%put ;%put ;%put ;%put ;%put ;
%mend; %mend mm_createwebservice;
/** /**
@file mm_deletedocument.sas @file mm_deletedocument.sas
@brief Deletes a Document using path as reference @brief Deletes a Document using path as reference
@@ -12889,17 +12892,22 @@ run;
%mend;/** %mend;/**
@file mv_createfolder.sas @file mv_createfolder.sas
@brief Creates a viya folder if that folder does not already exist @brief Creates a viya folder if that folder does not already exist
@details Expects oauth token in a global macro variable (default @details Creates a viya folder by checking if each parent folder exists, and
ACCESS_TOKEN). recursively creating children if needed.
Usage:
%mv_createfolder(path=/Public) %mv_createfolder(path=/Public)
@param path= The full path of the folder to be created @param [in] path= The full path of the folder to be created
@param access_token_var= The global macro variable to contain the access token @param [in] access_token_var= The global macro variable to contain the access
@param grant_type= (authorization_code) Valid values are "password" or token, if using authorization_code grant type.
"authorization_code" (unquoted). @param [in] grant_type= (sas_services) Valid values are:
@li password
@li authorization_code
@li sas_services
@param [in] mdebug=(0) set to 1 to enable DEBUG messages
@version VIYA V.03.04 @version VIYA V.03.04
@author Allan Bowe, source: https://github.com/sasjs/core @author Allan Bowe, source: https://github.com/sasjs/core
@@ -12916,15 +12924,23 @@ run;
%macro mv_createfolder(path= %macro mv_createfolder(path=
,access_token_var=ACCESS_TOKEN ,access_token_var=ACCESS_TOKEN
,grant_type=sas_services ,grant_type=sas_services
,mdebug=0
); );
%local dbg;
%if &mdebug=1 %then %do;
%put &sysmacroname entry vars:;
%put _local_;
%end;
%else %let dbg=*;
%local oauth_bearer; %local oauth_bearer;
%if &grant_type=detect %then %do; %if &grant_type=detect %then %do;
%if %symexist(&access_token_var) %then %let grant_type=authorization_code; %if %symexist(&access_token_var) %then %let grant_type=authorization_code;
%else %let grant_type=sas_services; %else %let grant_type=sas_services;
%end; %end;
%if &grant_type=sas_services %then %do; %if &grant_type=sas_services %then %do;
%let oauth_bearer=oauth_bearer=sas_services; %let oauth_bearer=oauth_bearer=sas_services;
%let &access_token_var=; %let &access_token_var=;
%end; %end;
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password %mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
@@ -12979,6 +12995,15 @@ options noquotelenmax;
,mac=&sysmacroname ,mac=&sysmacroname
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE) ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
) )
%if &mdebug=1 %then %do;
%put &sysmacroname following check to see if &newpath exists:;
%put _local_;
data _null_;
set &fname1;
input;
putlog _infile_;
run;
%end;
%if &SYS_PROCHTTP_STATUS_CODE=200 %then %do; %if &SYS_PROCHTTP_STATUS_CODE=200 %then %do;
%*put &sysmacroname &newpath exists so grab the follow on link ; %*put &sysmacroname &newpath exists so grab the follow on link ;
data _null_; data _null_;
@@ -13028,8 +13053,10 @@ options noquotelenmax;
%put &sysmacroname &newpath now created. Grabbing the follow on link ; %put &sysmacroname &newpath now created. Grabbing the follow on link ;
data _null_; data _null_;
set &libref2..links; set &libref2..links;
if rel='createChild' then if rel='createChild' then do;
call symputx('href',quote(cats("&base_uri",href)),'l'); call symputx('href',quote(cats("&base_uri",href)),'l');
&dbg put (_all_)(=);
end;
run; run;
libname &libref2 clear; libname &libref2 clear;

View File

@@ -22,7 +22,7 @@ Usage:
%webout(OBJ,example2) * Object format, easier to work with ; %webout(OBJ,example2) * Object format, easier to work with ;
%webout(CLOSE) %webout(CLOSE)
;;;; ;;;;
%mm_createwebservice(path=/Public/app/common,name=appInit) %mm_createwebservice(path=/Public/app/common,name=appInit,code=ft15f001)
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mm_createstp.sas @li mm_createstp.sas
@@ -37,12 +37,15 @@ Usage:
@param desc= The description of the service (optional) @param desc= The description of the service (optional)
@param precode= Space separated list of filerefs, pointing to the code that @param precode= Space separated list of filerefs, pointing to the code that
needs to be attached to the beginning of the service (optional) needs to be attached to the beginning of the service (optional)
@param code= Space seperated fileref(s) of the actual code to be added @param code=(ft15f001) Space seperated fileref(s) of the actual code to be
@param server= The server which will run the STP. Server name or uri is fine. added
@param mDebug= set to 1 to show debug messages in the log @param server=(SASApp) The server which will run the STP. Server name or uri
@param replace= select YES to replace any existing service in that location is fine.
@param adapter= the macro uses the sasjs adapter by default. To use another @param mDebug=(0) set to 1 to show debug messages in the log
adapter, add a (different) fileref here. @param replace=(YES) select NO to avoid replacing an existing service in that
location
@param adapter=(sasjs) the macro uses the sasjs adapter by default. To use
another adapter, add a (different) fileref here.
@version 9.2 @version 9.2
@author Allan Bowe @author Allan Bowe
@@ -52,11 +55,11 @@ Usage:
%macro mm_createwebservice(path= %macro mm_createwebservice(path=
,name=initService ,name=initService
,precode= ,precode=
,code= ,code=ft15f001
,desc=This stp was created automagically by the mm_createwebservice macro ,desc=This stp was created automagically by the mm_createwebservice macro
,mDebug=0 ,mDebug=0
,server=SASApp ,server=SASApp
,replace=NO ,replace=YES
,adapter=sasjs ,adapter=sasjs
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
@@ -468,4 +471,4 @@ run;
%put &url?_PROGRAM=&path/&name; %put &url?_PROGRAM=&path/&name;
%put ;%put ;%put ;%put ;%put ;%put ; %put ;%put ;%put ;%put ;%put ;%put ;
%mend; %mend mm_createwebservice;

View File

@@ -1,17 +1,22 @@
/** /**
@file mv_createfolder.sas @file mv_createfolder.sas
@brief Creates a viya folder if that folder does not already exist @brief Creates a viya folder if that folder does not already exist
@details Expects oauth token in a global macro variable (default @details Creates a viya folder by checking if each parent folder exists, and
ACCESS_TOKEN). recursively creating children if needed.
Usage:
%mv_createfolder(path=/Public) %mv_createfolder(path=/Public)
@param path= The full path of the folder to be created @param [in] path= The full path of the folder to be created
@param access_token_var= The global macro variable to contain the access token @param [in] access_token_var= The global macro variable to contain the access
@param grant_type= (authorization_code) Valid values are "password" or token, if using authorization_code grant type.
"authorization_code" (unquoted). @param [in] grant_type= (sas_services) Valid values are:
@li password
@li authorization_code
@li sas_services
@param [in] mdebug=(0) set to 1 to enable DEBUG messages
@version VIYA V.03.04 @version VIYA V.03.04
@author Allan Bowe, source: https://github.com/sasjs/core @author Allan Bowe, source: https://github.com/sasjs/core
@@ -28,15 +33,23 @@
%macro mv_createfolder(path= %macro mv_createfolder(path=
,access_token_var=ACCESS_TOKEN ,access_token_var=ACCESS_TOKEN
,grant_type=sas_services ,grant_type=sas_services
,mdebug=0
); );
%local dbg;
%if &mdebug=1 %then %do;
%put &sysmacroname entry vars:;
%put _local_;
%end;
%else %let dbg=*;
%local oauth_bearer; %local oauth_bearer;
%if &grant_type=detect %then %do; %if &grant_type=detect %then %do;
%if %symexist(&access_token_var) %then %let grant_type=authorization_code; %if %symexist(&access_token_var) %then %let grant_type=authorization_code;
%else %let grant_type=sas_services; %else %let grant_type=sas_services;
%end; %end;
%if &grant_type=sas_services %then %do; %if &grant_type=sas_services %then %do;
%let oauth_bearer=oauth_bearer=sas_services; %let oauth_bearer=oauth_bearer=sas_services;
%let &access_token_var=; %let &access_token_var=;
%end; %end;
%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password %mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
@@ -91,6 +104,15 @@ options noquotelenmax;
,mac=&sysmacroname ,mac=&sysmacroname
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE) ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
) )
%if &mdebug=1 %then %do;
%put &sysmacroname following check to see if &newpath exists:;
%put _local_;
data _null_;
set &fname1;
input;
putlog _infile_;
run;
%end;
%if &SYS_PROCHTTP_STATUS_CODE=200 %then %do; %if &SYS_PROCHTTP_STATUS_CODE=200 %then %do;
%*put &sysmacroname &newpath exists so grab the follow on link ; %*put &sysmacroname &newpath exists so grab the follow on link ;
data _null_; data _null_;
@@ -140,8 +162,10 @@ options noquotelenmax;
%put &sysmacroname &newpath now created. Grabbing the follow on link ; %put &sysmacroname &newpath now created. Grabbing the follow on link ;
data _null_; data _null_;
set &libref2..links; set &libref2..links;
if rel='createChild' then if rel='createChild' then do;
call symputx('href',quote(cats("&base_uri",href)),'l'); call symputx('href',quote(cats("&base_uri",href)),'l');
&dbg put (_all_)(=);
end;
run; run;
libname &libref2 clear; libname &libref2 clear;