@sasjs/core 4.18.16 → 4.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/mp_jsonout.sas +1 -5
- package/meta/mm_createwebservice.sas +1 -5
- package/package.json +1 -1
- package/server/ms_createfile.sas +4 -1
- package/server/ms_createuser.sas +144 -0
- package/server/ms_deletefile.sas +14 -1
- package/server/ms_getfile.sas +14 -5
- package/server/ms_getusers.sas +107 -0
- package/server/ms_runstp.sas +3 -3
- package/viya/mv_createwebservice.sas +1 -5
package/base/mp_jsonout.sas
CHANGED
|
@@ -199,11 +199,7 @@
|
|
|
199
199
|
format _numeric_ bart.;
|
|
200
200
|
%do i=1 %to &numcols;
|
|
201
201
|
%if &&typelong&i=char or &fmt=Y %then %do;
|
|
202
|
-
if
|
|
203
|
-
'm/\"|\x0A|\x0D|\x09|\x00|\x0E|\x0F|\x01|\x02|\x10|\x11|\\/o',
|
|
204
|
-
&&name&i
|
|
205
|
-
)>0
|
|
206
|
-
then do;
|
|
202
|
+
if findc(&&name&i,'"\'!!'0A0D09000E0F01021011'x) then do;
|
|
207
203
|
&&name&i='"'!!trim(
|
|
208
204
|
prxchange('s/"/\\"/',-1, /* double quote */
|
|
209
205
|
prxchange('s/\x0A/\n/',-1, /* new line */
|
|
@@ -232,11 +232,7 @@ data _null_;
|
|
|
232
232
|
put ' format _numeric_ bart.; ';
|
|
233
233
|
put ' %do i=1 %to &numcols; ';
|
|
234
234
|
put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
|
|
235
|
-
put ' if
|
|
236
|
-
put ' ''m/\"|\x0A|\x0D|\x09|\x00|\x0E|\x0F|\x01|\x02|\x10|\x11|\\/o'', ';
|
|
237
|
-
put ' &&name&i ';
|
|
238
|
-
put ' )>0 ';
|
|
239
|
-
put ' then do; ';
|
|
235
|
+
put ' if findc(&&name&i,''"\''!!''0A0D09000E0F01021011''x) then do; ';
|
|
240
236
|
put ' &&name&i=''"''!!trim( ';
|
|
241
237
|
put ' prxchange(''s/"/\\"/'',-1, /* double quote */ ';
|
|
242
238
|
put ' prxchange(''s/\x0A/\n/'',-1, /* new line */ ';
|
package/package.json
CHANGED
package/server/ms_createfile.sas
CHANGED
|
@@ -61,8 +61,11 @@ data _null_;
|
|
|
61
61
|
run;
|
|
62
62
|
|
|
63
63
|
data _null_;
|
|
64
|
-
file &fname1;
|
|
64
|
+
file &fname1 lrecl=1000;
|
|
65
|
+
infile "&_sasjs_tokenfile" lrecl=1000;
|
|
66
|
+
input;
|
|
65
67
|
put "Content-Type: multipart/form-data; boundary=&boundary";
|
|
68
|
+
put "Authorization: Bearer " _infile_;
|
|
66
69
|
run;
|
|
67
70
|
|
|
68
71
|
%if &mdebug=1 %then %do;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Creates a user on SASjs Server
|
|
4
|
+
@details Creates a user on SASjs Server with the following attributes:
|
|
5
|
+
|
|
6
|
+
@li UserName
|
|
7
|
+
@li Password
|
|
8
|
+
@li isAdmin
|
|
9
|
+
@li displayName
|
|
10
|
+
|
|
11
|
+
The userid is created by sasjs/server. All users are created with `isActive`
|
|
12
|
+
set to `true`.
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
|
|
16
|
+
%ms_createuser(newuser,secretpass,displayname=New User!)
|
|
17
|
+
|
|
18
|
+
@param [in] username The username to apply. No spaces or special characters.
|
|
19
|
+
@param [in] password The initial password to set.
|
|
20
|
+
@param [in] isadmin= (false) Set to true to give the user admin rights
|
|
21
|
+
@param [in] displayName= (0) Set a friendly name (spaces & special characters
|
|
22
|
+
are ok). If not provided, username will be used instead.
|
|
23
|
+
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
24
|
+
@param [out] outds= (work.ms_createuser) This output dataset will contain the
|
|
25
|
+
values from the JSON response (such as the id of the new user)
|
|
26
|
+
|ID:best.|DISPLAYNAME:$8.|USERNAME:$8.|ISACTIVE:best.|ISADMIN:best.|
|
|
27
|
+
|---|---|---|---|---|
|
|
28
|
+
|`6 `|`New User `|`newuser `|`1 `|`0 `|
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<h4> SAS Macros </h4>
|
|
33
|
+
@li mf_getuniquefileref.sas
|
|
34
|
+
@li mf_getuniquelibref.sas
|
|
35
|
+
@li mp_abort.sas
|
|
36
|
+
|
|
37
|
+
<h4> Related Files </h4>
|
|
38
|
+
@li ms_createuser.test.sas
|
|
39
|
+
@li ms_getusers.sas
|
|
40
|
+
|
|
41
|
+
**/
|
|
42
|
+
|
|
43
|
+
%macro ms_createuser(username,password
|
|
44
|
+
,isadmin=false
|
|
45
|
+
,displayname=0
|
|
46
|
+
,outds=work.ms_createuser
|
|
47
|
+
,mdebug=0
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
%mp_abort(
|
|
51
|
+
iftrue=(&syscc ne 0)
|
|
52
|
+
,mac=ms_createuser.sas
|
|
53
|
+
,msg=%str(syscc=&syscc on macro entry)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
%local fref0 fref1 fref2 libref optval rc msg;
|
|
57
|
+
%let fref0=%mf_getuniquefileref();
|
|
58
|
+
%let fref1=%mf_getuniquefileref();
|
|
59
|
+
%let fref2=%mf_getuniquefileref();
|
|
60
|
+
%let libref=%mf_getuniquelibref();
|
|
61
|
+
|
|
62
|
+
/* avoid sending bom marker to API */
|
|
63
|
+
%let optval=%sysfunc(getoption(bomfile));
|
|
64
|
+
options nobomfile;
|
|
65
|
+
|
|
66
|
+
data _null_;
|
|
67
|
+
file &fref0 termstr=crlf;
|
|
68
|
+
username=quote(cats(symget('username')));
|
|
69
|
+
password=quote(cats(symget('password')));
|
|
70
|
+
isadmin=symget('isadmin');
|
|
71
|
+
displayname=quote(cats(symget('displayname')));
|
|
72
|
+
if displayname='"0"' then displayname=username;
|
|
73
|
+
|
|
74
|
+
%if &mdebug=1 %then %do;
|
|
75
|
+
putlog _all_;
|
|
76
|
+
%end;
|
|
77
|
+
|
|
78
|
+
put '{'@;
|
|
79
|
+
put '"displayName":' displayname @;
|
|
80
|
+
put ',"username":' username @;
|
|
81
|
+
put ',"password":' password @;
|
|
82
|
+
put ',"isAdmin":' isadmin @;
|
|
83
|
+
put ',"isActive": true }';
|
|
84
|
+
run;
|
|
85
|
+
|
|
86
|
+
data _null_;
|
|
87
|
+
file &fref1 lrecl=1000;
|
|
88
|
+
infile "&_sasjs_tokenfile" lrecl=1000;
|
|
89
|
+
input;
|
|
90
|
+
put "Authorization: Bearer " _infile_;
|
|
91
|
+
put "Content-Type: application/json";
|
|
92
|
+
put "accept: application/json";
|
|
93
|
+
run;
|
|
94
|
+
|
|
95
|
+
%if &mdebug=1 %then %do;
|
|
96
|
+
data _null_;
|
|
97
|
+
infile &fref0;
|
|
98
|
+
input;
|
|
99
|
+
put _infile_;
|
|
100
|
+
data _null_;
|
|
101
|
+
infile &fref1;
|
|
102
|
+
input;
|
|
103
|
+
put _infile_;
|
|
104
|
+
run;
|
|
105
|
+
%end;
|
|
106
|
+
|
|
107
|
+
proc http method='POST' in=&fref0 headerin=&fref1 out=&fref2
|
|
108
|
+
url="&_sasjs_apiserverurl/SASjsApi/user";
|
|
109
|
+
%if &mdebug=1 %then %do;
|
|
110
|
+
debug level=1;
|
|
111
|
+
%end;
|
|
112
|
+
run;
|
|
113
|
+
|
|
114
|
+
%mp_abort(
|
|
115
|
+
iftrue=(&syscc ne 0)
|
|
116
|
+
,mac=ms_createuser.sas
|
|
117
|
+
,msg=%str(Issue submitting query to SASjsApi/user)
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
libname &libref JSON fileref=&fref2;
|
|
121
|
+
|
|
122
|
+
data &outds;
|
|
123
|
+
set &libref..root;
|
|
124
|
+
drop ordinal_root;
|
|
125
|
+
run;
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
%mp_abort(
|
|
129
|
+
iftrue=(&syscc ne 0)
|
|
130
|
+
,mac=ms_createuser.sas
|
|
131
|
+
,msg=%str(Issue reading response JSON)
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
/* reset options */
|
|
135
|
+
options &optval;
|
|
136
|
+
|
|
137
|
+
%if &mdebug=1 %then %do;
|
|
138
|
+
filename &fref0 clear;
|
|
139
|
+
filename &fref1 clear;
|
|
140
|
+
filename &fref2 clear;
|
|
141
|
+
libname &libref clear;
|
|
142
|
+
%end;
|
|
143
|
+
|
|
144
|
+
%mend ms_createuser;
|
package/server/ms_deletefile.sas
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
@param [in] driveloc The full path to the file in SASjs Drive
|
|
18
18
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
19
19
|
|
|
20
|
+
<h4> SAS Macros </h4>
|
|
21
|
+
@li mf_getuniquefileref.sas
|
|
20
22
|
|
|
21
23
|
**/
|
|
22
24
|
|
|
@@ -24,12 +26,23 @@
|
|
|
24
26
|
,mdebug=0
|
|
25
27
|
);
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
%local headref;
|
|
30
|
+
%let headref=%mf_getuniquefileref();
|
|
31
|
+
|
|
32
|
+
data _null_;
|
|
33
|
+
file &headref lrecl=1000;
|
|
34
|
+
infile "&_sasjs_tokenfile" lrecl=1000;
|
|
35
|
+
input;
|
|
36
|
+
put "Authorization: Bearer " _infile_;
|
|
37
|
+
run;
|
|
38
|
+
|
|
39
|
+
proc http method='DELETE' headerin=&headref
|
|
28
40
|
url="&_sasjs_apiserverurl/SASjsApi/drive/file?_filePath=&driveloc";
|
|
29
41
|
%if &mdebug=1 %then %do;
|
|
30
42
|
debug level=2;
|
|
31
43
|
%end;
|
|
32
44
|
run;
|
|
33
45
|
|
|
46
|
+
filename &headref clear;
|
|
34
47
|
|
|
35
48
|
%mend ms_deletefile;
|
package/server/ms_getfile.sas
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Example:
|
|
7
7
|
|
|
8
|
-
%ms_getfile(/
|
|
8
|
+
%ms_getfile(/Public/app/dc/services/public/settings.sas, outref=myfile)
|
|
9
9
|
|
|
10
10
|
@param [in] driveloc The full path to the file in SASjs Drive
|
|
11
11
|
@param [out] outref= (msgetfil) The fileref to contain the file.
|
|
@@ -23,13 +23,21 @@
|
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
/* use the recfm in a separate fileref to avoid issues with subsequent reads */
|
|
26
|
-
%local binaryfref floc;
|
|
26
|
+
%local binaryfref floc headref;
|
|
27
27
|
%let binaryfref=%mf_getuniquefileref();
|
|
28
|
+
%let headref=%mf_getuniquefileref();
|
|
28
29
|
%let floc=%sysfunc(pathname(work))/%mf_getuniquename().txt;
|
|
29
|
-
filename &outref "&floc";
|
|
30
|
+
filename &outref "&floc" lrecl=32767;
|
|
30
31
|
filename &binaryfref "&floc" recfm=n;
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
data _null_;
|
|
34
|
+
file &headref lrecl=1000;
|
|
35
|
+
infile "&_sasjs_tokenfile" lrecl=1000;
|
|
36
|
+
input;
|
|
37
|
+
put "Authorization: Bearer " _infile_;
|
|
38
|
+
run;
|
|
39
|
+
|
|
40
|
+
proc http method='GET' out=&binaryfref headerin=&headref
|
|
33
41
|
url="&_sasjs_apiserverurl/SASjsApi/drive/file?_filePath=&driveloc";
|
|
34
42
|
%if &mdebug=1 %then %do;
|
|
35
43
|
debug level=2;
|
|
@@ -37,5 +45,6 @@ proc http method='GET' out=&binaryfref
|
|
|
37
45
|
run;
|
|
38
46
|
|
|
39
47
|
filename &binaryfref clear;
|
|
48
|
+
filename &headref clear;
|
|
40
49
|
|
|
41
|
-
%mend ms_getfile;
|
|
50
|
+
%mend ms_getfile;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Fetches the list of users from SASjs Server
|
|
4
|
+
@details Fetches the list of users from SASjs Server and writes them to an
|
|
5
|
+
output dataset.
|
|
6
|
+
|
|
7
|
+
Example:
|
|
8
|
+
|
|
9
|
+
%ms_getusers(outds=userlist)
|
|
10
|
+
|
|
11
|
+
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
12
|
+
@param [out] outds= (work.ms_getusers) This output dataset will contain the
|
|
13
|
+
list of user accounts. Format:
|
|
14
|
+
|DISPLAYNAME:$18.|USERNAME:$10.|ID:best.|
|
|
15
|
+
|---|---|---|
|
|
16
|
+
|`Super Admin `|`secretuser `|`1`|
|
|
17
|
+
|`Sabir Hassan`|`sabir`|`2`|
|
|
18
|
+
|`Mihajlo Medjedovic `|`mihajlo `|`3`|
|
|
19
|
+
|`Ivor Townsend `|`ivor `|`4`|
|
|
20
|
+
|`New User `|`newuser `|`5`|
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<h4> SAS Macros </h4>
|
|
25
|
+
@li mf_getuniquefileref.sas
|
|
26
|
+
@li mf_getuniquelibref.sas
|
|
27
|
+
@li mp_abort.sas
|
|
28
|
+
|
|
29
|
+
<h4> Related Files </h4>
|
|
30
|
+
@li ms_createuser.sas
|
|
31
|
+
@li ms_getusers.test.sas
|
|
32
|
+
|
|
33
|
+
**/
|
|
34
|
+
|
|
35
|
+
%macro ms_getusers(
|
|
36
|
+
outds=work.ms_getusers
|
|
37
|
+
,mdebug=0
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
%mp_abort(
|
|
41
|
+
iftrue=(&syscc ne 0)
|
|
42
|
+
,mac=ms_getusers.sas
|
|
43
|
+
,msg=%str(syscc=&syscc on macro entry)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
%local fref0 fref1 libref optval rc msg;
|
|
47
|
+
%let fref0=%mf_getuniquefileref();
|
|
48
|
+
%let fref1=%mf_getuniquefileref();
|
|
49
|
+
%let libref=%mf_getuniquelibref();
|
|
50
|
+
|
|
51
|
+
/* avoid sending bom marker to API */
|
|
52
|
+
%let optval=%sysfunc(getoption(bomfile));
|
|
53
|
+
options nobomfile;
|
|
54
|
+
|
|
55
|
+
data _null_;
|
|
56
|
+
file &fref0 lrecl=1000;
|
|
57
|
+
infile "&_sasjs_tokenfile" lrecl=1000;
|
|
58
|
+
input;
|
|
59
|
+
put "Authorization: Bearer " _infile_;
|
|
60
|
+
put "accept: application/json";
|
|
61
|
+
run;
|
|
62
|
+
|
|
63
|
+
%if &mdebug=1 %then %do;
|
|
64
|
+
data _null_;
|
|
65
|
+
infile &fref0;
|
|
66
|
+
input;
|
|
67
|
+
put _infile_;
|
|
68
|
+
run;
|
|
69
|
+
%end;
|
|
70
|
+
|
|
71
|
+
proc http method='GET' headerin=&fref0 out=&fref1
|
|
72
|
+
url="&_sasjs_apiserverurl/SASjsApi/user";
|
|
73
|
+
%if &mdebug=1 %then %do;
|
|
74
|
+
debug level=1;
|
|
75
|
+
%end;
|
|
76
|
+
run;
|
|
77
|
+
|
|
78
|
+
%mp_abort(
|
|
79
|
+
iftrue=(&syscc ne 0)
|
|
80
|
+
,mac=ms_getusers.sas
|
|
81
|
+
,msg=%str(Issue submitting GET query to SASjsApi/user)
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
libname &libref JSON fileref=&fref1;
|
|
85
|
+
|
|
86
|
+
data &outds;
|
|
87
|
+
set &libref..root;
|
|
88
|
+
drop ordinal_root;
|
|
89
|
+
run;
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
%mp_abort(
|
|
93
|
+
iftrue=(&syscc ne 0)
|
|
94
|
+
,mac=ms_getusers.sas
|
|
95
|
+
,msg=%str(Issue reading response JSON)
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
/* reset options */
|
|
99
|
+
options &optval;
|
|
100
|
+
|
|
101
|
+
%if &mdebug=1 %then %do;
|
|
102
|
+
filename &fref0 clear;
|
|
103
|
+
filename &fref1 clear;
|
|
104
|
+
libname &libref clear;
|
|
105
|
+
%end;
|
|
106
|
+
|
|
107
|
+
%mend ms_getusers;
|
package/server/ms_runstp.sas
CHANGED
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
data _null_;
|
|
46
|
-
file &fname1;
|
|
47
|
-
infile "&_sasjs_tokenfile";
|
|
46
|
+
file &fname1 lrecl=1000;
|
|
47
|
+
infile "&_sasjs_tokenfile" lrecl=1000;
|
|
48
48
|
input;
|
|
49
|
-
put 'Authorization: Bearer' _infile_;
|
|
49
|
+
put 'Authorization: Bearer ' _infile_;
|
|
50
50
|
run;
|
|
51
51
|
|
|
52
52
|
filename &outref temp;
|
|
@@ -376,11 +376,7 @@ data _null_;
|
|
|
376
376
|
put ' format _numeric_ bart.; ';
|
|
377
377
|
put ' %do i=1 %to &numcols; ';
|
|
378
378
|
put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
|
|
379
|
-
put ' if
|
|
380
|
-
put ' ''m/\"|\x0A|\x0D|\x09|\x00|\x0E|\x0F|\x01|\x02|\x10|\x11|\\/o'', ';
|
|
381
|
-
put ' &&name&i ';
|
|
382
|
-
put ' )>0 ';
|
|
383
|
-
put ' then do; ';
|
|
379
|
+
put ' if findc(&&name&i,''"\''!!''0A0D09000E0F01021011''x) then do; ';
|
|
384
380
|
put ' &&name&i=''"''!!trim( ';
|
|
385
381
|
put ' prxchange(''s/"/\\"/'',-1, /* double quote */ ';
|
|
386
382
|
put ' prxchange(''s/\x0A/\n/'',-1, /* new line */ ';
|