Spectrum API to handle users and user group
search cancel

Spectrum API to handle users and user group

book

Article ID: 235162

calendar_today

Updated On:

Products

CA Spectrum

Issue/Introduction

Some Restful API to handle Spectrum users and user group.

Environment

All supported releases

Resolution

1) How to get the model_handle of a specific User Group

HTTP method: POST
URL: http://<OC_server>:<port>/spectrum/restful/models
BODY: Application/xml

<?xml version="1.0" encoding="UTF-8"?> 
<rs:model-request throttlesize="5" 
xmlns:rs="http://www.ca.com/spectrum/restful/schema/request" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd "> 
<rs:target-models>
  <rs:models-search>
   <rs:search-criteria xmlns="http://www.ca.com/spectrum/restful/schema/filter">
    <filtered-models>
     <and>
      <equals>
       <attribute id="AttributeID.MTYPE_HANDLE">
        <value>0x1040a</value>  <!-- UserGroup -->
       </attribute>
      </equals>
      <equals>
       <attribute id="0x1006e">  <!-- Model_Name -->
        <value><UserGroup></value>
       </attribute>
      </equals>
     </and>
    </filtered-models>
   </rs:search-criteria>
  </rs:models-search>
 </rs:target-models>
 </rs:model-request>


where <UserGroup> is your user group name 

2) How to get the list of users currently defined

HTTP method: POST
URL: http://<OC_server>:<port>/spectrum/restful/models
BODY: Application/xml

<?xml version="1.0" encoding="UTF-8"?> 
<rs:model-request throttlesize="5" 
xmlns:rs="http://www.ca.com/spectrum/restful/schema/request" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd "> 
<rs:target-models> 
 <rs:models-search> 
  <rs:search-criteria xmlns="http://www.ca.com/spectrum/restful/schema/filter"> 
   <filtered-models> 
      <equals> 
           <attribute id="AttributeID.MTYPE_HANDLE"> 
                 <value>0x10004</value> <!-- USER --> 
           </attribute> 
      </equals> 
   </filtered-models> 
  </rs:search-criteria> 
 </rs:models-search> 
</rs:target-models> 
<rs:requested-attribute id="0x1006e" /> <!-- model name -->
</rs:model-request>

3) How to get the list of users that belong to a specific user group

HTTP method: POST
URL: http://<OC_server>:<port>/spectrum/restful/models
BODY: Application/xml

<?xml version="1.0" encoding="UTF-8"?>
<rs:model-request throttlesize="5"
  xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd">
    <rs:target-models>
      <rs:models-search>
        <rs:search-criteria xmlns="http://www.ca.com/spectrum/restful/schema/filter">    
   <child-models>
   <filtered-models>
     <and>
      <equals>
        <model-type>0x1040a</model-type>  <!-- User Group -->
      </equals>
      <has-substring-ignore-case>
         <attribute id="AttributeID.MODEL_NAME">
           <value><UserGroup></value> <!-- Group ModelName -->
         </attribute>
      </has-substring-ignore-case>
     </and>
   </filtered-models>
     <relation>0x10022</relation> <!-- Has_member relation-->
                               </child-models>
        </rs:search-criteria>     
      </rs:models-search>
    </rs:target-models>
    <rs:requested-attribute id="0x1006e" />
</rs:model-request>

Where where <UserGroup> is your user group name

4) How to get the User Group a specific userid belongs

HTTP method: POST
URL: http://<OC_server>:<port>/spectrum/restful/models
BODY: Application/xml

<?xml version="1.0" encoding="UTF-8"?>
<rs:model-request throttlesize="5"
  xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd">
    <rs:target-models>
      <rs:models-search>
        <rs:search-criteria xmlns="http://www.ca.com/spectrum/restful/schema/filter">    
   <parent-models>
   <filtered-models>
     <and>
      <equals>
        <model-type>0x10004</model-type>  <!-- User model type -->
      </equals>
      <has-substring-ignore-case>
         <attribute id="AttributeID.MODEL_NAME">
           <value><user_name></value> <!-- User ModelName -->
         </attribute>
      </has-substring-ignore-case>
     </and>
   </filtered-models>
     <relation>0x10022</relation> <!-- Has_member relation-->
                               </parent-models>
        </rs:search-criteria>     
      </rs:models-search>
    </rs:target-models>
    <rs:requested-attribute id="0x1006e" />
</rs:model-request>

where <user_name> is the user name you want to get its user group.

5) How to get the list of groups defined in a specific landscape

HTTP method: POST
URL: http://<OC_server>:<port>/spectrum/restful/models
BODY: Application/xml

<?xml version="1.0" encoding="UTF-8"?> 
<rs:model-request throttlesize="5" 
xmlns:rs="http://www.ca.com/spectrum/restful/schema/request" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd "> 
<rs:landscape id="<landscape_handle>" /> 
<rs:target-models> 
 <rs:models-search> 
  <rs:search-criteria xmlns="http://www.ca.com/spectrum/restful/schema/filter"> 
   <filtered-models> 
      <equals> 
           <attribute id="AttributeID.MTYPE_HANDLE"> 
                 <value>0x1040a</value> <!-- UserGroup --> 
           </attribute> 
      </equals> 
   </filtered-models> 
  </rs:search-criteria> 
 </rs:models-search> 
</rs:target-models> 
<rs:requested-attribute id="0x1006e" /> <!-- model name -->
</rs:model-request>

Where <landscape_handle> is the landscape handle you want to search your UserGroups. You can specify more than one landscape id if necessary eg.
<rs:landscape id="0x14000000" /> 
<rs:landscape id="0x1000000" />