@sasjs/core 4.49.1 → 4.50.1
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/xplatform/mx_getgroups.sas +98 -0
package/package.json
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Fetches all groups or the groups for a particular member
|
|
4
|
+
@details When building applications that run on multiple flavours of SAS, it
|
|
5
|
+
is convenient to use a single macro (like this one) to fetch the groups
|
|
6
|
+
regardless of the flavour of SAS being used
|
|
7
|
+
|
|
8
|
+
The alternative would be to compile a generic macro in target-specific
|
|
9
|
+
folders (SASVIYA, SAS9 and SASJS). This avoids compiling unnecessary macros
|
|
10
|
+
at the expense of a more complex sasjsconfig.json setup.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
14
|
+
@param [in] user= (0) Provide the username on which to filter
|
|
15
|
+
@param [in] uid= (0) Provide the userid on which to filter
|
|
16
|
+
@param [in] repo= (foundation) SAS9 only, choose the metadata repo to query
|
|
17
|
+
@param [in] access_token_var= (ACCESS_TOKEN) VIYA only.
|
|
18
|
+
The global macro variable to contain the access token
|
|
19
|
+
@param [in] grant_type= (sas_services) VIYA only.
|
|
20
|
+
Valid values are "password" or "authorization_code" (unquoted).
|
|
21
|
+
@param [out] outds= (work.mx_getgroups) This output dataset will contain the
|
|
22
|
+
list of groups. Format:
|
|
23
|
+
|GROUPNAME:$32.|GROUPDESC:$256.|GROUPURI:best.|
|
|
24
|
+
|---|---|---|
|
|
25
|
+
|`SomeGroup `|`A group `|`1`|
|
|
26
|
+
|`Another Group`|`this is a different group`|`2`|
|
|
27
|
+
|`admin`|`Administrators `|`3`|
|
|
28
|
+
|
|
29
|
+
<h4> SAS Macros </h4>
|
|
30
|
+
@li mf_getplatform.sas
|
|
31
|
+
@li mm_getgroups.sas
|
|
32
|
+
@li ms_getgroups.sas
|
|
33
|
+
@li mv_getgroups.sas
|
|
34
|
+
@li mv_getusergroups.sas
|
|
35
|
+
|
|
36
|
+
**/
|
|
37
|
+
|
|
38
|
+
%macro mx_getgroups(
|
|
39
|
+
mdebug=0,
|
|
40
|
+
user=0,
|
|
41
|
+
uid=0,
|
|
42
|
+
repo=foundation,
|
|
43
|
+
access_token_var=ACCESS_TOKEN,
|
|
44
|
+
grant_type=sas_services,
|
|
45
|
+
outds=work.mx_getgroups
|
|
46
|
+
)/*/STORE SOURCE*/;
|
|
47
|
+
%local platform name shortloc;
|
|
48
|
+
%let platform=%mf_getplatform();
|
|
49
|
+
|
|
50
|
+
%if &platform=SASJS %then %do;
|
|
51
|
+
%ms_getgroups(
|
|
52
|
+
user=&user,
|
|
53
|
+
uid=&uid,
|
|
54
|
+
outds=&outds,
|
|
55
|
+
mdebug=&mdebug
|
|
56
|
+
)
|
|
57
|
+
data &outds;
|
|
58
|
+
length groupuri groupname $32 groupdesc $128 ;
|
|
59
|
+
set &outds;
|
|
60
|
+
keep groupuri groupname groupdesc;
|
|
61
|
+
groupuri=cats(groupid);
|
|
62
|
+
groupname=name;
|
|
63
|
+
groupdesc=description;
|
|
64
|
+
run;
|
|
65
|
+
proc sort; by groupname; run;
|
|
66
|
+
%end;
|
|
67
|
+
%else %if &platform=SAS9 or &platform=SASMETA %then %do;
|
|
68
|
+
%if &user=0 %then %let user=;
|
|
69
|
+
%mm_getGroups(
|
|
70
|
+
user=&user
|
|
71
|
+
,outds=&outds
|
|
72
|
+
,repo=&repo
|
|
73
|
+
,mDebug=&mdebug
|
|
74
|
+
)
|
|
75
|
+
proc sort data=&outds; by groupname; run;
|
|
76
|
+
%end;
|
|
77
|
+
%else %if &platform=SASVIYA %then %do;
|
|
78
|
+
%if &user=0 %then %do;
|
|
79
|
+
%mv_getgroups(access_token_var=&access_token_var
|
|
80
|
+
,grant_type=&grant_type
|
|
81
|
+
,outds=&outds
|
|
82
|
+
)
|
|
83
|
+
%end;
|
|
84
|
+
%else %do;
|
|
85
|
+
%mv_getusergroups(&user
|
|
86
|
+
,outds=&outds
|
|
87
|
+
,access_token_var=&access_token_var
|
|
88
|
+
,grant_type=&grant_type
|
|
89
|
+
)
|
|
90
|
+
%end;
|
|
91
|
+
proc sort
|
|
92
|
+
data=&outds(rename=(id=groupuri name=groupname description=groupdesc))
|
|
93
|
+
out=&outds (keep=groupuri groupname groupdesc);
|
|
94
|
+
by groupname;
|
|
95
|
+
run;
|
|
96
|
+
%end;
|
|
97
|
+
|
|
98
|
+
%mend mx_getgroups;
|