Skip to content

Commit

Permalink
Changes to get_elements method.
Browse files Browse the repository at this point in the history
  • Loading branch information
senthurayyappan committed Jan 6, 2025
1 parent a08c4dc commit 891397b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions onshape_robotics_toolkit/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,20 @@ def get_elements(self, did: str, wtype: str, wid: str) -> dict[str, Element]:

# /documents/d/{did}/{wvm}/{wvmid}/elements
request_path = "/api/documents/d/" + did + "/" + wtype + "/" + wid + "/elements"
_elements_json = self.request(
response = self.request(
HTTP.GET,
request_path,
).json()
)

if response.status_code == 404:
LOGGER.error(f"Elements not found for document: {did}")
return {}

elif response.status_code == 403:
LOGGER.error(f"Access forbidden for document: {did}")
return {}

return {element["name"]: Element.model_validate(element) for element in _elements_json}
return {element["name"]: Element.model_validate(element) for element in response.json()}

def get_variables(self, did: str, wid: str, eid: str) -> dict[str, Variable]:
"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "onshape_robotics_toolkit"
version = "0.0.1"
description = "A python library to facilitate interaction with Onshape's REST API"
authors = ["Senthur Ayyappan <neurobionics@gmail.com>"]
authors = ["Senthur Ayyappan <senthurayyappan@gmail.com>"]
repository = "https://github.com/neurobionics/onshape-robotics-toolkit"
documentation = "https://neurobionics.github.io/onshape-robotics-toolkit/"
readme = "README.md"
Expand Down

0 comments on commit 891397b

Please sign in to comment.