Skip to content

Commit 2bee54f

Browse files
committed
[PTDT-1108] Added client method unarchive_root_schema_node
1 parent 24dd42a commit 2bee54f

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

labelbox/client.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def __init__(self,
5555
api_key=None,
5656
endpoint='https://api.labelbox.com/graphql',
5757
enable_experimental=False,
58-
app_url="https://app.labelbox.com"):
58+
app_url="https://app.labelbox.com",
59+
rest_endpoint="https://api.labelbox.com/api/v1"):
5960
""" Creates and initializes a Labelbox Client.
6061
6162
Logging is defaulted to level WARNING. To receive more verbose
@@ -95,6 +96,12 @@ def __init__(self,
9596
'X-User-Agent': f'python-sdk {SDK_VERSION}'
9697
}
9798
self._data_row_metadata_ontology = None
99+
self.rest_endpoint = rest_endpoint
100+
self.rest_endpoint_headers = {
101+
"authorization": "Bearer %s" % self.api_key,
102+
'X-User-Agent': 'python-sdk 0.0.0',
103+
'Content-Type': 'application/json',
104+
}
98105

99106
@retry.Retry(predicate=retry.if_exception_type(
100107
labelbox.exceptions.InternalServerError,
@@ -1384,3 +1391,23 @@ def get_catalog_slice(self, slice_id) -> CatalogSlice:
13841391
"""
13851392
res = self.execute(query_str, {'id': slice_id})
13861393
return Entity.CatalogSlice(self, res['getSavedQuery'])
1394+
1395+
def unarchive_root_feature_schema_node(self, ontology_id: str, root_feature_schema_id: str) -> bool:
1396+
"""
1397+
Returns true if the root feature schema node was successfully unarchived, false otherwise
1398+
Args:
1399+
root_feature_schema_id (str): The ID of the root level feature schema
1400+
ontology_id (str): The ID of the ontology
1401+
Returns:
1402+
bool
1403+
"""
1404+
ontology_endpoint = self.rest_endpoint + "/ontologies/" + ontology_id + '/root-feature-schemas/' + root_feature_schema_id + '/unarchive'
1405+
response = requests.patch(
1406+
ontology_endpoint,
1407+
headers=self.rest_endpoint_headers,
1408+
)
1409+
if response.status_code == 200:
1410+
return response.json()['didUnarchive']
1411+
else:
1412+
raise labelbox.exceptions.LabelboxError(
1413+
"Failed unarchive root feature schema node: ", response.text)

0 commit comments

Comments
 (0)