def search_generator(self, *, filter: dict = None, limit: int = 50,
                         page: int = None,
                         **kwargs) -> Generator[Resource, None, None]:
        """Return a generator to search through OAuth clients.

        The generator allows the user not to care about the pagination of
        results, while being memory-effective.

        Found OAuth clients are sorted chronologically in order to
        allow new resources to be found during the search.

        Args:
            filter: Search filter dictionary.

            limit: Optional maximum number of results by search
                request (default to 50).

            page: Optional page number to start the search at (default is 1).

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Returns:
            A generator yielding resources for found OAuth clients.

        """
        return search_generator(self, first_page=1, filter=filter, limit=limit,
                                page=page, **kwargs)
Ejemplo n.º 2
0
    def search_generator(self,
                         *,
                         filter: dict = None,
                         fields: dict = None,
                         limit: int = 100,
                         page: int = None,
                         sort: dict = None,
                         **kwargs) -> Generator[Resource, None, None]:
        """Return a generator to search through projects.

        The generator allows the user not to care about the pagination of
        results, while being memory-effective.

        Found projects are sorted chronologically in order to allow
        new resources to be found during the search.

        Args:
            filter: Optional ``filter`` dictionary from ``search()`` method.

            fields: Optional ``fields`` dictionary from ``search()`` method.

            limit: Optional maximum number of results by search
                request (default is ``100``).

            page: Optional page number to start the search at (default is 1).

            sort: Optional ``sort`` dictionary from ``search()`` method.

            **kwargs: Optional keyword arguments. Those arguments are
                passed as is to the API provider.

        Returns:
            A generator yielding found projects.

        Examples:
            >>> # get all projects matching filter by using generator
            >>> results_iterator = sdk.projects.search_generator(filter={...})
            >>> projects = [r for r in results_iterator]

        """
        return search_generator(self,
                                first_page=1,
                                filter=filter,
                                fields=fields,
                                limit=limit,
                                page=page,
                                sort=sort,
                                **kwargs)