Manage Spectrum users via RESTful API - examples
search cancel

Manage Spectrum users via RESTful API - examples

book

Article ID: 116305

calendar_today

Updated On:

Products

Spectrum Network Observability

Issue/Introduction

I have a requirement to automatically manage my users/roles. Can this be leveraged through the REST API? 

Environment

All supported DX NetOps Spectrum releases

Resolution

The following are some Restful examples for managing Spectrum Users. Using a RESTful client, connect to the OneClick server as per the following URLs.

Create a user by issuing the following as a POST request: 

     http://<OC_HOST:OC_PORT>/spectrum/restful/model?landscapeid=<ls_handle>&mtypeid=0x10004&attr=0x1006e&val=<username

NOTES:

    • In a DSS environment the create user call must be run once per SS using each SS's Landscape_Handle value. Using the OC web UI to create the user is beneficial over this method as it will result in the user being created on every SS in the DSS without additional work.
    • The "mtypeid=0x10004" should not be modified. It what tells it to create a user model to represent the new user.
    • The "attr=0x1006e&val=" is for setting the users name. Replace <username> with the desired username to be set.

Delete the user using a DELETE request: 

     http://<OC_HOST:OC_PORT>/spectrum/restful/model/<user_model_handle> 

Associate user with a role using a POST request: 

     http://<OC_HOST:OC_PORT>/spectrum/restful/associations/relation/0x10031/leftmodel/<user_role_handle>/rightmodel/<user_model_handle

Where "0x10031" = user role association.

Use Spectrum CLI to obtain the User_Role_handles. User_role_handle is shown in the left column of the output.

cd /vnmsh
./connect
./show models | grep -i LicenseRole

Example output for user roles: 

     0x100016 Operator        0x10453 LicenseRole 
     0x100015 Administrator   0x10453 LicenseRole 
     0x100012 Service Manager 0x10453 LicenseRole 

Create a user Group: 

     http://OC_HOST:OC_PORT>/spectrum/restful/model?landscapeid=<ls_handle>&mtypeid=0x1040a&attr=0x1006e&val=<groupname

Associate a user with a user group: 

     http://<OC_HOST:OC_PORT>/spectrum/restful/associations/relation/0x10022/leftmodel/<group_handle>/rightmodel/<user_model_handle

 Where "0x10022" = Has_Member association.

Get a user role: 

     http://<OC_HOST:OC_PORT>/spectrum/restful/associations/relation/0x00010031/model/<user_model_handle>?side=right 

Get a list of users model handles: 

POST request 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>
</rs:model-request>



Additional Information

Additional attributes that might be useful when creating new users.

  • User_ID at attribute ID 0x101f3.
    • Appears as ID value in a users Component Detail tab in the General Information area.
  • User_Full_Name at attribute ID 0x10074.
    • Appears as "Full Name" value in a users Component Detail tab in the General Information area.
  • User_Email at attribute ID 0x12912.
    • Appears as "E-Mail" value in a users Component Detail tab in the General Information area.