<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Viya CLI - List rules, but filter by principal in SAS Viya</title>
    <link>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/899073#M2049</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the CLI to list rules that are applied to a certain principal. In het documentation&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/nl/sasadmincdc/v_044/calauthzgen/p1ed0i3sx9clbnn1vm5zzb7qbmt5.htm" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;we can see example code for listing all rules:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;sas-viya authorization list-rules&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But there doesn't seem to be an option to filter these results beforehand.&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Filtering after retrieving the full list of rules is also not possible&amp;nbsp;unfortunately because for some reason the results are returned in blocks of 50 rules (no option to change this). So something like:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;sas-viya -output json -yes-to-all authorization list-rules&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Does not return valid json. Instead it returns a&amp;nbsp;concatenation of multiple jsons, each with 50 items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Is there a way to either:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Apply a filter to the 'list-rules' command in the authorization plugin&lt;/LI&gt;&lt;LI&gt;Retrieve a list of ALL rules in a single json&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Wed, 18 Oct 2023 09:06:34 GMT</pubDate>
    <dc:creator>RobWanders1</dc:creator>
    <dc:date>2023-10-18T09:06:34Z</dc:date>
    <item>
      <title>Viya CLI - List rules, but filter by principal</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/899073#M2049</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the CLI to list rules that are applied to a certain principal. In het documentation&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/nl/sasadmincdc/v_044/calauthzgen/p1ed0i3sx9clbnn1vm5zzb7qbmt5.htm" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;we can see example code for listing all rules:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;sas-viya authorization list-rules&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But there doesn't seem to be an option to filter these results beforehand.&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Filtering after retrieving the full list of rules is also not possible&amp;nbsp;unfortunately because for some reason the results are returned in blocks of 50 rules (no option to change this). So something like:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;sas-viya -output json -yes-to-all authorization list-rules&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Does not return valid json. Instead it returns a&amp;nbsp;concatenation of multiple jsons, each with 50 items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Is there a way to either:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Apply a filter to the 'list-rules' command in the authorization plugin&lt;/LI&gt;&lt;LI&gt;Retrieve a list of ALL rules in a single json&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 18 Oct 2023 09:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/899073#M2049</guid>
      <dc:creator>RobWanders1</dc:creator>
      <dc:date>2023-10-18T09:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Viya CLI - List rules, but filter by principal</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/899097#M2050</link>
      <description>&lt;P&gt;There is currently no way to filter the rules using the sas-viya CLI. However you can write a SAS program to use the REST API, see below for an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
 * Use of the authorization REST API
 * return rules based on some filters
 * Doc is here
 * https://developer.sas.com/apis/rest/CoreServices/#get-authorization-rules
 */

/*
 * get the base url
 */
%let baseurl = %sysfunc(getoption(servicesbaseurl));
%put NOTE: &amp;amp;=baseurl;

/*
 * temp file for json resp
 */
filename resp temp;

/*
 * call the REST API
 */
proc http
  method=get
  url="&amp;amp;baseurl/authorization/rules"
  oauth_bearer=sas_services
  out=resp
  verbose

  /*
   * we use the QUERY= option to pass in parameters
   */
  query=(
    /*
     * filter allows to specify filter conditions for the returned items
     * some examples below
     */
    
/*     "filter" = 'gt(modifiedTimeStamp, "2022-05-10T00:00Z")' */
    "filter" = 'eq(principal, "SASAdministrators")'
/*     "filter" = 'ne(containerUri , " ")' */

    /*
     * typically REST API will only return part of the items
     * can use limit to specify how many should be returned
     * the response will contain count to indicate how many items
     * can be returned
     */
    "limit" = "10000"
  )
;
run;
%put NOTE: &amp;amp;=SYS_PROCHTTP_STATUS_CODE;
%put NOTE: &amp;amp;=SYS_PROCHTTP_STATUS_PHRASE;

/* 
 * only for small results
 */
/* %put NOTE: json response; */
/* %let dummy = %sysfunc(jsonpp(resp, log)); */

/*
 * convert JSON to SAS Datasets
 */
libname jsresp json fileref=resp noalldata;
proc copy in=jsresp out=work;
run;
libname jsresp clear;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Oct 2023 12:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/899097#M2050</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2023-10-18T12:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Viya CLI - List rules, but filter by principal</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/899104#M2051</link>
      <description>Alright, too bad it is not possible. But thanks for your solution!</description>
      <pubDate>Wed, 18 Oct 2023 12:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/899104#M2051</guid>
      <dc:creator>RobWanders1</dc:creator>
      <dc:date>2023-10-18T12:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Viya CLI - List rules, but filter by principal</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/899574#M2061</link>
      <description>Please also have a look at &lt;A href="https://github.com/sassoftware/pyviyatools/blob/master/listrules.py" target="_blank"&gt;https://github.com/sassoftware/pyviyatools/blob/master/listrules.py&lt;/A&gt; it will allow you to list all rules with a given principal</description>
      <pubDate>Sun, 22 Oct 2023 19:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/899574#M2061</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2023-10-22T19:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Viya CLI - List rules, but filter by principal</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/953501#M2688</link>
      <description>&lt;P&gt;--output &lt;STRONG&gt;fulljson&lt;/STRONG&gt; authorization list-rules&lt;/P&gt;
&lt;P&gt;, gives more information, my collegue told me today.&lt;/P&gt;
&lt;P&gt;If you redirect with &amp;gt; filename.json you have a lot of more output.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 11:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Viya-CLI-List-rules-but-filter-by-principal/m-p/953501#M2688</guid>
      <dc:creator>paterd2</dc:creator>
      <dc:date>2024-12-13T11:08:57Z</dc:date>
    </item>
  </channel>
</rss>

