Manage Spectrum users via RESTful API - examples

Document ID : KB000116305
Last Modified Date : 23/10/2018
Show Technical Document Details
Introduction:
I have a requirement to automatically manage my users/roles. Can this be leveraged through the REST API? 
Environment:
Platform Independent
Instructions:
The following are some Restful examples for managing Spectrum Users.

Create a user: 
http://<host:port>/spectrum/restful/model?landscapeid=<ls_handle>&mtypeid=0x10004&attr=0x1006e&val=<username> 

Delete the user: 
http://<host:port>/spectrum/restful/model/<user_model_handle> 

Associate user with a role: 
http://<host:port>/spectrum/restful/associations/relation/0x10031/leftmodel/<user_role>/rightmodel/<user_handle> 
0x10031 = user role association 

User roles: 
0x100016 Operator 0x10453 LicenseRole 
0x100015 Administrator 0x10453 LicenseRole 
0x100012 Service Manager 0x10453 LicenseRole 

Create user Group: 
http://<host:port>/spectrum/restful/model?landscapeid=<ls_handle>&mtypeid=0x1040a&attr=0x1006e&val=<groupname> 

Associate user with group: 
http://<host:port>/spectrum/restful/associations/relation/0x10022/leftmodel/<group_handle>/rightmodel/<user_handle> 
0x10022 = Has_Member association 

Get user role: 
http://<host:port>/spectrum/restful/associations/relation/0x00010031/model/<user_model>?side=right 

Get list of users model handles: 
POST http://localhost/spectrum/restful/models with the following XML POST body will get you the list of users. 

<?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> 
Additional Information:
RESOURCES: 

Creating users w/ REST 

https://communities.ca.com/message/241879871?commentID=241879871#comment-241879871 

Create Groups & users via REST 

https://communities.ca.com/message/101812885 

update user password via REST: 

https://communities.ca.com/message/241860344 

Get users and user roles: 

https://communities.ca.com/thread/241815955 

2. Here are a few RESTful API references: 

https://docops.ca.com/ca-spectrum/10-2-3/en/programming/web-services-api-reference 

https://support.ca.com/cadocs/1/CA%20Spectrum%209%202%201-ENU/Bookshelf_Files/PDF/Spectrum_Web_Services_API_Ref_ENU.pdf