Bug 50023 - [UDM HTTP API] patch document requires options, policies and position
[UDM HTTP API] patch document requires options, policies and position
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM - REST API
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: Florian Best
Daniel Tröder
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-08-19 15:16 CEST by Daniel Tröder
Modified: 2019-09-22 15:51 CEST (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2019-08-19 15:16:38 CEST
One of the most common use cases for the UDM HTTP API is changing an objects property.
This cannot be easily done, because the patch document requires "options", "policies" and "position" to be set.
To do that a search and download of the object is first necessary.

Make "options", "policies" and "position" optional in patch documents.
Comment 1 Florian Best univentionstaff 2019-08-19 19:47:08 CEST
Okay, changed so that nothing needs to be set.

In most cases it is probably better to make a GET request, modify the content you get and send this via PUT.

Fixed in, no package build, will be done soon via Bug #27816:
dcb1d32645bb | Bug #27816: Bug #50023: add defaults in PATCH method
Comment 2 Daniel Tröder univentionstaff 2019-09-12 12:00:51 CEST
OK: code change
OK: tested PATCH for single "properties" and "options":

$ univention-ldapsearch -LLL uid=demo_student sn
dn: uid=demo_student,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=uni,dc=dtr
sn: Student

$ curl -i -X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -u Administrator:univention -d '{"properties": {"lastname": "Studi"}}' 'http://10.200.3.66/univention/udm/users/user/uid=demo_student,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=uni,dc=dtr'

$ univention-ldapsearch -LLL uid=demo_student sn
dn: uid=demo_student,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=uni,dc=dtr
sn: Studi

-----------------------------------------------------------------

$ univention-ldapsearch -LLL uid=demo_teacher objectClass | grep ucsschool
objectClass: ucsschoolTeacher
objectClass: ucsschoolType

$ curl -i -X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -u Administrator:univention -d '{"options": {"ucsschoolStaff": true}}' 'http://10.200.3.66/univention/udm/users/user/uid=demo_teacher,cn=lehrer,cn=users,ou=DEMOSCHOOL,dc=uni,dc=dtr'

$ univention-ldapsearch -LLL uid=demo_teacher objectClass | grep ucsschool
objectClass: ucsschoolType
objectClass: ucsschoolStaff
objectClass: ucsschoolTeacher

-----------------------------------------------------------------

$ curl -i -X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -u Administrator:univention -d '{"options": {"ucsschoolStaff": false}}' 'http://10.200.3.66/univention/udm/users/user/uid=demo_teacher,cn=lehrer,cn=users,ou=DEMOSCHOOL,dc=uni,dc=dtr'

$ univention-ldapsearch -LLL uid=demo_teacher objectClass | grep ucsschool
objectClass: ucsschoolType
objectClass: ucsschoolTeacher

-----------------------------------------------------------------

$ univention-ldapsearch -LLL cn=lehrer-schulezwei univentionPolicyReference
dn: cn=lehrer-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr
univentionPolicyReference: cn=ucsschool-umc-teachers-default,cn=UMC,cn=policies,dc=uni,dc=dtr

$ curl -i -X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -u Administrator:univention -d '{"policies": {"policies/registry": ["cn=ou-default-ucr-policy,cn=policies,ou=demoschool,dc=uni,dc=dtr"]}}' 'http://10.200.3.66/univention/udm/groups/group/cn=lehrer-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr'

$ univention-ldapsearch -LLL cn=lehrer-schulezwei univentionPolicyReference
dn: cn=lehrer-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr
univentionPolicyReference: cn=ou-default-ucr-policy,cn=policies,ou=demoschool,dc=uni,dc=dtr

$ curl -i -X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -u Administrator:univention -d '{"policies": {"policies/umc": ["cn=ucsschool-umc-teachers-default,cn=UMC,cn=policies,dc=uni,dc=dtr"]}}' 'http://10.200.3.66/univention/udm/groups/group/cn=lehrer-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr'

$ univention-ldapsearch -LLL cn=lehrer-schulezwei univentionPolicyReference
dn: cn=lehrer-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr
univentionPolicyReference: cn=ucsschool-umc-teachers-default,cn=UMC,cn=policies,dc=uni,dc=dtr
Comment 3 Florian Best univentionstaff 2019-09-18 14:53:46 CEST
<http://errata.software-univention.de/ucs/4.4/282.html>