This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there a way to locate objects (=determine their type) by their reference using REST API?

As far as I can tell, object reference identifiers are unique throughout the system (i.e., across differnt "types" of objects).

If I have an interface with reference (not name!) REF_foobarbaz that is accessible by REST API under https://.../api/objects/interface/ethernet/REF_foobarbaz then I cannot also have, say, an TLS intermediate certificate with the same reference accessible under https://.../api/objects/ca/verification_ca/REF_foobarbaz

My problem is: given only the reference REF_foobarbaz, I'd like to find out where it belongs in the object tree, i.e., whether to find it under /interface/ethernet/ or under /ca/verification_ca/ or under whatnot ...

Weirdly, once I know that REF_foobarbaz refers to an interface, GET /api/objects/interface/ethernet/REF_foobarbaz reveals that fact as part of the object data a la { "_locked": "", "_ref": "REF_foobarbaz", "_type": "interface/ethernet", ... }

My attempt was to simply try GET /api/objects/REF_foobarbaz and hope for something useful (an informational reply or a redirect), but that didn't work.

Is there any REST API method to locate an object by its reference without knowing its type beforehand?



This thread was automatically locked due to age.
Parents
  • Newer objects have easily recognizable class and type information.  The Ethernet interface named Internal is REF_IntEthInternal.  The user named hagman is REF_AaaUseHagman.  The user group named IT is REF_AaaGroIt.  A verification CA would start with REF_CaVer.

    You can see this at the command line with cc get_object REF_tFluWzWtkWgR|grep 'class\|type'

    I'm not sure what class foo is or what type bar is. [:D]   

    Cheers - Bob

     
    Sophos UTM Community Moderator
    Sophos Certified Architect - UTM
    Sophos Certified Engineer - XG
    Gold Solution Partner since 2005
    MediaSoft, Inc. USA
  • OK, good to hear.

    It seems that this method, i.e., in PERL parlance, matching against the regular expression /REF_([A-Z][a-z]+)([A-Z][a-z]+)/ and then comparing $1 and $2 against the finitely many possibilities, works for most cases I am interested in. (I might need to compile a dictionary of class/type abbreviations)

    Then again, my external interface for example looks like below, i.e., most entries look like random garbage. Apparently, and as you mention,  this is for historical reasons (cf. comment "(V6 Upgrade)"): The good-looking secondary addresses are indeed relatively "recent".

    {
        "_locked": "",
        "_ref": "REF_azBWDGPbXc",              // random
        "_type": "interface/ethernet",
        "additional_addresses": [
          "REF_tmfGmIefra",                    // random 
          "REF_hzHxjoBZyi",                    // random
          "REF_yDGvyoUjzr",                    // random
          "REF_ItfSecFiles",                   // systematic 
          "REF_ItfSecEth1tvkonf",              // systematic
          "REF_ItfSecEth1intran",              // systematic
          "REF_ItfSecEth1webmai"               // systematic
        ],
        "bandwidth": 0,
        "comment": "(V6 Upgrade)",
        "inbandwidth": 0,
        "itfhw": "REF_bIhlcikhlu",             // random
        "link": true,
        "mtu": 1500,
        "mtu_auto_discovery": true,
        "name": "Internet",
        "outbandwidth": 0,
        "primary_address": "REF_FemtDFktSf",   // random
        "proxyarp": false,
        "proxyndp": false,
        "status": true
      }

     

    Good to see that class and type can be retrieved via cc, but I'd really like to know a sure-fire method for REST (as I am in the process of switching certain automated processes from cc to REST).

    Thanks for the (as always) informative answer - hagman

     

    P.S.: Come to think of it, there is unfortunately a (neglibigle but) positive probability that the "random" reference names accidentally look like something else. For example, by pure chance, it might have happened that the historical random ref of my interface was REF_CaVerGPbXc instead of REF_azBWDGPbXc, thus making it accidentally "look like" a certificate ...

Reply
  • OK, good to hear.

    It seems that this method, i.e., in PERL parlance, matching against the regular expression /REF_([A-Z][a-z]+)([A-Z][a-z]+)/ and then comparing $1 and $2 against the finitely many possibilities, works for most cases I am interested in. (I might need to compile a dictionary of class/type abbreviations)

    Then again, my external interface for example looks like below, i.e., most entries look like random garbage. Apparently, and as you mention,  this is for historical reasons (cf. comment "(V6 Upgrade)"): The good-looking secondary addresses are indeed relatively "recent".

    {
        "_locked": "",
        "_ref": "REF_azBWDGPbXc",              // random
        "_type": "interface/ethernet",
        "additional_addresses": [
          "REF_tmfGmIefra",                    // random 
          "REF_hzHxjoBZyi",                    // random
          "REF_yDGvyoUjzr",                    // random
          "REF_ItfSecFiles",                   // systematic 
          "REF_ItfSecEth1tvkonf",              // systematic
          "REF_ItfSecEth1intran",              // systematic
          "REF_ItfSecEth1webmai"               // systematic
        ],
        "bandwidth": 0,
        "comment": "(V6 Upgrade)",
        "inbandwidth": 0,
        "itfhw": "REF_bIhlcikhlu",             // random
        "link": true,
        "mtu": 1500,
        "mtu_auto_discovery": true,
        "name": "Internet",
        "outbandwidth": 0,
        "primary_address": "REF_FemtDFktSf",   // random
        "proxyarp": false,
        "proxyndp": false,
        "status": true
      }

     

    Good to see that class and type can be retrieved via cc, but I'd really like to know a sure-fire method for REST (as I am in the process of switching certain automated processes from cc to REST).

    Thanks for the (as always) informative answer - hagman

     

    P.S.: Come to think of it, there is unfortunately a (neglibigle but) positive probability that the "random" reference names accidentally look like something else. For example, by pure chance, it might have happened that the historical random ref of my interface was REF_CaVerGPbXc instead of REF_azBWDGPbXc, thus making it accidentally "look like" a certificate ...

Children
  • You can change the REF_ with move_object.  I just changed an Additional Address object named 'Southware External from 'REF_KNWfrJVtME' to 'REF_ItfSecSouthExter':

    cc move_object 'REF_KNWfrJVtME' 'REF_ItfSecSouthExter'

    Cheers - Bob

     
    Sophos UTM Community Moderator
    Sophos Certified Architect - UTM
    Sophos Certified Engineer - XG
    Gold Solution Partner since 2005
    MediaSoft, Inc. USA