mirror of
https://github.com/sasjs/core.git
synced 2026-01-03 15:40:05 +00:00
Compare commits
1 Commits
7c2b7dca1f
...
viyafixes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aef9a6325b |
56
all.sas
56
all.sas
@@ -24172,13 +24172,13 @@ run;
|
|||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Returns the uri of a file or folder
|
@brief Returns the uri of a file or folder
|
||||||
@details The automatic variable _FILESRVC_[fref]_URI is used after assigning
|
@details The automatic variable `_FILESRVC_[fref]_URI` is used after assigning
|
||||||
a fileref using the filesrvc engine.
|
a fileref using the filesrvc engine.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
%put %mfv_existfile(/Public/folder/file.txt);
|
%put %mfv_getpathuri(/Public/folder/file.txt);
|
||||||
%put %mfv_existfile(/Public/folder);
|
%put %mfv_getpathuri(/Public/folder);
|
||||||
|
|
||||||
@param [in] filepath The full path to the file on SAS drive
|
@param [in] filepath The full path to the file on SAS drive
|
||||||
(eg /Public/myfile.txt)
|
(eg /Public/myfile.txt)
|
||||||
@@ -24258,6 +24258,8 @@ run;
|
|||||||
@li password
|
@li password
|
||||||
@li authorization_code
|
@li authorization_code
|
||||||
@li sas_services
|
@li sas_services
|
||||||
|
@param [in] force= (YES) Will overwrite (delete / recreate) files by default.
|
||||||
|
Set to NO to abort if a file already exists in that location.
|
||||||
@param [out] outds= (_null_) Output dataset with the uri of the new file
|
@param [out] outds= (_null_) Output dataset with the uri of the new file
|
||||||
|
|
||||||
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
@@ -24268,6 +24270,7 @@ run;
|
|||||||
@li mf_getuniquename.sas
|
@li mf_getuniquename.sas
|
||||||
@li mf_isblank.sas
|
@li mf_isblank.sas
|
||||||
@li mf_mimetype.sas
|
@li mf_mimetype.sas
|
||||||
|
@li mfv_getpathuri.sas
|
||||||
@li mp_abort.sas
|
@li mp_abort.sas
|
||||||
@li mp_base64copy.sas
|
@li mp_base64copy.sas
|
||||||
@li mv_createfolder.sas
|
@li mv_createfolder.sas
|
||||||
@@ -24287,6 +24290,7 @@ run;
|
|||||||
,grant_type=sas_services
|
,grant_type=sas_services
|
||||||
,mdebug=0
|
,mdebug=0
|
||||||
,outds=_null_
|
,outds=_null_
|
||||||
|
,force=YES
|
||||||
);
|
);
|
||||||
%local dbg;
|
%local dbg;
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
@@ -24308,16 +24312,16 @@ run;
|
|||||||
%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
|
||||||
and &grant_type ne sas_services
|
and &grant_type ne sas_services
|
||||||
)
|
)
|
||||||
,mac=&sysmacroname
|
,mac=MV_CREATEFILE
|
||||||
,msg=%str(Invalid value for grant_type: &grant_type)
|
,msg=%str(Invalid value for grant_type: &grant_type)
|
||||||
)
|
)
|
||||||
|
|
||||||
%mp_abort(iftrue=(%mf_isblank(&path)=1 or %length(&path)=1)
|
%mp_abort(iftrue=(%mf_isblank(&path)=1 or %length(&path)=1)
|
||||||
,mac=&sysmacroname
|
,mac=MV_CREATEFILE
|
||||||
,msg=%str(path value must be provided)
|
,msg=%str(path value must be provided)
|
||||||
)
|
)
|
||||||
%mp_abort(iftrue=(%mf_isblank(&name)=1 or %length(&name)=1)
|
%mp_abort(iftrue=(%mf_isblank(&name)=1 or %length(&name)=1)
|
||||||
,mac=&sysmacroname
|
,mac=MV_CREATEFILE
|
||||||
,msg=%str(name value with length >1 must be provided)
|
,msg=%str(name value with length >1 must be provided)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24340,9 +24344,12 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
options noquotelenmax;
|
||||||
|
%local base_uri; /* location of rest apis */
|
||||||
|
%let base_uri=%mf_getplatform(VIYARESTAPI);
|
||||||
|
|
||||||
/* create folder if it does not already exist */
|
/* create folder if it does not already exist */
|
||||||
%local folderds parenturi;
|
%local folderds self_uri;
|
||||||
%let folderds=%mf_getuniquename(prefix=folderds);
|
%let folderds=%mf_getuniquename(prefix=folderds);
|
||||||
%mv_createfolder(path=&path
|
%mv_createfolder(path=&path
|
||||||
,access_token_var=&access_token_var
|
,access_token_var=&access_token_var
|
||||||
@@ -24355,10 +24362,26 @@ data _null_;
|
|||||||
call symputx('self_uri',self_uri,'l');
|
call symputx('self_uri',self_uri,'l');
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
/* abort or delete if file already exists */
|
||||||
|
%let force=%upcase(&force);
|
||||||
|
%local fileuri ;
|
||||||
|
%let fileuri=%mfv_getpathuri(&path/&name);
|
||||||
|
%mp_abort(iftrue=(%mf_isblank(&fileuri)=0 and &force ne YES)
|
||||||
|
,mac=MV_CREATEFILE
|
||||||
|
,msg=%str(File &path/&name already exists and force=&force)
|
||||||
|
)
|
||||||
|
|
||||||
options noquotelenmax;
|
%if %mf_isblank(&fileuri)=0 and &force=YES %then %do;
|
||||||
%local base_uri; /* location of rest apis */
|
proc http method="DELETE" url="&base_uri&fileuri" &oauth_bearer;
|
||||||
%let base_uri=%mf_getplatform(VIYARESTAPI);
|
headers
|
||||||
|
%if &grant_type=authorization_code %then %do;
|
||||||
|
"Authorization"="Bearer &&&access_token_var"
|
||||||
|
%end;
|
||||||
|
"Accept"="*/*";
|
||||||
|
run;
|
||||||
|
%put &sysmacroname DELETE &base_uri&fileuri
|
||||||
|
&=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||||
|
%end;
|
||||||
|
|
||||||
%local url mimetype;
|
%local url mimetype;
|
||||||
%let url=&base_uri/files/files?parentFolderUri=&self_uri;
|
%let url=&base_uri/files/files?parentFolderUri=&self_uri;
|
||||||
@@ -24374,7 +24397,8 @@ proc http method='POST' out=&fname1 &oauth_bearer in=&fref
|
|||||||
%else %do;
|
%else %do;
|
||||||
ct="&ctype"
|
ct="&ctype"
|
||||||
%end;
|
%end;
|
||||||
%if "&mimetype"="text/html" %then %do;
|
%if "&mimetype"="text/html" or "&mimetype"="text/css"
|
||||||
|
or "&mimetype"="text/javascript" %then %do;
|
||||||
url="&url%str(&)typeDefName=file";
|
url="&url%str(&)typeDefName=file";
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
@@ -24387,10 +24411,10 @@ proc http method='POST' out=&fname1 &oauth_bearer in=&fref
|
|||||||
%end;
|
%end;
|
||||||
"Content-Disposition"= "&contentdisp filename=""&name""; name=""&name"";";
|
"Content-Disposition"= "&contentdisp filename=""&name""; name=""&name"";";
|
||||||
run;
|
run;
|
||||||
%put &=SYS_PROCHTTP_STATUS_CODE;
|
%put &sysmacroname POST &=url
|
||||||
%put &=SYS_PROCHTTP_STATUS_PHRASE;
|
&=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
||||||
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 201)
|
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||||
,mac=&sysmacroname
|
,mac=MV_CREATEFILE
|
||||||
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
||||||
)
|
)
|
||||||
%local libref2;
|
%local libref2;
|
||||||
@@ -26230,8 +26254,8 @@ filename &fname1a clear;
|
|||||||
libname &libref1a clear;
|
libname &libref1a clear;
|
||||||
|
|
||||||
%mend mv_deletejes;/**
|
%mend mv_deletejes;/**
|
||||||
@file mv_deleteviyafolder.sas
|
@file
|
||||||
@brief Creates a viya folder if that folder does not already exist
|
@brief Deletes a viya folder
|
||||||
@details If not running in Studo 5 +, will expect an oauth token in a global
|
@details If not running in Studo 5 +, will expect an oauth token in a global
|
||||||
macro variable (default ACCESS_TOKEN).
|
macro variable (default ACCESS_TOKEN).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user