@sasjs/core 7.1.13 → 7.1.14
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/package.json +1 -1
- package/viya/mv_getfoldermembers.sas +95 -18
- package/viya/mv_getgroupmembers.sas +41 -11
- package/viya/mv_getusergroups.sas +22 -1
package/package.json
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
%mv_getfoldermembers(root=/Public, outds=work.mymembers)
|
|
8
8
|
|
|
9
|
+
A root with nothing to list - an empty folder, or an answer that carries no
|
|
10
|
+
members link - still yields &outds, with the documented columns and zero rows.
|
|
11
|
+
|
|
9
12
|
|
|
10
13
|
@param [in] root= (/) The path for which to return the list of folders
|
|
11
14
|
@param [out] outds= (work.mv_getfolders) The output dataset to create. Format:
|
|
@@ -83,9 +86,41 @@ options noquotelenmax;
|
|
|
83
86
|
%end;
|
|
84
87
|
run;
|
|
85
88
|
libname &libref1 JSON fileref=&fname1;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
/* an empty collection produces no items dataset at all, so a straight SET
|
|
90
|
+
would fail with "File ...ITEMS.DATA does not exist" and leave syscc dirty */
|
|
91
|
+
%if %sysfunc(exist(&libref1..items))=1 %then %do;
|
|
92
|
+
data &outds;
|
|
93
|
+
/* the documented columns are declared on every path, so a caller reads
|
|
94
|
+
the same columns whether the collection is empty or full - an empty
|
|
95
|
+
collection's items dataset carries a narrower shape (no createdBy,
|
|
96
|
+
no timestamps) than a populated one. The declared lengths are at
|
|
97
|
+
least the engine's own, which are sized to the payload */
|
|
98
|
+
length ordinal_root 8 ordinal_items 8
|
|
99
|
+
creationTimeStamp $32 modifiedTimeStamp $32
|
|
100
|
+
createdBy $64 modifiedBy $64
|
|
101
|
+
id $36 uri $512 added $32 type $32
|
|
102
|
+
name $256 description $256;
|
|
103
|
+
/* initialise the declared columns - an empty collection's items
|
|
104
|
+
dataset carries none of the member columns, and referencing one that
|
|
105
|
+
the input does not supply raises "Variable x is uninitialized" */
|
|
106
|
+
call missing(of _all_);
|
|
107
|
+
set &libref1..items;
|
|
108
|
+
/* the engine emits one all-missing row for an empty collection */
|
|
109
|
+
if missing(name) and missing(uri) then delete;
|
|
110
|
+
run;
|
|
111
|
+
%end;
|
|
112
|
+
%else %do;
|
|
113
|
+
%put NOTE: &sysmacroname - no root folders found;
|
|
114
|
+
data &outds;
|
|
115
|
+
length ordinal_root 8 ordinal_items 8
|
|
116
|
+
creationTimeStamp $32 modifiedTimeStamp $32
|
|
117
|
+
createdBy $64 modifiedBy $64
|
|
118
|
+
id $36 uri $512 added $32 type $32
|
|
119
|
+
name $256 description $256;
|
|
120
|
+
call missing(of _all_);
|
|
121
|
+
stop;
|
|
122
|
+
run;
|
|
123
|
+
%end;
|
|
89
124
|
%end;
|
|
90
125
|
%else %do;
|
|
91
126
|
/* first get parent folder id */
|
|
@@ -100,18 +135,35 @@ options noquotelenmax;
|
|
|
100
135
|
/* now get the followon link to list members */
|
|
101
136
|
%local href cnt;
|
|
102
137
|
%let cnt=0;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
138
|
+
/* a root that is not a folder (a member path, for instance) answers
|
|
139
|
+
without a links dataset, so a straight SET would leave syscc dirty */
|
|
140
|
+
%if %sysfunc(exist(&libref1..links))=1 %then %do;
|
|
141
|
+
data _null_;
|
|
142
|
+
length rel href $512;
|
|
143
|
+
call missing(rel,href);
|
|
144
|
+
set &libref1..links;
|
|
145
|
+
if rel='members' then do;
|
|
146
|
+
url=cats("'","&base_uri",href,"?limit=10000'");
|
|
147
|
+
call symputx('href',url,'l');
|
|
148
|
+
call symputx('cnt',1,'l');
|
|
149
|
+
end;
|
|
150
|
+
run;
|
|
151
|
+
%end;
|
|
113
152
|
%if &cnt=0 %then %do;
|
|
114
153
|
%put NOTE:;%put NOTE- No members found in &root!!;%put NOTE-;
|
|
154
|
+
/* the folder answered without a members link, so there is nothing to list -
|
|
155
|
+
the output dataset is still created, with the documented columns */
|
|
156
|
+
data &outds;
|
|
157
|
+
length ordinal_root 8 ordinal_items 8
|
|
158
|
+
creationTimeStamp $32 modifiedTimeStamp $32
|
|
159
|
+
createdBy $64 modifiedBy $64
|
|
160
|
+
id $36 uri $512 added $32 type $32
|
|
161
|
+
name $256 description $256;
|
|
162
|
+
call missing(of _all_);
|
|
163
|
+
stop;
|
|
164
|
+
run;
|
|
165
|
+
filename &fname1 clear;
|
|
166
|
+
libname &libref1 clear;
|
|
115
167
|
%return;
|
|
116
168
|
%end;
|
|
117
169
|
%local fname2 libref2;
|
|
@@ -124,11 +176,36 @@ options noquotelenmax;
|
|
|
124
176
|
%end;
|
|
125
177
|
run;
|
|
126
178
|
libname &libref2 JSON fileref=&fname2;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
179
|
+
/* an emptied folder produces no items dataset at all, so a straight SET would
|
|
180
|
+
fail with "File ...ITEMS.DATA does not exist" and leave syscc dirty */
|
|
181
|
+
%if %sysfunc(exist(&libref2..items))=1 %then %do;
|
|
182
|
+
data &outds;
|
|
183
|
+
length ordinal_root 8 ordinal_items 8
|
|
184
|
+
creationTimeStamp $32 modifiedTimeStamp $32
|
|
185
|
+
createdBy $64 modifiedBy $64
|
|
186
|
+
id $36 uri $512 added $32 type $32
|
|
187
|
+
name $256 description $256;
|
|
188
|
+
/* initialise the declared columns - an empty collection's items
|
|
189
|
+
dataset carries none of the member columns, and referencing one that
|
|
190
|
+
the input does not supply raises "Variable x is uninitialized" */
|
|
191
|
+
call missing(of _all_);
|
|
192
|
+
set &libref2..items;
|
|
193
|
+
/* the engine emits one all-missing row for an empty collection */
|
|
194
|
+
if missing(name) and missing(uri) then delete;
|
|
195
|
+
run;
|
|
196
|
+
%end;
|
|
197
|
+
%else %do;
|
|
198
|
+
%put NOTE: &sysmacroname - &root is empty;
|
|
199
|
+
data &outds;
|
|
200
|
+
length ordinal_root 8 ordinal_items 8
|
|
201
|
+
creationTimeStamp $32 modifiedTimeStamp $32
|
|
202
|
+
createdBy $64 modifiedBy $64
|
|
203
|
+
id $36 uri $512 added $32 type $32
|
|
204
|
+
name $256 description $256;
|
|
205
|
+
call missing(of _all_);
|
|
206
|
+
stop;
|
|
207
|
+
run;
|
|
208
|
+
%end;
|
|
132
209
|
filename &fname2 clear;
|
|
133
210
|
libname &libref2 clear;
|
|
134
211
|
%end;
|
|
@@ -20,8 +20,15 @@
|
|
|
20
20
|
version num,
|
|
21
21
|
id char(256),
|
|
22
22
|
name char(256),
|
|
23
|
-
providerId char(
|
|
24
|
-
implicit num
|
|
23
|
+
providerId char(32),
|
|
24
|
+
implicit num,
|
|
25
|
+
type char(32)
|
|
26
|
+
|
|
27
|
+
`type` is the member type (user or group) and is declared on every path.
|
|
28
|
+
`implicit` is declared so a caller reading it does not fail with "Variable
|
|
29
|
+
implicit not found", but the identities API returns no such field, so the
|
|
30
|
+
column is present and always missing. A group with no members, and a group
|
|
31
|
+
id the server does not know, both return the columns above with zero rows.
|
|
25
32
|
|
|
26
33
|
@param [in] group Group id for which to return group members
|
|
27
34
|
@param [in] access_token_var= (ACCESS_TOKEN)
|
|
@@ -44,6 +51,7 @@
|
|
|
44
51
|
@li mf_getplatform.sas
|
|
45
52
|
@li mf_getuniquefileref.sas
|
|
46
53
|
@li mf_getuniquelibref.sas
|
|
54
|
+
@li mf_existvar.sas
|
|
47
55
|
|
|
48
56
|
**/
|
|
49
57
|
|
|
@@ -88,9 +96,13 @@ run;
|
|
|
88
96
|
/*data _null_;infile &fname1;input;putlog _infile_;run;*/
|
|
89
97
|
%if &SYS_PROCHTTP_STATUS_CODE=404 %then %do;
|
|
90
98
|
%put NOTE: Group &group not found!!;
|
|
99
|
+
/* the same documented columns and zero rows as a group with no members -
|
|
100
|
+
call missing alone would output one all-missing observation */
|
|
91
101
|
data &outds;
|
|
92
|
-
length
|
|
102
|
+
length ordinal_root 8 ordinal_items 8 version 8
|
|
103
|
+
id $256 name $256 providerId $32 implicit 8 type $32;
|
|
93
104
|
call missing(of _all_);
|
|
105
|
+
stop;
|
|
94
106
|
run;
|
|
95
107
|
%end;
|
|
96
108
|
%else %do;
|
|
@@ -100,15 +112,33 @@ run;
|
|
|
100
112
|
)
|
|
101
113
|
%let libref1=%mf_getuniquelibref();
|
|
102
114
|
libname &libref1 JSON fileref=&fname1;
|
|
103
|
-
/*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
/* a group with no members returns a collection whose items dataset carries no
|
|
116
|
+
member columns, so a straight SET would raise "Variable id is uninitialized"
|
|
117
|
+
and leave syscc dirty. Only copy when there is something to copy. The
|
|
118
|
+
documented columns are declared on both paths, so an empty group hands the
|
|
119
|
+
caller the same PDV as a populated one. The lengths are declared because
|
|
120
|
+
the JSON engine sizes its columns to the longest value in the payload:
|
|
121
|
+
$256 is the longest an active directory display name or SAM account name
|
|
122
|
+
can hold, and a shorter declaration lets the engine report "Multiple
|
|
123
|
+
lengths were specified" on a later member. */
|
|
124
|
+
%local itemsds hasvars;
|
|
125
|
+
%let itemsds=&libref1..items;
|
|
126
|
+
%let hasvars=0;
|
|
127
|
+
%if %sysfunc(exist(&itemsds))=1 %then %do;
|
|
128
|
+
%if %mf_existvar(&itemsds,id)>0 %then %let hasvars=1;
|
|
129
|
+
%end;
|
|
109
130
|
data &outds;
|
|
110
|
-
length
|
|
111
|
-
|
|
131
|
+
length ordinal_root 8 ordinal_items 8 version 8
|
|
132
|
+
id $256 name $256 providerId $32 implicit 8 type $32;
|
|
133
|
+
call missing(of _all_);
|
|
134
|
+
%if &hasvars=1 %then %do;
|
|
135
|
+
set &itemsds;
|
|
136
|
+
/* the engine emits one all-missing row for an empty collection */
|
|
137
|
+
if missing(id) then delete;
|
|
138
|
+
%end;
|
|
139
|
+
%else %do;
|
|
140
|
+
stop;
|
|
141
|
+
%end;
|
|
112
142
|
run;
|
|
113
143
|
libname &libref1 clear;
|
|
114
144
|
%end;
|
|
@@ -19,7 +19,12 @@
|
|
|
19
19
|
@param [in] grant_type= (sas_services)
|
|
20
20
|
Valid values are "password" or "authorization_code" (unquoted).
|
|
21
21
|
@param [out] outds= (work.mv_getusergroups)
|
|
22
|
-
The library.dataset to be created that contains the list of groups
|
|
22
|
+
The library.dataset to be created that contains the list of groups. Format:
|
|
23
|
+
|ordinal_root|ordinal_items|version|id|implicit|name|providerId|
|
|
24
|
+
|---|---|---|---|---|---|---|
|
|
25
|
+
|1|1|1|viyagroup18|0|SAS Viyagroup18|ldap|
|
|
26
|
+
|
|
27
|
+
A user the server does not know returns the columns above with zero rows.
|
|
23
28
|
|
|
24
29
|
|
|
25
30
|
@version VIYA V.03.04
|
|
@@ -73,8 +78,19 @@ proc http method='GET' out=&fname1 &oauth_bearer
|
|
|
73
78
|
"Accept"="application/json";
|
|
74
79
|
run;
|
|
75
80
|
/*data _null_;infile &fname1;input;putlog _infile_;run;*/
|
|
81
|
+
/* a 404 answers with a document that carries no items dataset, so the output
|
|
82
|
+
is written here instead, with the documented columns and zero rows, and the
|
|
83
|
+
JSON libref is never assigned */
|
|
76
84
|
%if &SYS_PROCHTTP_STATUS_CODE=404 %then %do;
|
|
77
85
|
%put NOTE: User &user not found!!;
|
|
86
|
+
data &outds;
|
|
87
|
+
length ordinal_root 8 ordinal_items 8 version 8
|
|
88
|
+
id $256 implicit 8 name $256 providerId $32;
|
|
89
|
+
call missing(of _all_);
|
|
90
|
+
stop;
|
|
91
|
+
run;
|
|
92
|
+
filename &fname1 clear;
|
|
93
|
+
%return;
|
|
78
94
|
%end;
|
|
79
95
|
%else %do;
|
|
80
96
|
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200)
|
|
@@ -84,7 +100,12 @@ run;
|
|
|
84
100
|
%end;
|
|
85
101
|
libname &libref1 JSON fileref=&fname1;
|
|
86
102
|
|
|
103
|
+
/* the documented columns are declared on both paths, so a caller reads the
|
|
104
|
+
same columns whether the user has memberships or is unknown. The lengths
|
|
105
|
+
are at least the engine's own, which are sized to the payload */
|
|
87
106
|
data &outds;
|
|
107
|
+
length ordinal_root 8 ordinal_items 8 version 8
|
|
108
|
+
id $256 implicit 8 name $256 providerId $32;
|
|
88
109
|
set &libref1..items;
|
|
89
110
|
run;
|
|
90
111
|
|