-
Notifications
You must be signed in to change notification settings - Fork 7
[PNE-7426] Expose Project.archived. #1000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = "3.24.1" | ||
| __version__ = "3.25.0" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| """Resources that represent both individual and collections of projects.""" | ||
| from deprecation import deprecated | ||
| from functools import partial | ||
| from typing import Optional, Dict, List, Union, Iterable, Tuple, Iterator | ||
| from uuid import UUID | ||
| from warnings import warn | ||
|
|
@@ -77,6 +78,8 @@ class Project(Resource['Project']): | |
| """str: Status of the project.""" | ||
| created_at = properties.Optional(properties.Datetime(), 'created_at') | ||
| """int: Time the project was created, in seconds since epoch.""" | ||
| archived = properties.Optional(properties.Boolean, 'archived') | ||
| """bool: Whether the project is archived.""" | ||
| _team_id = properties.Optional(properties.UUID, "team.id", serializable=False) | ||
|
|
||
| def __init__(self, | ||
|
|
@@ -599,9 +602,57 @@ def register(self, name: str, *, description: Optional[str] = None) -> Project: | |
| project = Project(name, description=description) | ||
| return super().register(project) | ||
|
|
||
| def _list_base(self, *, per_page: int = 1000, archived: Optional[bool] = None): | ||
| filters = {} | ||
| if archived is not None: | ||
| filters["archived"] = str(archived).lower() | ||
|
|
||
| fetcher = partial(self._fetch_page, additional_params=filters, version=self._api_version) | ||
| return self._paginator.paginate(page_fetcher=fetcher, | ||
| collection_builder=self._build_collection_elements, | ||
| per_page=per_page) | ||
|
|
||
| def list(self, *, per_page: int = 1000) -> Iterator[Project]: | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that |
||
| """ | ||
| List projects using pagination. | ||
| List all projects using pagination. | ||
|
|
||
| Parameters | ||
| --------- | ||
| per_page: int, optional | ||
| Max number of results to return per page. Default is 1000. This parameter | ||
| is used when making requests to the backend service. If the page parameter | ||
| is specified it limits the maximum number of elements in the response. | ||
|
|
||
| Returns | ||
| ------- | ||
| Iterator[Project] | ||
| Projects in this collection. | ||
|
|
||
| """ | ||
| return self._list_base(per_page=per_page) | ||
|
|
||
| def list_active(self, *, per_page: int = 1000) -> Iterator[Project]: | ||
| """ | ||
| List non-archived projects using pagination. | ||
|
|
||
| Parameters | ||
| --------- | ||
| per_page: int, optional | ||
| Max number of results to return per page. Default is 1000. This parameter | ||
| is used when making requests to the backend service. If the page parameter | ||
| is specified it limits the maximum number of elements in the response. | ||
|
|
||
| Returns | ||
| ------- | ||
| Iterator[Project] | ||
| Projects in this collection. | ||
|
|
||
| """ | ||
| return self._list_base(per_page=per_page, archived=False) | ||
|
|
||
| def list_archived(self, *, per_page: int = 1000) -> Iterable[Project]: | ||
| """ | ||
| List archived projects using pagination. | ||
|
|
||
| Parameters | ||
| --------- | ||
|
|
@@ -616,7 +667,7 @@ def list(self, *, per_page: int = 1000) -> Iterator[Project]: | |
| Projects in this collection. | ||
|
|
||
| """ | ||
| return super().list(per_page=per_page) | ||
| return self._list_base(per_page=per_page, archived=True) | ||
|
|
||
| def search_all(self, search_params: Optional[Dict]) -> Iterable[Dict]: | ||
| """ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
requestsand our testing library just callstron abool, leaving it capitalized. And it seems the accounts service doesn't recognize that as a valid boolean.For the record, I confirmed that at least Orion paths can handle either. So I'm slightly inclined to add a snippet in
Sessionthat converts anyboolquery parameters to lower-cased strings automatically. But I've left that for the future, when we can more thoroughly ensure there are no ill effects elsewhere in the system.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll approve, but I'd rather see
jsonused to encode this, since the problem (I believe) is that the JSON standard uses lower case false and stringified Python uses title case. This works, but is less intuitive about why.