Skip to content

Commit 89c62ab

Browse files
authored
Support Renaming Containers (#57)
1 parent b3233f0 commit 89c62ab

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

CHANGE.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
LabKey Python Client API News
33
+++++++++++
44

5+
What's New in the LabKey 2.4.2 package
6+
==============================
7+
8+
*Release date: TBD*
9+
- Container API - add ability to rename containers
10+
511
What's New in the LabKey 2.4.1 package
612
==============================
713

labkey/container.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,31 @@ def delete(server_context: ServerContext, container_path: str = None) -> any:
4545
return server_context.make_request(url, headers=headers)
4646

4747

48+
def rename(
49+
server_context: ServerContext,
50+
name: str = None,
51+
title: str = None,
52+
add_alias: bool = True,
53+
container_path: str = None,
54+
) -> any:
55+
"""
56+
Renames a container at the given container_path, or at the server_context's container path
57+
:param server_context: A LabKey server context. See utils.create_server_context.
58+
:param name: The new name of the container.
59+
:param title: The new title of the container.
60+
:param add_alias: Whether to add a folder alias for the folder's current name.
61+
:param container_path: The path of the container to rename.
62+
:return:
63+
"""
64+
url = server_context.build_url("admin", "renameContainer.api", container_path)
65+
payload = {
66+
"name": name,
67+
"title": title,
68+
"addAlias": add_alias,
69+
}
70+
return server_context.make_request(url, json=payload)
71+
72+
4873
class ContainerWrapper:
4974
"""
5075
Wrapper for all of the API methods exposed in the container module. Used by the APIWrapper class.
@@ -68,3 +93,8 @@ def create(
6893

6994
def delete(self, container_path: str = None):
7095
return delete(self.server_context, container_path)
96+
97+
def rename(
98+
self, name: str = None, title: str = None, add_alias: bool = True, container_path: str = None
99+
):
100+
return rename(self.server_context, name, title, add_alias, container_path)

0 commit comments

Comments
 (0)