11"""Resources that represent both individual and collections of projects."""
22from deprecation import deprecated
3+ from functools import partial
34from typing import Optional , Dict , List , Union , Iterable , Tuple , Iterator
45from uuid import UUID
56from warnings import warn
@@ -77,6 +78,8 @@ class Project(Resource['Project']):
7778 """str: Status of the project."""
7879 created_at = properties .Optional (properties .Datetime (), 'created_at' )
7980 """int: Time the project was created, in seconds since epoch."""
81+ archived = properties .Optional (properties .Boolean , 'archived' )
82+ """bool: Whether the project is archived."""
8083 _team_id = properties .Optional (properties .UUID , "team.id" , serializable = False )
8184
8285 def __init__ (self ,
@@ -599,9 +602,57 @@ def register(self, name: str, *, description: Optional[str] = None) -> Project:
599602 project = Project (name , description = description )
600603 return super ().register (project )
601604
605+ def _list_base (self , * , per_page : int = 1000 , archived : Optional [bool ] = None ):
606+ filters = {}
607+ if archived is not None :
608+ filters ["archived" ] = str (archived ).lower ()
609+
610+ fetcher = partial (self ._fetch_page , additional_params = filters , version = self ._api_version )
611+ return self ._paginator .paginate (page_fetcher = fetcher ,
612+ collection_builder = self ._build_collection_elements ,
613+ per_page = per_page )
614+
602615 def list (self , * , per_page : int = 1000 ) -> Iterator [Project ]:
603616 """
604- List projects using pagination.
617+ List all projects using pagination.
618+
619+ Parameters
620+ ---------
621+ per_page: int, optional
622+ Max number of results to return per page. Default is 1000. This parameter
623+ is used when making requests to the backend service. If the page parameter
624+ is specified it limits the maximum number of elements in the response.
625+
626+ Returns
627+ -------
628+ Iterator[Project]
629+ Projects in this collection.
630+
631+ """
632+ return self ._list_base (per_page = per_page )
633+
634+ def list_active (self , * , per_page : int = 1000 ) -> Iterator [Project ]:
635+ """
636+ List non-archived projects using pagination.
637+
638+ Parameters
639+ ---------
640+ per_page: int, optional
641+ Max number of results to return per page. Default is 1000. This parameter
642+ is used when making requests to the backend service. If the page parameter
643+ is specified it limits the maximum number of elements in the response.
644+
645+ Returns
646+ -------
647+ Iterator[Project]
648+ Projects in this collection.
649+
650+ """
651+ return self ._list_base (per_page = per_page , archived = False )
652+
653+ def list_archived (self , * , per_page : int = 1000 ) -> Iterable [Project ]:
654+ """
655+ List archived projects using pagination.
605656
606657 Parameters
607658 ---------
@@ -616,7 +667,7 @@ def list(self, *, per_page: int = 1000) -> Iterator[Project]:
616667 Projects in this collection.
617668
618669 """
619- return super (). list (per_page = per_page )
670+ return self . _list_base (per_page = per_page , archived = True )
620671
621672 def search_all (self , search_params : Optional [Dict ]) -> Iterable [Dict ]:
622673 """
0 commit comments