Jump to content

Event Subscriptions and Expressions


Evan Hale

Recommended Posts

Hello, 

I am trying to understand how expressions work in regards subscribing to events.

So far I have:

session.event_hub.subscribe('topic=ftrack.update', handle_event)

I am trying to filter an ftrack.update event to only capture when a status change occurs. I understand I can access the key value pairs in the event using "." notation. However whatever I try seems not to work.  If my event looks like the one below how would I access "statusid" inside of "changes"? Or even "statusid" inside of "keys"? I am not sure how to navigate past the list that is "entities" or "keys". I also see in the api documentation that you can use ">" "<" operators. How would this work? I don't seem to be able to filter by length.

TLDR: I want to filter the event subscription to only capture events with a status change. How would I do this? Thanks!

"<Event"{
    "id":"9573a292408342b580dacfb654dd8a45",
    "data":{
       "entities":[
          {
             "entity_type":"Task",
             "keys":[
                "statusid"
             ],
             "objectTypeId":"11c137c0-ee7e-4f9c-91c5-8c77cec22b2c",
             "entityType":"task",
             "parents":[
                {
                   "entityId":"849a05ce-a267-11ed-8a5f-32d516aa59c4",
                   "entityType":"task",
                   "entity_type":"Task",
                   "parentId":"7c90fdb0-a267-11ed-8d96-32d516aa59c4"
                },
                {
                   "entityId":"7c90fdb0-a267-11ed-8d96-32d516aa59c4",
                   "entityType":"task",
                   "entity_type":"Folder",
                   "parentId":"829bf916-9cf5-11ed-b339-32d516aa59c4"
                },
                {
                   "entityId":"829bf916-9cf5-11ed-b339-32d516aa59c4",
                   "entityType":"show",
                   "entity_type":"Project",
                   "parentId":"None"
                }
             ],
             "parentId":"7c90fdb0-a267-11ed-8d96-32d516aa59c4",
             "action":"update",
             "entityId":"849a05ce-a267-11ed-8a5f-32d516aa59c4",
             "changes":{
                "statusid":{
                   "new":"44de097a-4164-11df-9218-0019bb4983d8",
                   "old":"44ddd0fe-4164-11df-9218-0019bb4983d8"
                }
             }
          }
       ],
       "pushToken":"6902c5b6-a3f3-11ed-8a5f-32d516aa59c4",
       "parents":[
          "7c90fdb0-a267-11ed-8d96-32d516aa59c4",
          "849a05ce-a267-11ed-8a5f-32d516aa59c4",
          "829bf916-9cf5-11ed-b339-32d516aa59c4"
       ],
    },
    "topic":"ftrack.update",
    "sent":"None",
    "source":{
    "target":"",
    "in_reply_to_event":"None"
 }">"

 

Link to comment
Share on other sites

Hi Evan,

Which documentation are you referring to that mentions `<` and `>`? I want to check it out and ensure it accurately reflects current capabilities.

As for your initial question, it is my understanding that anything past the boundary of a list is not accessible via the dot notation in a subscription. This would preclude you from accessing `changes.statusid.<new|old>` and `keys.statusid`. These kinds of things need to be implemented in your callback.

Regards,
Patrick

Link to comment
Share on other sites

  • 3 weeks later...

Hey Patrick,

Sorry for the late response. I ended up doing exactly that and just filtering the events in the callback. I for the life of me cannot find the documentation where '<' and '>' operators can be used for filtering so maybe it was some old information or I am just going insane. Either way, I believe we are doing it the intended way in the callback now.

Thank you!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...