Create a Restful API search to collect all models contained within a Global Collection

book

Article ID: 209503

calendar_today

Updated On:

Products

CA Spectrum

Issue/Introduction

We are looking for search on CollectionsModelNameString to collect models contained within a specific GC Name via RestAPI

Environment

Spectrum 10.3 and up

Resolution

The Restful suggestion is below:

 

<?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>0x10474</model-type>  <!-- GC mtype -->

      </equals>

      <has-substring-ignore-case>

         <attribute id="AttributeID.MODEL_NAME">

           <value>Fault</value> <!-- ModelName -->

         </attribute>

      </has-substring-ignore-case>

     </and>

   </filtered-models>

     <relation>0x1003a</relation> <!-- 0x1003a DynamicGlobalCollects relation-->

                                  <!-- 0x1003b StaticGlobalCollects relation-->

   </child-models>

      

     

        </rs:search-criteria>     

      </rs:models-search>

    </rs:target-models>

    <rs:requested-attribute id="0x1006e" />

</rs:model-request>

 

You can replace the GC name.

 

This search query will satisfy your requirement by replacing the GC name.

 

This query looks for all models under specified GC with either StaticGlobalCollects or DynamicGlobalCollects child relation.

 

 

You can also use this CURL command: 

 

url --user spectrum:spectrum http://model/0x700154d?side=leftum/restful/associations/relation/0x0001003a/

This is the curl command you can use to get the list of models associated with a Global Collection. The parameter after the model is the model handle of the Global Collection. The parameter after relation is the DynamicGlobalCollects relation handle and the side is the side the global collection is on in the association. In this case the left side.

The output looks like the following:

<association-response-list xmlns="http://www.ca.com/spectrum/restful/schema/response">
<association-responses>
<association rh="0x1003a" leftmh="0x700154d" rightmh="0x700007d"/>
<association rh="0x1003a" leftmh="0x700154d" rightmh="0x70010bd"/>
<association rh="0x1003a" leftmh="0x700154d" rightmh="0x7000762"/>
<association rh="0x1003a" leftmh="0x700154d" rightmh="0x7001515"/>
</association-responses>
</association-response-list>