Some of the Zabbix objects have both methods getObjects and get. They seem to be very similar. Why are both offered?
Ad Widget
Collapse
Zabbix API methods getObjects and get
Collapse
X
-
An object in most programming languages means a reference to something.
So in the case of the API, GetObject gives you reference to the API's json data but Get just hands over the resulting json data.
So if you get an object you can use/change it in place or copy it over to a normal Array (variable) and use it that way.
Main difference is how you like dealing with the result. Watch your error log for when you use it incorrectly though...
Haven't used the Zabbix API yet but have experience in other APIs. -
I'll answer my own question, now that I've studied the php code:
While the results are the same (getObjects methods return the get method results!), the getObjects methods allow a slightly different way of querying for them. GetObjects allows search on particular nodes or node ids. Also, getObjects sets output to EXTEND automatically, and webitems (whatever that is) to true. Also, getObjects puts your search criteria in a filter, rather than having to explicitly specify a filter.
So, it looks like the main reason for offering both is to allow specification of nodes, but it also simplifies the query a little bit. If you need to specify get parameters other than filter and output=EXTEND, though, you'll have to use the get method.Comment
Comment