def attach(self, api_object, on_cloud=False):
if self.on_cloud:<EOL><INDENT>return True<EOL><DEDENT>if api_object and getattr(api_object, '<STR_LIT>', None):<EOL><INDENT>if on_cloud:<EOL><INDENT>if not api_object.object_id:<EOL><INDENT>raise RuntimeError(<EOL>'<STR_LIT>')<EOL><DEDENT>url = api_object.build_url(self._endpoints.get('<STR_LIT>').format(<EOL>id=api_object.object_id))<EOL>response = api_object.con.post(url, data=self.to_api_data())<EOL>return bool(response)<EOL><DEDENT>else:<EOL><INDENT>if self.attachment_type == '<STR_LIT:file>':<EOL><INDENT>api_object.attachments.add([{<EOL>'<STR_LIT>': self.attachment_id,<EOL>'<STR_LIT:path>': str(<EOL>self.attachment) if self.attachment else None,<EOL>'<STR_LIT:name>': self.name,<EOL>'<STR_LIT:content>': self.content,<EOL>'<STR_LIT>': self.on_disk<EOL>}])<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>
Attach this attachment to an existing api_object. This
        BaseAttachment object must be an orphan BaseAttachment created for the
        sole purpose of attach it to something and therefore run this method.

        :param api_object: object to attach to
        :param on_cloud: if the attachment is on cloud or not
        :return: Success / Failure
        :rtype: bool