From 6b9675a07d910d69953d72f3812982e174a30ab6 Mon Sep 17 00:00:00 2001 From: XingY Date: Thu, 18 Jun 2026 19:18:20 -0700 Subject: [PATCH 1/2] Allow require reason on storage changes --- Rlabkey/DESCRIPTION | 4 ++-- Rlabkey/NEWS | 3 +++ Rlabkey/R/labkey.storage.R | 12 +++++++++--- Rlabkey/man/Rlabkey-package.Rd | 4 ++-- Rlabkey/man/labkey.storage.delete.Rd | 13 ++++++++++++- Rlabkey/man/labkey.storage.update.Rd | 13 ++++++++++++- 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/Rlabkey/DESCRIPTION b/Rlabkey/DESCRIPTION index fe58ab1..e7a114f 100755 --- a/Rlabkey/DESCRIPTION +++ b/Rlabkey/DESCRIPTION @@ -1,6 +1,6 @@ Package: Rlabkey -Version: 3.4.6 -Date: 2026-02-17 +Version: 3.4.X +Date: 2026-X Title: Data Exchange Between R and 'LabKey' Server Authors@R: c(person(given = "Peter", family = "Hussey", diff --git a/Rlabkey/NEWS b/Rlabkey/NEWS index c804471..f52968e 100644 --- a/Rlabkey/NEWS +++ b/Rlabkey/NEWS @@ -1,3 +1,6 @@ +Changes in 3.4.7 + o Add auditUserComment parameter to labkey.storage.create, labkey.storage.update, and labkey.storage.delete for attaching a reason to the audit log record + Changes in 3.4.6 o Incorporate new filter types for Array (Multi-value text choice) fields o Update listToMatrix to handle cases where the list elements are an array of strings, which will return a comma separated string in the response diff --git a/Rlabkey/R/labkey.storage.R b/Rlabkey/R/labkey.storage.R index a5e35ed..3663679 100644 --- a/Rlabkey/R/labkey.storage.R +++ b/Rlabkey/R/labkey.storage.R @@ -14,7 +14,7 @@ # limitations under the License. ## -labkey.storage.create <- function(baseUrl=NULL, folderPath, type, props) +labkey.storage.create <- function(baseUrl=NULL, folderPath, type, props, auditUserComment=NULL) { baseUrl=labkey.getBaseUrl(baseUrl) @@ -26,13 +26,15 @@ labkey.storage.create <- function(baseUrl=NULL, folderPath, type, props) stop (paste("Storage API props must be a list data structure.")) params <- list(type = type, props = props) + if (!is.null(auditUserComment)) + params$auditUserComment <- auditUserComment url <- labkey.buildURL(baseUrl, "storage", "create.api", folderPath) response <- labkey.post(url, toJSON(params, auto_unbox=TRUE)) return (fromJSON(response)) } -labkey.storage.update <- function(baseUrl=NULL, folderPath, type, props) +labkey.storage.update <- function(baseUrl=NULL, folderPath, type, props, auditUserComment=NULL) { baseUrl=labkey.getBaseUrl(baseUrl) @@ -44,13 +46,15 @@ labkey.storage.update <- function(baseUrl=NULL, folderPath, type, props) stop (paste("Storage API props must be a list data structure.")) params <- list(type = type, props = props) + if (!is.null(auditUserComment)) + params$auditUserComment <- auditUserComment url <- labkey.buildURL(baseUrl, "storage", "update.api", folderPath) response <- labkey.post(url, toJSON(params, auto_unbox=TRUE)) return (fromJSON(response)) } -labkey.storage.delete <- function(baseUrl=NULL, folderPath, type, rowId) +labkey.storage.delete <- function(baseUrl=NULL, folderPath, type, rowId, auditUserComment=NULL) { baseUrl=labkey.getBaseUrl(baseUrl) @@ -59,6 +63,8 @@ labkey.storage.delete <- function(baseUrl=NULL, folderPath, type, rowId) stop (paste("A value must be specified for each of baseUrl, folderPath, type, and rowId.")) params <- list(type = type, props = list(rowId = rowId)) + if (!is.null(auditUserComment)) + params$auditUserComment <- auditUserComment url <- labkey.buildURL(baseUrl, "storage", "delete.api", folderPath) response <- labkey.post(url, toJSON(params, auto_unbox=TRUE)) diff --git a/Rlabkey/man/Rlabkey-package.Rd b/Rlabkey/man/Rlabkey-package.Rd index 8355fa8..f0de1ae 100755 --- a/Rlabkey/man/Rlabkey-package.Rd +++ b/Rlabkey/man/Rlabkey-package.Rd @@ -18,8 +18,8 @@ schema objects (\code{labkey.getSchema}). \tabular{ll}{ Package: \tab Rlabkey\cr Type: \tab Package\cr -Version: \tab 3.4.6\cr -Date: \tab 2026-02-17\cr +Version: \tab 3.4.X\cr +Date: \tab 2026-X\cr License: \tab Apache License 2.0\cr LazyLoad: \tab yes\cr } diff --git a/Rlabkey/man/labkey.storage.delete.Rd b/Rlabkey/man/labkey.storage.delete.Rd index f4fa864..5715d5e 100644 --- a/Rlabkey/man/labkey.storage.delete.Rd +++ b/Rlabkey/man/labkey.storage.delete.Rd @@ -9,13 +9,14 @@ Storage items can be of the following types: Physical Location, Freezer, Primary Storage Unit Type, or Terminal Storage Location. } \usage{ -labkey.storage.delete(baseUrl=NULL, folderPath, type, rowId) +labkey.storage.delete(baseUrl=NULL, folderPath, type, rowId, auditUserComment=NULL) } \arguments{ \item{baseUrl}{a string specifying the \code{baseUrl}for the LabKey server} \item{folderPath}{a string specifying the \code{folderPath} } \item{type}{a string specifying the type of storage item to delete } \item{rowId}{the primary key of the storage item to delete } + \item{auditUserComment}{optional reason text that will be attached to the audit log record for this storage change. } } \value{ A list containing a data element with the property values for the deleted storage item. @@ -75,6 +76,16 @@ freezer <- labkey.storage.delete( type="Freezer", rowId=freezer$data$rowId ) + +## supply an auditUserComment ("reason for change") that will be attached to the +## audit log record for this delete +plateType <- labkey.storage.delete( + baseUrl="http://labkey/", + folderPath="home", + type="Storage Unit Type", + rowId=plateType$data$rowId, + auditUserComment="Retiring this plate type per lab SOP-42" +) } } \keyword{IO} diff --git a/Rlabkey/man/labkey.storage.update.Rd b/Rlabkey/man/labkey.storage.update.Rd index 9a7fd21..ab803de 100644 --- a/Rlabkey/man/labkey.storage.update.Rd +++ b/Rlabkey/man/labkey.storage.update.Rd @@ -7,13 +7,14 @@ Storage items can be of the following types: Physical Location, Freezer, Primary Storage Unit Type, or Terminal Storage Location. } \usage{ -labkey.storage.update(baseUrl=NULL, folderPath, type, props) +labkey.storage.update(baseUrl=NULL, folderPath, type, props, auditUserComment=NULL) } \arguments{ \item{baseUrl}{a string specifying the \code{baseUrl}for the LabKey server} \item{folderPath}{a string specifying the \code{folderPath} } \item{type}{a string specifying the type of storage item to update } \item{props}{a list properties for the storage item (i.e. name, description, etc.), must include the RowId primary key } + \item{auditUserComment}{optional reason text that will be attached to the audit log record for this storage change. } } \value{ A list containing a data element with the property values for the updated storage item. @@ -43,6 +44,16 @@ plateType = labkey.storage.update( type="Storage Unit Type", props=list(rowId=plateType$data$rowId, positionFormat="NumAlpha", positionOrder="ColumnRow" ) ) + +## supply an auditUserComment ("reason for change") that will be attached to the +## audit log record for this update +plateType = labkey.storage.update( + baseUrl="http://labkey/", + folderPath="home", + type="Storage Unit Type", + props=list(rowId=plateType$data$rowId, description="Switched to AlphaNum positions"), + auditUserComment="Switching to AlphaNum positioning per lab SOP-42" +) } } \keyword{IO} From 5567f091481f245dbc61a288c8b2f6b6a8bc054f Mon Sep 17 00:00:00 2001 From: XingY Date: Mon, 22 Jun 2026 14:43:23 -0700 Subject: [PATCH 2/2] Update apis --- Rlabkey/NEWS | 3 ++- Rlabkey/R/labkey.storage.R | 13 +++++-------- Rlabkey/man/labkey.storage.update.Rd | 16 +++++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Rlabkey/NEWS b/Rlabkey/NEWS index f52968e..f980866 100644 --- a/Rlabkey/NEWS +++ b/Rlabkey/NEWS @@ -1,5 +1,6 @@ Changes in 3.4.7 - o Add auditUserComment parameter to labkey.storage.create, labkey.storage.update, and labkey.storage.delete for attaching a reason to the audit log record + o Pass auditUserComment to labkey.storage.delete for attaching a reason to the audit log record + o labkey.storage.create and labkey.storage.update now accept an optional auditUserComment entry inside the props list (recorded as the "Reason" on the resulting audit event) Changes in 3.4.6 o Incorporate new filter types for Array (Multi-value text choice) fields diff --git a/Rlabkey/R/labkey.storage.R b/Rlabkey/R/labkey.storage.R index 3663679..30e3ae8 100644 --- a/Rlabkey/R/labkey.storage.R +++ b/Rlabkey/R/labkey.storage.R @@ -14,7 +14,7 @@ # limitations under the License. ## -labkey.storage.create <- function(baseUrl=NULL, folderPath, type, props, auditUserComment=NULL) +labkey.storage.create <- function(baseUrl=NULL, folderPath, type, props) { baseUrl=labkey.getBaseUrl(baseUrl) @@ -26,15 +26,13 @@ labkey.storage.create <- function(baseUrl=NULL, folderPath, type, props, auditUs stop (paste("Storage API props must be a list data structure.")) params <- list(type = type, props = props) - if (!is.null(auditUserComment)) - params$auditUserComment <- auditUserComment url <- labkey.buildURL(baseUrl, "storage", "create.api", folderPath) response <- labkey.post(url, toJSON(params, auto_unbox=TRUE)) return (fromJSON(response)) } -labkey.storage.update <- function(baseUrl=NULL, folderPath, type, props, auditUserComment=NULL) +labkey.storage.update <- function(baseUrl=NULL, folderPath, type, props) { baseUrl=labkey.getBaseUrl(baseUrl) @@ -46,8 +44,6 @@ labkey.storage.update <- function(baseUrl=NULL, folderPath, type, props, auditUs stop (paste("Storage API props must be a list data structure.")) params <- list(type = type, props = props) - if (!is.null(auditUserComment)) - params$auditUserComment <- auditUserComment url <- labkey.buildURL(baseUrl, "storage", "update.api", folderPath) response <- labkey.post(url, toJSON(params, auto_unbox=TRUE)) @@ -62,9 +58,10 @@ labkey.storage.delete <- function(baseUrl=NULL, folderPath, type, rowId, auditUs if (missing(baseUrl) || is.null(baseUrl) || missing(folderPath) || missing(type) || missing(rowId)) stop (paste("A value must be specified for each of baseUrl, folderPath, type, and rowId.")) - params <- list(type = type, props = list(rowId = rowId)) + props <- list(rowId = rowId) if (!is.null(auditUserComment)) - params$auditUserComment <- auditUserComment + props$auditUserComment <- auditUserComment + params <- list(type = type, props = props) url <- labkey.buildURL(baseUrl, "storage", "delete.api", folderPath) response <- labkey.post(url, toJSON(params, auto_unbox=TRUE)) diff --git a/Rlabkey/man/labkey.storage.update.Rd b/Rlabkey/man/labkey.storage.update.Rd index ab803de..71c6dd5 100644 --- a/Rlabkey/man/labkey.storage.update.Rd +++ b/Rlabkey/man/labkey.storage.update.Rd @@ -7,14 +7,13 @@ Storage items can be of the following types: Physical Location, Freezer, Primary Storage Unit Type, or Terminal Storage Location. } \usage{ -labkey.storage.update(baseUrl=NULL, folderPath, type, props, auditUserComment=NULL) +labkey.storage.update(baseUrl=NULL, folderPath, type, props) } \arguments{ \item{baseUrl}{a string specifying the \code{baseUrl}for the LabKey server} \item{folderPath}{a string specifying the \code{folderPath} } \item{type}{a string specifying the type of storage item to update } - \item{props}{a list properties for the storage item (i.e. name, description, etc.), must include the RowId primary key } - \item{auditUserComment}{optional reason text that will be attached to the audit log record for this storage change. } + \item{props}{a list properties for the storage item (i.e. name, description, etc.), must include the RowId primary key. May also include an optional \code{auditUserComment} entry, which is recorded as the "Reason" on the resulting audit event. } } \value{ A list containing a data element with the property values for the updated storage item. @@ -45,14 +44,17 @@ plateType = labkey.storage.update( props=list(rowId=plateType$data$rowId, positionFormat="NumAlpha", positionOrder="ColumnRow" ) ) -## supply an auditUserComment ("reason for change") that will be attached to the -## audit log record for this update +## include an auditUserComment in the props list to attach a "Reason" to +## the audit log record for this update plateType = labkey.storage.update( baseUrl="http://labkey/", folderPath="home", type="Storage Unit Type", - props=list(rowId=plateType$data$rowId, description="Switched to AlphaNum positions"), - auditUserComment="Switching to AlphaNum positioning per lab SOP-42" + props=list( + rowId=plateType$data$rowId, + description="Switched to AlphaNum positions", + auditUserComment="Switching to AlphaNum positioning per lab SOP-42" + ) ) } }