Skip to content

Commit

Permalink
add publish_model_without_links
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Sep 24, 2024
1 parent 12928ba commit 6ef177c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
40 changes: 40 additions & 0 deletions APSToolkitPython/src/aps_toolkit/BIM360.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,46 @@ def publish_model(self, project_id: str, item_id: str):
response = requests.post(url, headers=headers, json=payload)
return response.json() if response.status_code == 200 else response.text

def publish_model_without_links(self, project_id: str, item_id: str):
"""
Publish a model in Autodesk Construction Cloud (ACC)
:param project_id: the unique identifier of a project
:param item_id: the unique identifier of an item
:return: Response from the API
"""
headers = {
'Authorization': f'Bearer {self.token.access_token}',
'Content-Type': 'application/vnd.api+json'
}
url = f"{self.host}/data/v1/projects/{project_id}/commands"

payload = {
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "commands",
"attributes": {
"extension": {
"type": "commands:autodesk.bim360:C4RPublishWithoutLinks",
"version": "1.0.0"
}
},
"relationships": {
"resources": {
"data": [
{
"type": "items",
"id": item_id
}
]
}
}
}
}
response = requests.post(url, headers=headers, json=payload)
return response.json() if response.status_code == 200 else response.text

def get_hubs(self) -> dict:
"""
Returns a collection of accessible hubs for this member.
Expand Down
7 changes: 7 additions & 0 deletions APSToolkitPython/src/test/test_bim360.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ def test_publish_model(self):
bim360 = BIM360(token)
result = bim360.publish_model(self.project_id, item_id)
self.assertNotEquals(result, 0)

def test_publish_model_without_links(self):
item_id = "urn:adsk.wipprod:dm.lineage:Od8txDbKSSelToVg1oc1VA"
token = Auth().auth3leg()
bim360 = BIM360(token)
result = bim360.publish_model_without_links(self.project_id, item_id)
self.assertNotEquals(result, 0)
def test_get_hubs(self):
hubs = self.bim360.get_hubs()
self.assertNotEquals(hubs, 0)
Expand Down

0 comments on commit 6ef177c

Please sign in to comment.