(domain, restore_user, host_id, host_type=None, host_name=None, device_id=None)
return claim_id
Claim a case identified by host_id for claimant identified by owner_id.

    Creates an extension case so that the claimed case is synced to the claimant's device.
Claim a case identified by host_id for claimant identified by owner_id.
Claim a case identified by host_id for claimant identified by owner_id .
def claim_case(domain, restore_user, host_id, host_type=None, host_name=None, device_id=None):
    """
    Claim a case identified by host_id for claimant identified by owner_id.

    Creates an extension case so that the claimed case is synced to the claimant's device.
    """
    claim_id = uuid4().hex
    if not (host_type and host_name):
        case = CaseAccessors(domain).get_case(host_id)
        host_type = case.type
        host_name = case.name
    identifier = DEFAULT_CASE_INDEX_IDENTIFIERS[CASE_INDEX_EXTENSION]
    claim_case_block = CaseBlock.deprecated_init(
        create=True,
        case_id=claim_id,
        case_name=host_name,
        case_type=CLAIM_CASE_TYPE,
        owner_id=restore_user.user_id,
        index={
            identifier: IndexAttrs(
                case_type=host_type,
                case_id=host_id,
                relationship=CASE_INDEX_EXTENSION,
            )
        }
    ).as_xml()
    form_extras = {}
    if restore_user.request_user:
        form_extras["auth_context"] = AuthContext(
            domain=domain,
            user_id=restore_user.request_user_id,
            authenticated=True
        )
    submit_case_blocks(
        [ElementTree.tostring(claim_case_block, encoding='utf-8').decode('utf-8')],
        domain=domain,
        form_extras=form_extras,
        username=restore_user.full_username,
        user_id=restore_user.user_id,
        device_id=device_id,
    )
    return claim_id
def claim_case ( domain , restore_user , host_id , host_type = None , host_name = None , device_id = None ) : claim_id = uuid4 ( ) . hex if not ( host_type and host_name ) : case = CaseAccessors ( domain ) . get_case ( host_id ) host_type = case . type host_name = case . name identifier = DEFAULT_CASE_INDEX_IDENTIFIERS [ CASE_INDEX_EXTENSION ] claim_case_block = CaseBlock . deprecated_init ( create = True , case_id = claim_id , case_name = host_name , case_type = CLAIM_CASE_TYPE , owner_id = restore_user . user_id , index = { identifier : IndexAttrs ( case_type = host_type , case_id = host_id , relationship = CASE_INDEX_EXTENSION , ) } ) . as_xml ( ) form_extras = { } if restore_user . request_user : form_extras [ "auth_context" ] = AuthContext ( domain = domain , user_id = restore_user . request_user_id , authenticated = True ) submit_case_blocks ( [ ElementTree . tostring ( claim_case_block , encoding = 'utf-8' ) . decode ( 'utf-8' ) ] , domain = domain , form_extras = form_extras , username = restore_user . full_username , user_id = restore_user . user_id , device_id = device_id , ) return claim_id