1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-16 13:00:05 +00:00

feat: filter for groups by user id in ms_getgroups

This commit is contained in:
Allan Bowe
2022-06-17 07:46:51 +00:00
parent 1eb6d8cec9
commit c8805db0b5
2 changed files with 24 additions and 8 deletions

16
all.sas
View File

@@ -20278,12 +20278,17 @@ filename &headref clear;
%ms_getgroups(outds=userlist) %ms_getgroups(outds=userlist)
With filter: With filter on username:
%ms_getgroups(outds=userlist, user=James) %ms_getgroups(outds=userlist, user=James)
With filter on userid:
%ms_getgroups(outds=userlist, uid=1)
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
@param [in] user= (0) Provide the username on which to filter @param [in] user= (0) Provide the username on which to filter
@param [in] uid= (0) Provide the userid on which to filter
@param [out] outds= (work.ms_getgroups) This output dataset will contain the @param [out] outds= (work.ms_getgroups) This output dataset will contain the
list of groups. Format: list of groups. Format:
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.| |NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
@@ -20306,6 +20311,7 @@ filename &headref clear;
%macro ms_getgroups( %macro ms_getgroups(
user=0, user=0,
uid=0,
outds=work.ms_getgroups, outds=work.ms_getgroups,
mdebug=0 mdebug=0
); );
@@ -20355,8 +20361,10 @@ run;
run; run;
%end; %end;
%if "&user"="0" %then %let url=/SASjsApi/group; %if "&user" ne "0" %then %let url=/SASjsApi/user/by/username/&user;
%else %let url=/SASjsApi/user/by/username/&user; %else %if "&uid" ne "0" %then %let url=/SASjsApi/user/&uid;
%else %let url=/SASjsApi/group;
proc http method='GET' headerin=&fref0 out=&fref1 proc http method='GET' headerin=&fref0 out=&fref1
url="&_sasjs_apiserverurl.&url"; url="&_sasjs_apiserverurl.&url";
@@ -20373,7 +20381,7 @@ run;
libname &libref JSON fileref=&fref1; libname &libref JSON fileref=&fref1;
%if "&user"="0" %then %do; %if "&user"="0" and "&uid"="0" %then %do;
data &outds; data &outds;
length NAME $32 DESCRIPTION $64. GROUPID 8; length NAME $32 DESCRIPTION $64. GROUPID 8;
if _n_=1 then call missing(of _all_); if _n_=1 then call missing(of _all_);

View File

@@ -9,12 +9,17 @@
%ms_getgroups(outds=userlist) %ms_getgroups(outds=userlist)
With filter: With filter on username:
%ms_getgroups(outds=userlist, user=James) %ms_getgroups(outds=userlist, user=James)
With filter on userid:
%ms_getgroups(outds=userlist, uid=1)
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
@param [in] user= (0) Provide the username on which to filter @param [in] user= (0) Provide the username on which to filter
@param [in] uid= (0) Provide the userid on which to filter
@param [out] outds= (work.ms_getgroups) This output dataset will contain the @param [out] outds= (work.ms_getgroups) This output dataset will contain the
list of groups. Format: list of groups. Format:
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.| |NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
@@ -37,6 +42,7 @@
%macro ms_getgroups( %macro ms_getgroups(
user=0, user=0,
uid=0,
outds=work.ms_getgroups, outds=work.ms_getgroups,
mdebug=0 mdebug=0
); );
@@ -86,8 +92,10 @@ run;
run; run;
%end; %end;
%if "&user"="0" %then %let url=/SASjsApi/group; %if "&user" ne "0" %then %let url=/SASjsApi/user/by/username/&user;
%else %let url=/SASjsApi/user/by/username/&user; %else %if "&uid" ne "0" %then %let url=/SASjsApi/user/&uid;
%else %let url=/SASjsApi/group;
proc http method='GET' headerin=&fref0 out=&fref1 proc http method='GET' headerin=&fref0 out=&fref1
url="&_sasjs_apiserverurl.&url"; url="&_sasjs_apiserverurl.&url";
@@ -104,7 +112,7 @@ run;
libname &libref JSON fileref=&fref1; libname &libref JSON fileref=&fref1;
%if "&user"="0" %then %do; %if "&user"="0" and "&uid"="0" %then %do;
data &outds; data &outds;
length NAME $32 DESCRIPTION $64. GROUPID 8; length NAME $32 DESCRIPTION $64. GROUPID 8;
if _n_=1 then call missing(of _all_); if _n_=1 then call missing(of _all_);