[ZBX-5032] add support of "selectMediatypes" for "user.get" and fix support of "userids,mediaids" for "mediatype.get" Created: 2012 May 22  Updated: 2017 May 30  Resolved: 2012 May 28

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A), Documentation (D)
Affects Version/s: 1.8.13, 2.0.0
Fix Version/s: 1.8.14rc1, 2.0.1rc1, 2.1.0

Type: Incident report Priority: Critical
Reporter: Oleksii Zagorskyi Assignee: Martins Valkovskis
Resolution: Fixed Votes: 0
Labels: API
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File api_user.get_mediatype.get.patch    
Issue Links:
Duplicate
is duplicated by ZBX-5043 leave API method "usermedia.get" and ... Closed

 Description   

See attached patch (based on just released 2.0.0)

(1) Apply the patch to add all time documented but missing in the code parameter "selectMediatypes" for user.get method
http://www.zabbix.com/documentation/2.0/manual/appendix/api/user/get

along with a fix for parameters userids,mediaids for mediatype.get (dummy typo in a table name)
http://www.zabbix.com/documentation/2.0/manual/appendix/api/mediatype/get

(2) Also consider to apply patch to the 1.8 (and also add support of selectMedias from 2.0 to 1.8) or remove declaration of parameters select_medias, select_mediatypes from 1.8 documentation.
http://www.zabbix.com/documentation/1.8/api/user/get

Because it misleads users all these years:
http://www.zabbix.com/forum/showthread.php?t=21042
http://boardreader.com/thread/API_Call_is_failing_any_ideas_why_q2Xhii.html

After patch:

Request:

{ "userids":[3, 7], "selectMediatypes":"refer" }

Response:
"result":[{
"userid":"3",
"mediatypes":[

{ "mediatypeid":"6" }

]
},{
"userid":"7",
"mediatypes":[

{ "mediatypeid":"1" }

,

{ "mediatypeid":"2" }

]
}],

ALL is correct - TESTED



 Comments   
Comment by Eduards Samersovs (Inactive) [ 2012 May 23 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-5032
and svn://svn.zabbix.com/branches/dev/ZBX-5032-1.8

<zalex> See issue description where I said "(and also add support of selectMedias from 2.0 to 1.8)"
You forgot to add support of selectMedias (in 2.0) to the 1.8 with parameter name "'select_medias'"
REOPENED

<Eduard> RESOLVED

<zalex> See (3) CLOSED

Comment by Pavels Jelisejevs (Inactive) [ 2012 May 23 ]

(1) Please review my changes in r27782.

<Eduard> OK, CLOSED

<pavels> I've reverted some changes in 27847. The options parameter should not be modified during the creation of the query. It will create a mix of dependencies that may be hard to handle.

Comment by Pavels Jelisejevs (Inactive) [ 2012 May 23 ]

(2) For 1.8: if the user has no media defined, select_mediatypes should return an empty array.

<Eduard> RESOLVED

<pavels> CLOSED.

Comment by Pavels Jelisejevs (Inactive) [ 2012 May 23 ]

(3) The "selectMedias" parameter is not implemented in neither trunk, nor 1.8. It should be removed from the code and the docs.
http://www.zabbix.com/documentation/2.0/manual/appendix/api/mediatype/get
http://www.zabbix.com/documentation/1.8/api/user/get

<zalex> NO, it IS implemented in the trunk, but missing in the 1.8
See changes for rev 19332 (ZBXNEXT-629)
Why it should be removed ? I do NOT agree.

<pavels> It's only defined in the trunk, it's not implemented (it only returns ids). But, if you think we need id, then let's add it. But rename to "selectMedia", because that's the correct plural form.

<zalex> I personally do not have any objections for any parameter names, but note that 1.8 API and its doc uses another parameters naming, not Camel Case but uses underscore for spaces. You can compare with other get methods.

Now (and all time before) that parameter had name "select_medias"
See http://www.zabbix.com/documentation/1.8/api/user/get

So I suppose for 1.8 (as you have decided to restore for 1.8 as well) would be better to use old parameter names: select_medias and select_mediatypes (ok already in the dev dbanch) and DO NOT TOUCH 1.8 DOCUMENTATION for the user.get

<Eduard> RESOLVED

<zalex> it worth to mention here that "select_medias" NOT added to 1.8 and finally removed from 1.8 documentation.
support of "select_mediatypes" added to 1.8 code, documented.
TESTED and could be closed.

<pavels> CLOSED.

Comment by Oleksii Zagorskyi [ 2012 May 25 ]

(4)
Dev branch of 2.0 (ZBX-5032):
Request:

{ "userids":"1", "selectMedias":"extend", "selectMediatypes":"extend" }

Response:
{
"jsonrpc":"2.0",
"result":[
{
"userid":"1",
"medias":[

{ "mediaid":"40", "userid":"1", "mediatypeid":"2", "sendto":"jjjj", "active":"0", "severity":"63", "period":"1-7,00:00-24:00;" }

],
"mediatypes":[

{ "mediatypeid":"2", "type":"3", "description":"Jabber", "smtp_server":"", "smtp_helo":"", "smtp_email":"", "exec_path":"", "gsm_modem":"", "username":"[email protected]", "passwd":"zabbix", "status":"0", "userid":"1" }

]
},
{
"mediatypes":[

{ "mediatypeid":"2", "type":"3", "description":"Jabber", "smtp_server":"", "smtp_helo":"", "smtp_email":"", "exec_path":"", "gsm_modem":"", "username":"[email protected]", "passwd":"zabbix", "status":"0", "userid":"1" }

]
}
],
"id":0
}

As you see the array "mediatypes" repeated twice and second time on wrong level.
REOPENED

<Eduard> RESOLVED

<pavels> CLOSED.

Comment by Oleksii Zagorskyi [ 2012 May 25 ]

FYI: Changes reflected in the doc http://www.zabbix.com/documentation/2.0/manual/appendix/api/changes_1.8_-_2.0#user

Comment by Pavels Jelisejevs (Inactive) [ 2012 May 25 ]

(5) Please review my changes for the trunk fix in 27847-27849. If everything is ok, you can merge.

Comment by Pavels Jelisejevs (Inactive) [ 2012 May 25 ]

The fix for 1.8 is TESTED.

Comment by Oleksii Zagorskyi [ 2012 May 25 ]

dev branches of 1.8 and trunk additionally successfully TESTED.

Comment by Eduards Samersovs (Inactive) [ 2012 May 28 ]

Fixed in versions pre-2.1.0 (beta) r27864, pre-2.0.1 r27863, pre-1.8.14rc1 r27865

Generated at Wed Apr 24 01:09:34 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.