CA Service Management

Expand all | Collapse all

REST where clause and sort by

Jump to Best Answer
  • 1.  REST where clause and sort by

    Posted 02-13-2018 02:19 PM

    I'm trying to figure out a way to use rest to retrieve a session ID created by a given analyst logging in with a browser.

    I would like to be able to use a compound where clause something like: 

     

    ?WC=session_type=10&contact="U'03A8CBDC945A094FBD8665E682002180'"

    (forgive the syntax i just copied it out of SOAP-UI)

     

    In reading the documentation I don't see anything about compound where clauses or where clauses used simultaneously with the sort clause is either scenario possible?

     

    Or is there another way to solve this problem?

     

    Elwynn.



  • 2.  Re: REST where clause and sort by

    Posted 02-13-2018 04:09 PM

    Elwynn,

     

    session_type=1  is GUI based login.  

     

    Our sorting syntax is documented here: REST HTTP Methods - CA Service Management - 17.0 - CA Technologies Documentation 

     

    So a sample like this seems to be working fine for me, where I'm looking for the latest 50 GUI based logins records for a specific user.  You can query / retrieve any objects on the session_log table below:

     

    C:\>bop_sinfo -qd session_log

    Factory session_log < session_log >
    Attributes:
    id INTEGER UNIQUE
    producer_id LOCAL STRING(20)
    persistent_id LOCAL STRING(60)
    login_time DATE REQUIRED
    logout_time DATE
    contact SREL -> cnt.id TENANCY_UNRESTRICTED
    session_id INTEGER
    session_type SREL -> session_type.id TENANCY_UNRESTRICTED
    policy SREL -> sapolicy.id TENANCY_UNRESTRICTED
    status INTEGER

     

     

    Example: 

    http://hostname:port/caisd-rest/session_log?SORT=login_time DESC&start=1&size=50&rel=all&contact=U'F4C2A60100EA154695D233F90ABFFD21'&WC=session_type=1

     

    Hope this helps

    _R



  • 3.  Re: REST where clause and sort by

    Posted 02-14-2018 11:04 AM

    Raghu,

     

    Thank you for your help!

     

    I haven't been able to get any additional filters beyond sort to work before the WC.

     

    For example below the sort and contact are working but session_type isn't, it doesn't make any difference where i put which attribute, only the sort plus 1 other will work.

    ?SORT=login_time DESC&session_type=1&WC=contact=U'03A8CBDC945A094FBD8665E682002180'

     

    Any thoughts?

     

    Elwynn.



  • 4.  Re: REST where clause and sort by
    Best Answer

    Posted 02-14-2018 11:22 AM

    Elwynn,

     

     

    I think I'm seeing the same too,  could be a defect that we need to look into.  Would you be able to raise a support case and hit me up with the #?

     

    Thx

    _R



  • 5.  Re: REST where clause and sort by

    Posted 02-14-2018 12:23 PM

    Raghu,

     

    Sure, the case number is 00963268.

     

    Elwynn.



  • 6.  Re: REST where clause and sort by

    Posted 02-14-2018 03:15 PM

    Sorry for the mislead. I do have your support case too, Looks like we did not know the correct syntax there.

     

    We just needed    %20AND%20    for the join, and it %3D  instead of =.

     

    So, a where clause like:    contact='foo' and session_type=1    becomes   contact%3DU'F4C2A60100EA154695D233F90ABFFD21'%20and%20session_type%3D1 

     

    See my working example below:

     

    /caisd-rest/session_log?SORT=login_time DESC&start=1&size=50&rel=all&WC=contact%3DU'F4C2A60100EA154695D233F90ABFFD21'%20and%20session_type%3D1

     

    It was on the same docops page that I mentioned earlier but I totally missed it  (REST HTTP Methods - CA Service Management - 17.0 - CA Technologies Documentation ) 

     

    Hope that resolves yours too

    _R