-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,283 additions
and
210 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
from datetime import datetime | ||
from typing import List, Optional, overload | ||
|
||
from deprecated import deprecated | ||
|
||
from specklepy.core.api.inputs.project_inputs import UserProjectsFilter | ||
from specklepy.core.api.inputs.user_inputs import UserUpdateInput | ||
from specklepy.core.api.models import ( | ||
FE1_DEPRECATION_REASON, | ||
FE1_DEPRECATION_VERSION, | ||
PendingStreamCollaborator, | ||
ResourceCollection, | ||
User, | ||
) | ||
from specklepy.core.api.new_models import Project | ||
from specklepy.core.api.resources.active_user_resource import ( | ||
ActiveUserResource as CoreResource, | ||
) | ||
from specklepy.logging import metrics | ||
|
||
|
||
class ActiveUserResource(CoreResource): | ||
def __init__(self, account, basepath, client, server_version) -> None: | ||
super().__init__( | ||
account=account, | ||
basepath=basepath, | ||
client=client, | ||
server_version=server_version, | ||
) | ||
self.schema = User | ||
|
||
def get(self) -> Optional[User]: | ||
return super().get() | ||
|
||
@deprecated("Use UserUpdateInput overload", version=FE1_DEPRECATION_VERSION) | ||
@overload | ||
def update( | ||
self, | ||
name: Optional[str] = None, | ||
company: Optional[str] = None, | ||
bio: Optional[str] = None, | ||
avatar: Optional[str] = None, | ||
) -> User: | ||
... | ||
|
||
@overload | ||
def update(self, *, input: UserUpdateInput) -> User: | ||
... | ||
|
||
def update( | ||
self, | ||
name: Optional[str] = None, | ||
company: Optional[str] = None, | ||
bio: Optional[str] = None, | ||
avatar: Optional[str] = None, | ||
*, | ||
input: Optional[UserUpdateInput] = None, | ||
) -> User: | ||
if isinstance(input, UserUpdateInput): | ||
return super()._update(input=input) | ||
else: | ||
return super()._update( | ||
input=UserUpdateInput( | ||
name=name, | ||
company=company, | ||
bio=bio, | ||
avatar=avatar, | ||
) | ||
) | ||
|
||
def get_projects( | ||
self, | ||
*, | ||
limit: int = 25, | ||
cursor: Optional[str] = None, | ||
filter: Optional[UserProjectsFilter] = None, | ||
) -> ResourceCollection[Project]: | ||
return super().get_projects(limit=limit, cursor=cursor, filter=filter) | ||
|
||
def get_project_invites(self) -> List[PendingStreamCollaborator]: | ||
return super().get_project_invites() | ||
|
||
@deprecated(reason=FE1_DEPRECATION_REASON, version=FE1_DEPRECATION_VERSION) | ||
def activity( | ||
self, | ||
limit: int = 20, | ||
action_type: Optional[str] = None, | ||
before: Optional[datetime] = None, | ||
after: Optional[datetime] = None, | ||
cursor: Optional[datetime] = None, | ||
): | ||
""" | ||
Fetches collection the current authenticated user's activity | ||
as filtered by given parameters | ||
Note: all timestamps arguments should be `datetime` of any tz as they will be | ||
converted to UTC ISO format strings | ||
Args: | ||
limit (int): The maximum number of activity items to return. | ||
action_type (Optional[str]): Filter results to a single action type. | ||
before (Optional[datetime]): Latest cutoff for activity to include. | ||
after (Optional[datetime]): Oldest cutoff for an activity to include. | ||
cursor (Optional[datetime]): Timestamp cursor for pagination. | ||
Returns: | ||
Activity collection, filtered according to the provided parameters. | ||
""" | ||
metrics.track(metrics.SDK, self.account, {"name": "User Active Activity"}) | ||
return super().activity(limit, action_type, before, after, cursor) | ||
|
||
@deprecated(reason=FE1_DEPRECATION_REASON, version=FE1_DEPRECATION_VERSION) | ||
def get_all_pending_invites(self) -> List[PendingStreamCollaborator]: | ||
"""Fetches all of the current user's pending stream invitations. | ||
Returns: | ||
List[PendingStreamCollaborator]: A list of pending stream invitations. | ||
""" | ||
metrics.track( | ||
metrics.SDK, self.account, {"name": "User Active Invites All Get"} | ||
) | ||
return super().get_all_pending_invites() | ||
|
||
@deprecated(reason=FE1_DEPRECATION_REASON, version=FE1_DEPRECATION_VERSION) | ||
def get_pending_invite( | ||
self, stream_id: str, token: Optional[str] = None | ||
) -> Optional[PendingStreamCollaborator]: | ||
"""Fetches a specific pending invite for the current user on a given stream. | ||
Args: | ||
stream_id (str): The ID of the stream to look for invites on. | ||
token (Optional[str]): The token of the invite to look for (optional). | ||
Returns: | ||
Optional[PendingStreamCollaborator]: The invite for the given stream, or None if not found. | ||
""" | ||
metrics.track(metrics.SDK, self.account, {"name": "User Active Invite Get"}) | ||
return super().get_pending_invite(stream_id, token) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from typing import Optional | ||
|
||
from specklepy.core.api.inputs.model_inputs import ( | ||
CreateModelInput, | ||
DeleteModelInput, | ||
ModelVersionsFilter, | ||
UpdateModelInput, | ||
) | ||
from specklepy.core.api.inputs.project_inputs import ProjectModelsFilter | ||
from specklepy.core.api.new_models import Model, ModelWithVersions, ResourceCollection | ||
from specklepy.core.api.resources.model_resource import ModelResource as CoreResource | ||
|
||
|
||
class ModelResource(CoreResource): | ||
def __init__(self, account, basepath, client, server_version) -> None: | ||
super().__init__( | ||
account=account, | ||
basepath=basepath, | ||
client=client, | ||
server_version=server_version, | ||
) | ||
|
||
def get(self, model_id: str, project_id: str) -> Model: | ||
return super().get(model_id, project_id) | ||
|
||
def get_with_versions( | ||
self, | ||
model_id: str, | ||
project_id: str, | ||
*, | ||
versions_limit: int = 25, | ||
versions_cursor: Optional[str] = None, | ||
versions_filter: Optional[ModelVersionsFilter] = None, | ||
) -> ModelWithVersions: | ||
return super().get_with_versions( | ||
model_id, | ||
project_id, | ||
versions_limit=versions_limit, | ||
versions_cursor=versions_cursor, | ||
versions_filter=versions_filter, | ||
) | ||
|
||
def get_models( | ||
self, | ||
project_id: str, | ||
*, | ||
models_limit: int = 25, | ||
models_cursor: Optional[str] = None, | ||
models_filter: Optional[ProjectModelsFilter] = None, | ||
) -> ResourceCollection[Model]: | ||
return super().get_models( | ||
project_id, | ||
models_limit=models_limit, | ||
models_cursor=models_cursor, | ||
models_filter=models_filter, | ||
) | ||
|
||
def create(self, input: CreateModelInput) -> Model: | ||
return super().create(input) | ||
|
||
def delete(self, input: DeleteModelInput) -> bool: | ||
return super().delete(input) | ||
|
||
def update(self, input: UpdateModelInput) -> Model: | ||
return super().update(input) |
Oops, something went wrong.