o ckF[n-@sddlZddlmZddlZddlZddlmZGdddeZGdddeZ Gdd d eZ Gd d d eZ Gd d d e Z Gddde ZdS)N)json)CloudSearchDomainConnectionc@s eZdZdS)SearchServiceExceptionN)__name__ __module__ __qualname__rrs    rc@s"eZdZdZdddZddZdS) rVanWrapper for response to Cloudsearch document batch commit. :type response: :class:`requests.models.Response` :param response: Response from Cloudsearch /documents/batch API :type doc_service: :class:`boto.cloudsearch2.document.DocumentServiceConnection` :param doc_service: Object containing the documents posted and methods to retry :raises: :class:`boto.exception.BotoServerError` :raises: :class:`boto.cloudsearch2.document.SearchServiceException` :raises: :class:`boto.cloudsearch2.document.EncodingError` :raises: :class:`boto.cloudsearch2.document.ContentTooLongError` Fc Cs||_||_||_||_|jr||_n(|jd}zt||_Wntj d ||jtj j |jjd|d|jd|_|jdkrjdd|jd gD|_|jD]}d |vr`td |d krhtd qVng|_|jd|_|jd|_|d|j|d|jdS)Nzutf-8z9Error indexing documents. Response Content: {0} SDF: {1})bodystatusrScSsg|]}|dqS)message)get).0errr sz+CommitResponse.__init__..r zIllegal Unicode characterz%Illegal Unicode character in documentzThe Content-Length is too longzContent was too longaddsdeletesr&r.)response doc_servicer8rPcontentdecoderloadsrQrRrSformat exceptionBotoServerError status_coder[r]r r rrarb_check_num_ops)r$rcrdr8rP_bodyr_rrr r%sB       zCommitResponse.__init__csjtfdd|jjD}||kr3|jrtj|jntj|jjt d ||}|j |_ |dS)aYRaise exception if number of ops in response doesn't match commit :type type_: str :param type_: Type of commit operation: 'add' or 'delete' :type response_num: int :param response_num: Number of adds or deletes in the response. :raises: :class:`boto.cloudsearch2.document.CommitMismatchError` csg|] }|dkr|qS)r'r)r^r-type_rr r`'s z1CommitResponse._check_num_ops..zs    ,