-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from specklesystems/jedd/cxpla-95-add-fe2-que…
…ries-and-mutations-to-specklepy FE2 API Updates
- Loading branch information
Showing
71 changed files
with
3,775 additions
and
279 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
File renamed without changes.
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 |
---|---|---|
@@ -1,9 +1,41 @@ | ||
import pkgutil | ||
import sys | ||
from importlib import import_module | ||
from specklepy.api.resources.current.active_user_resource import ActiveUserResource | ||
from specklepy.api.resources.current.model_resource import ModelResource | ||
from specklepy.api.resources.current.other_user_resource import OtherUserResource | ||
from specklepy.api.resources.current.project_invite_resource import ( | ||
ProjectInviteResource, | ||
) | ||
from specklepy.api.resources.current.project_resource import ProjectResource | ||
from specklepy.api.resources.current.server_resource import ServerResource | ||
from specklepy.api.resources.current.subscription_resource import SubscriptionResource | ||
from specklepy.api.resources.current.version_resource import VersionResource | ||
from specklepy.api.resources.deprecated import ( | ||
active_user, | ||
branch, | ||
commit, | ||
object, | ||
other_user, | ||
server, | ||
stream, | ||
subscriptions, | ||
user, | ||
) | ||
|
||
for _, name, _ in pkgutil.iter_modules(__path__): | ||
imported_module = import_module("." + name, package=__name__) | ||
|
||
if hasattr(imported_module, "Resource"): | ||
setattr(sys.modules[__name__], name, imported_module) | ||
__all__ = [ | ||
"ActiveUserResource", | ||
"ModelResource", | ||
"OtherUserResource", | ||
"ProjectInviteResource", | ||
"ProjectResource", | ||
"ServerResource", | ||
"SubscriptionResource", | ||
"VersionResource", | ||
"active_user", | ||
"branch", | ||
"commit", | ||
"object", | ||
"other_user", | ||
"server", | ||
"stream", | ||
"subscriptions", | ||
"user", | ||
] |
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,74 @@ | ||
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.models import Model, ModelWithVersions, ResourceCollection | ||
from specklepy.core.api.resources import ModelResource as CoreResource | ||
from specklepy.logging import metrics | ||
|
||
|
||
class ModelResource(CoreResource): | ||
"""API Access class for models""" | ||
|
||
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: | ||
metrics.track(metrics.SDK, self.account, {"name": "Model Get"}) | ||
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: | ||
metrics.track(metrics.SDK, self.account, {"name": "Model Get With Versions"}) | ||
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]: | ||
metrics.track(metrics.SDK, self.account, {"name": "Model Get Models"}) | ||
return super().get_models( | ||
project_id, | ||
models_limit=models_limit, | ||
models_cursor=models_cursor, | ||
models_filter=models_filter, | ||
) | ||
|
||
def create(self, input: CreateModelInput) -> Model: | ||
metrics.track(metrics.SDK, self.account, {"name": "Model Create"}) | ||
return super().create(input) | ||
|
||
def delete(self, input: DeleteModelInput) -> bool: | ||
metrics.track(metrics.SDK, self.account, {"name": "Model Delete"}) | ||
return super().delete(input) | ||
|
||
def update(self, input: UpdateModelInput) -> Model: | ||
metrics.track(metrics.SDK, self.account, {"name": "Model Update"}) | ||
return super().update(input) |
Oops, something went wrong.