|
putObject
The putObject method.
The putObject method is used to create or update objects on the server. In order to create a new object on the server send the dictionary to the server with an "objectId" key of 0. If "objectId" is non-zero the server assumes it specifies an existing object to be updated. If the creation or modification succeeds the new object, including the new "objectId", is returned to the client with a detail level of 65,535 (all details). ExampleAppointmentThe special FLAGS key is important when creating and updating appointments. If the FLAGS key contains the string "ignoreConflicts" the appointment will be created or modified regardless of whether or not doing so also creates conflicts. Otherwise, if the creation or modification of the appointment creates a conflict the request will fail with an exception. A value of "respectConflicts" in FLAGS is synonymous with the default of producing an exception upon creating a conflict.
#!/usr/bin/env python
import xmlrpclib, time, sys
server = xmlrpclib.Server('http://{USER}:{PASSWORD}@{HOST}/zidestore/so/{HOST}/')
participant1 = {}
participant1['participantObjectId'] = 10160
participant1['role'] = 'CHAIR'
participant1['comment'] = 'This dude rocks'
participant2 = {}
participant2['participantObjectId'] = 10003
participant2['role'] = 'REQ-PARTICIPANT'
app = { }
app['entityName'] = 'Appointment'
app['objectId'] = '0'
app['keywords'] = 'ZOGI'
app['comment'] = 'COMMENT COMMENT COMMENT'
app['start'] = '2006-11-30 13:00'
app['end'] = '2006-11-30 15:00'
app['title'] = 'My New 2007 Appointment'
app['location'] = 'Sardinia'
app['_FLAGS'] = 'ignoreConflicts'
app['_PARTICIPANTS'] = [ participant1, participant2 ]
app['_RESOURCES'] = [ { 'objectId': 465950 }, { 'objectId': 465990 } ]
print "--Create--"
app = server.zogi.putObject(app)
print app
print "--Update--"
print "objectId: %s" % app['objectId']
app['title'] = 'Modified Appointment'
app['_FLAGS'] = 'ignoreConflicts'
app['_PARTICIPANTS'] = [ participant2 ]
app = server.zogi.putObject(app)
print appTaskFor information on performing task actions see the documentation concerning the taskNotation entity. #!/usr/bin/env python
import xmlrpclib, time, sys
server = xmlrpclib.Server('http://{USER}:{PASSWORD}@{HOST}/zidestore/so/{USER}/')
task = { }
task['entityName'] = 'Task'
task['name'] = 'New ZOGI Task 5'
task['executantObjectId'] = 10160
task['objectId'] = '0'
task['keywords'] = 'ZOGI'
task['comment'] = 'COMMENT COMMENT COMMENT'
task['priority'] = 2
task['startDate'] = '2006-12-31'
task['endDate'] = '2007-01-25'
task['sensitivity'] = 2
task['totalWork'] = 75
task['percentComplete'] = 40
task['notify'] = 1
task['kilometers'] = 34
task['accountingInfo'] = 'Accounting Info'
task['actualWork'] = 23
print "--Create--"
task = server.zogi.putObject(task)
print task
print "--Update--"
print "objectId: %s" % task['objectId']
task['name'] = 'Updated ZOGI Task 5'
task = server.zogi.putObject(task)
print taskTeamAs of r879 (2007-12-19) the membership of a Team can be modified by putting the Team with a modified "memberObjectIds" attributes. This requires the user to have sufficient permissions to modify the team. No other attributes of the Team can be modified. #!/usr/bin/env python
import xmlrpclib, time, pprint
server = xmlrpclib.Server('http://{USER}:{PASSWORD}@{HOST}/zidestore/so/{USER}/')
team = server.zogi.getObjectById(9981, 128)
pprint.pprint(team)
team['memberObjectIds'] = [ 10000, 10100, 9144860 ]
team = server.zogi.putObject(team)
print team['memberObjectIds']
team['memberObjectIds'] = [ 10100 ]
team = server.zogi.putObject(team)
print team['memberObjectIds']
team['memberObjectIds'] = [ 10000, 10100, 9144860 ]
team = server.zogi.putObject(team)
print team['memberObjectIds']If a Team entity is sent via putObject without a "memberObjectIds" attribute no modification attempt is performed. EnterpriseIn the context of the "CONTACTS" array key only the "targetObjectId" of contained entities is required to store the assignment on the server. Including a complete assignment entity is OK, but only the "targetObjectId" is used. The flags "unfavorite" and "favorite" can be supplied in order to modify the favorite status of the Enterprise. By default an Enterprise is not a favorite. The putObject operation on an Enterprise entity also supports a special businessCard mode to facilitate the creation of new Enterprise/Contact groups in one operation.
#!/usr/bin/env python
import xmlrpclib,pprint
server = xmlrpclib.Server('http://awilliam:*****localhost/zidestore/so/awilliam/')
enterprise = { }
enterprise['name'] = 'Fred Inc.'
enterprise['entityName'] = 'Enterprise'
enterprise['objectId'] = 0
companyValue = {}
companyValue['attribute'] = 'email2'
companyValue['value'] = 'fred@example.com'
address = {}
address['name1'] = 'Fred Smith'
address['street'] = '1234 Elm St.'
address['city'] = 'Pandemonium'
address['type'] = 'private'
phone = {}
phone['type'] = '01_tel'
phone['number'] = '6163401149'
phone['info'] = 'Old number'
person = {}
person['targetObjectId'] = 10160
enterprise['_ADDRESSES'] = [ address ]
enterprise['_PHONES'] = [ phone ]
enterprise['_COMPANYVALUES'] = [ companyValue ]
enterprise['_CONTACTS'] = [ person ]
property1 = {}
property1['propertyName'] = '{http://www.whitemiceconsulting.com/properties/ext-attr}myIntAttribute'
property1['value'] = 7
property2 = {}
property2['propertyName'] = '{http://www.whitemiceconsulting.com/properties/ext-attr}myStringAttribute'
property2['value'] = 'Hi there'
enterprise['_PROPERTIES'] = [ property1, property2 ]
print "--PUT Enterprise (New)--"
enterprise = server.zogi.putObject(enterprise)
pprint.pprint(enterprise)ContactIn the context of the ENTERPRISE array key only the "targetObjectId" of contained entities is required to store the assignment on the server. Including a complete assignment entity is OK, but only the "targetObjectId" is used. The flags "unfavorite" and "favorite" can be supplied in order to modify the favorite status of the Contact. By default a Contact is not a favorite.
#!/usr/bin/env python
import xmlrpclib,pprint
server = xmlrpclib.Server('http://{USER}:{PASSWORD}@{HOST}/zidestore/so/{USER}/')
contact = { }
contact['firstName'] = 'Fred'
contact['lastName'] = 'Smith'
contact['entityName'] = 'Contact'
contact['objectId'] = 0
companyValue = {}
companyValue['attribute'] = 'email2'
companyValue['value'] = 'fred@example.com'
address = {}
address['name1'] = 'Fred Smith'
address['street'] = '1234 Elm St.'
address['city'] = 'Pandemonium'
address['type'] = 'private'
phone = {}
phone['type'] = '01_tel'
phone['number'] = '6163401149'
phone['info'] = 'Old number'
acl1 = {}
acl1['targetObjectId'] = 10160
acl1['operations'] = 'rw'
acl2 = {}
acl2['targetObjectId'] = 10003
acl2['operations'] = 'r'
enterprise = {}
enterprise['targetObjectId'] = 148730
contact['_ADDRESSES'] = [ address ]
contact['_PHONES'] = [ phone ]
contact['_COMPANYVALUES'] = [ companyValue ]
contact['_ENTERPRISES'] = [ enterprise ]
contact['_ACCESS'] = [ acl1, acl2 ]
contact['_FLAGS'] = [ 'favorite' ]
property1 = {}
property1['propertyName'] = '{http://www.whitemiceconsulting.com/properties/ext-attr}myIntAttribute'
property1['value'] = 7
property2 = {}
property2['propertyName'] = '{http://www.whitemiceconsulting.com/properties/ext-attr}myStringAttribute'
property2['value'] = 'Hi there'
contact['_PROPERTIES'] = [ property1, property2 ]
print "--PUT Contact (New)--"
contact = server.zogi.putObject(contact)
pprint.pprint(contact)Project
|
Sign in to add a comment