Skip to content

Commit eb4bb1d

Browse files
authored
Add labkey.security.renameContainer (#92)
Rlabkey v2.11.0 - Add labkey.security.renameContainer and related documentation
1 parent 9afa6b2 commit eb4bb1d

11 files changed

+87
-4
lines changed

Rlabkey/DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: Rlabkey
2-
Version: 2.10.0
3-
Date: 2023-04-03
2+
Version: 2.11.0
3+
Date: 2023-05-02
44
Title: Data Exchange Between R and 'LabKey' Server
55
Author: Peter Hussey
66
Maintainer: Cory Nathe <[email protected]>

Rlabkey/NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export(labkey.security.createContainer)
3535
export(labkey.security.deleteContainer)
3636
export(labkey.security.getContainers)
3737
export(labkey.security.moveContainer)
38+
export(labkey.security.renameContainer)
3839
export(labkey.security.impersonateUser)
3940
export(labkey.security.stopImpersonating)
4041
export(labkey.provenance.createProvenanceParams)

Rlabkey/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Changes in 2.11.0
2+
o Add labkey.security.renameContainer
3+
14
Changes in 2.10.0
25
o Update documentation to reflect removal of "apikey|" and "session|" prefixes from API keys and session keys
36
o Issue 47202: Options to reduce payload of getContainers.api response: includeChildWorkbooks, includeStandardProperties

Rlabkey/R/labkey.security.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,33 @@ labkey.security.moveContainer <- function(baseUrl=NULL, folderPath, destinationP
9292
return (fromJSON(response))
9393
}
9494

95+
## Renames an existing container at the given container path. This action allows for updating the container
96+
## name, title, or both.
97+
##
98+
labkey.security.renameContainer <- function(baseUrl=NULL, folderPath, name=NULL, title=NULL, addAlias=TRUE)
99+
{
100+
baseUrl=labkey.getBaseUrl(baseUrl)
101+
102+
## check required parameters
103+
if (missing(baseUrl) || is.null(baseUrl) || missing(folderPath))
104+
stop (paste("A value must be specified for both baseUrl and folderPath."))
105+
if (missing(name) && missing(title))
106+
stop (paste("A value must be specified for either name or title."))
107+
108+
params <- list()
109+
if(is.null(name)==FALSE) {params <- c(params, list(name=name))}
110+
if(is.null(title)==FALSE) {params <- c(params, list(title=title))}
111+
if(is.null(addAlias)==FALSE) {params <- c(params, list(addAlias=addAlias))}
112+
113+
## normalize the folder path
114+
folderPath <- encodeFolderPath(folderPath)
115+
116+
url <- paste(baseUrl, "admin", folderPath, "renameContainer.api", sep="")
117+
response <- labkey.post(url, toJSON(params, auto_unbox=TRUE))
118+
119+
return (fromJSON(response))
120+
}
121+
95122
labkey.security.impersonateUser <- function(baseUrl = NULL, folderPath, userId = NULL, email = NULL)
96123
{
97124
baseUrl=labkey.getBaseUrl(baseUrl)

Rlabkey/man/Rlabkey-package.Rd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ schema objects (\code{labkey.getSchema}).
1818
\tabular{ll}{
1919
Package: \tab Rlabkey\cr
2020
Type: \tab Package\cr
21-
Version: \tab 2.10.0\cr
22-
Date: \tab 2023-04-03\cr
21+
Version: \tab 2.11.0\cr
22+
Date: \tab 2023-05-02\cr
2323
License: \tab Apache License 2.0\cr
2424
LazyLoad: \tab yes\cr
2525
}

Rlabkey/man/labkey.getFolders.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The available folders are returned as a three-column data frame containing
4747
\code{\link{labkey.security.createContainer}},
4848
\code{\link{labkey.security.deleteContainer}},
4949
\code{\link{labkey.security.moveContainer}}
50+
\code{\link{labkey.security.renameContainer}}
5051
}
5152
\examples{
5253
\dontrun{

Rlabkey/man/labkey.security.createContainer.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Returns information about the newly created container.
3333
\code{\link{labkey.security.getContainers}},
3434
\code{\link{labkey.security.deleteContainer}},
3535
\code{\link{labkey.security.moveContainer}}
36+
\code{\link{labkey.security.renameContainer}}
3637
}
3738
\examples{
3839
\dontrun{

Rlabkey/man/labkey.security.deleteContainer.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Returns a success message for the container deletion action.
2626
\code{\link{labkey.security.getContainers}},
2727
\code{\link{labkey.security.createContainer}},
2828
\code{\link{labkey.security.moveContainer}}
29+
\code{\link{labkey.security.renameContainer}}
2930
}
3031
\examples{
3132
\dontrun{

Rlabkey/man/labkey.security.getContainers.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ path, type, folderType, and effectivePermissions.
3636
\code{\link{labkey.security.createContainer}},
3737
\code{\link{labkey.security.deleteContainer}},
3838
\code{\link{labkey.security.moveContainer}}
39+
\code{\link{labkey.security.renameContainer}}
3940
}
4041
\examples{
4142
\dontrun{

Rlabkey/man/labkey.security.moveContainer.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Returns a success message for the container move action with the new path.
3131
\code{\link{labkey.security.getContainers}},
3232
\code{\link{labkey.security.createContainer}},
3333
\code{\link{labkey.security.deleteContainer}}
34+
\code{\link{labkey.security.renameContainer}}
3435
}
3536
\examples{
3637
\dontrun{
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
\name{labkey.security.renameContainer}
2+
\alias{labkey.security.renameContainer}
3+
\title{Rename an existing container at the given container path}
4+
\description{
5+
Renames an existing container at the given container path.
6+
This action allows for updating the container name, title, or both.
7+
}
8+
\usage{
9+
labkey.security.renameContainer(baseUrl=NULL, folderPath,
10+
name=NULL, title=NULL, addAlias=TRUE)
11+
}
12+
\arguments{
13+
\item{baseUrl}{A string specifying the \code{baseUrl} for the labkey server.}
14+
\item{folderPath}{A string specifying the \code{folderPath} to be renamed. Additionally, the container entity id is also valid.}
15+
\item{name}{The new container name. If not specified, the container name will not be changed.}
16+
\item{title}{The new container title. If not specified, the container name will be used.}
17+
\item{addAlias}{Add alias of current container path for the current container name (defaults to true).}
18+
}
19+
\details{
20+
This function renames an existing container at the given container path on the LabKey server.
21+
A new container name and/or title must be specified. If a new name is provided but not a title, the name will also
22+
be set as the container title.
23+
}
24+
\value{
25+
Returns a success message for the container rename action.
26+
}
27+
28+
\author{Cory Nathe}
29+
\seealso{
30+
\code{\link{labkey.getFolders}},
31+
\code{\link{labkey.security.getContainers}},
32+
\code{\link{labkey.security.createContainer}},
33+
\code{\link{labkey.security.deleteContainer}}
34+
\code{\link{labkey.security.moveContainer}}
35+
}
36+
\examples{
37+
\dontrun{
38+
39+
library(Rlabkey)
40+
41+
labkey.security.renameContainer(baseUrl="http://labkey/", folderPath = "/home/OriginalFolder",
42+
name = "NewFolderName", title = "New Folder Title", addAlias = TRUE
43+
)
44+
45+
}
46+
}
47+
\keyword{IO}

0 commit comments

Comments
 (0)