Esempio n. 1
0
def get_creator_node_users():
    try:
        if "creator_node_endpoint" not in request.args:
            raise exceptions.ArgumentError("Missing creator_node_endpoint")
        cnode_url = request.args.get("creator_node_endpoint")
        users = get_users_cnode(cnode_url)
        return api_helpers.success_response(users)
    except exceptions.ArgumentError as e:
        return api_helpers.error_response(str(e), 400)
Esempio n. 2
0
    def get(self, replica_type):
        """ New route to call get_users_cnode with replica_type param (only consumed by content node)
            - Leaving `/users/creator_node` above untouched for backwards-compatibility

            Response = array of objects of schema { user_id, wallet, primary, secondary1, secondary2 }
        """
        args = users_by_content_node_route_parser.parse_args()

        cnode_url = args.get("creator_node_endpoint")

        if replica_type == 'primary':
            users = get_users_cnode(cnode_url, ReplicaType.PRIMARY)
        elif replica_type == 'secondary':
            users = get_users_cnode(cnode_url, ReplicaType.SECONDARY)
        else:
            users = get_users_cnode(cnode_url, ReplicaType.ALL)

        return success_response(users)
Esempio n. 3
0
    def get(self, replica_type):
        args = users_by_content_node_route_parser.parse_args()

        # Endpoint that a user's primary/secondary/either must be set to for them to be included in the results
        cnode_url = args.get("creator_node_endpoint")
        # Used for pagination with ">" comparison in SQL query. See https://ivopereira.net/efficient-pagination-dont-use-offset-limit
        prev_user_id = args.get("prev_user_id")
        # LIMIT used in SQL query
        max_users = args.get("max_users")

        if replica_type == "primary":
            users = get_users_cnode(
                cnode_url, ReplicaType.PRIMARY, prev_user_id, max_users
            )
        elif replica_type == "secondary":
            users = get_users_cnode(
                cnode_url, ReplicaType.SECONDARY, prev_user_id, max_users
            )
        else:
            users = get_users_cnode(cnode_url, ReplicaType.ALL, prev_user_id, max_users)

        return success_response(users)