def METHOD_NAME(
    self,
    idp: IdentityProvider,
    external_id: str,
    user: User | RpcUser,
    defaults: Mapping[str, Any],
) -> Identity:
    """
    Updates the identity object for a given user and identity provider
    with the new external id and other fields related to the identity status
    """
    query = self.filter(user_id=user.id, idp=idp)
    query.update(external_id=external_id, **defaults)
    identity_model = query.first()
    logger.info(
        "updated-identity",
        extra={
            "external_id": external_id,
            "idp_id": idp.id,
            "user_id": user.id,
            "identity_id": identity_model.id,
        },
    )
    return identity_model