def edit(self, entity, id, payload, sync=True):
url = urljoin(self.host, entity.value + '<STR_LIT:/>')<EOL>url = urljoin(url, id + '<STR_LIT:/>')<EOL>params = {'<STR_LIT>': str(sync).lower()}<EOL>url = Utils.add_url_parameters(url, params)<EOL>r = requests.put(url, auth=self.auth, data=json.dumps(payload),<EOL>headers=self.headers)<EOL>if r.status_code == <NUM_LIT>:<EOL><INDENT>error_message = r.json()['<STR_LIT>']<EOL>raise CoredataError('<STR_LIT>'.format(error=error_message))<EOL><DEDENT>
Edit a document.