зеркало из https://github.com/Azure/AzureStor.git
blob leasing
This commit is contained in:
Родитель
5b795132d9
Коммит
8f09e0b433
|
@ -117,49 +117,3 @@ delete_azure_blob <- function(container, blob, confirm=TRUE)
|
|||
}
|
||||
|
||||
|
||||
acquire_blob_lease <- function(container, duration=60, lease=NULL)
|
||||
{
|
||||
headers <- list("x-ms-lease-action"="acquire", "x-ms-lease-duration"=duration)
|
||||
if(!is_empty(lease))
|
||||
headers <- c(headers, list("x-ms-proposed-lease-id"=lease))
|
||||
res <- do_container_op(container, options=list(comp="lease", restype="container"), headers=headers,
|
||||
http_verb="PUT", http_status_handler="pass")
|
||||
httr::stop_for_status(res)
|
||||
headers(res)[["x-ms-lease-id"]]
|
||||
}
|
||||
|
||||
|
||||
break_blob_lease <- function(container, period=NULL)
|
||||
{
|
||||
headers <- list("x-ms-lease-action"="break")
|
||||
if(!is_empty(period))
|
||||
headers=c(headers, list("x-ms-lease-break-period"=period))
|
||||
do_container_op(container, options=list(comp="lease", restype="container"), headers=headers,
|
||||
http_verb="PUT")
|
||||
}
|
||||
|
||||
|
||||
release_blob_lease <- function(container, lease)
|
||||
{
|
||||
headers <- list("x-ms-lease-id"=lease, "x-ms-lease-action"="release")
|
||||
do_container_op(container, options=list(comp="lease", restype="container"), headers=headers,
|
||||
http_verb="PUT")
|
||||
}
|
||||
|
||||
|
||||
renew_blob_lease <- function(container, lease)
|
||||
{
|
||||
headers <- list("x-ms-lease-id"=lease, "x-ms-lease-action"="renew")
|
||||
do_container_op(container, options=list(comp="lease", restype="container"), headers=headers,
|
||||
http_verb="PUT")
|
||||
}
|
||||
|
||||
|
||||
change_blob_lease <- function(container, lease, new_lease)
|
||||
{
|
||||
headers <- list("x-ms-lease-id"=lease, "x-ms-lease-action"="change", "x-ms-proposed-lease-id"=new_lease)
|
||||
res <- do_container_op(container, options=list(comp="lease", restype="container"), headers=headers,
|
||||
http_verb="PUT", http_status_handler="pass")
|
||||
httr::stop_for_status(res)
|
||||
headers(res)[["x-ms-lease-id"]]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
#' @export
|
||||
acquire_lease <- function(container, blob="", duration=60, lease=NULL)
|
||||
{
|
||||
headers <- list("x-ms-lease-action"="acquire", "x-ms-lease-duration"=duration)
|
||||
if(!is_empty(lease))
|
||||
headers <- c(headers, list("x-ms-proposed-lease-id"=lease))
|
||||
res <- do_container_op(container, blob, options=list(comp="lease", restype="container"), headers=headers,
|
||||
http_verb="PUT", http_status_handler="pass")
|
||||
httr::stop_for_status(res, storage_error_message(res))
|
||||
httr::headers(res)[["x-ms-lease-id"]]
|
||||
}
|
||||
|
||||
|
||||
#' @export
|
||||
break_lease <- function(container, blob="", period=NULL)
|
||||
{
|
||||
headers <- list("x-ms-lease-action"="break")
|
||||
if(!is_empty(period))
|
||||
headers=c(headers, list("x-ms-lease-break-period"=period))
|
||||
do_container_op(container, blob, options=list(comp="lease", restype="container"), headers=headers,
|
||||
http_verb="PUT")
|
||||
}
|
||||
|
||||
|
||||
#' @export
|
||||
release_lease <- function(container, blob="", lease)
|
||||
{
|
||||
headers <- list("x-ms-lease-id"=lease, "x-ms-lease-action"="release")
|
||||
do_container_op(container, blob, options=list(comp="lease", restype="container"), headers=headers,
|
||||
http_verb="PUT")
|
||||
}
|
||||
|
||||
|
||||
#' @export
|
||||
renew_lease <- function(container, blob="", lease)
|
||||
{
|
||||
headers <- list("x-ms-lease-id"=lease, "x-ms-lease-action"="renew")
|
||||
do_container_op(container, blob, options=list(comp="lease", restype="container"), headers=headers,
|
||||
http_verb="PUT")
|
||||
}
|
||||
|
||||
|
||||
#' @export
|
||||
change_lease <- function(container, blob="", lease, new_lease)
|
||||
{
|
||||
headers <- list("x-ms-lease-id"=lease, "x-ms-lease-action"="change", "x-ms-proposed-lease-id"=new_lease)
|
||||
res <- do_container_op(container, blob, options=list(comp="lease", restype="container"), headers=headers,
|
||||
http_verb="PUT", http_status_handler="pass")
|
||||
httr::stop_for_status(res, storage_error_message(res))
|
||||
httr::headers(res)[["x-ms-lease-id"]]
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
az_datalake_client <- R6::R6Class("az_blob_client",
|
||||
|
||||
public=list(
|
||||
|
||||
initialize=function(...) { },
|
||||
|
||||
datalake_upload=function(...) { },
|
||||
datalake_download=function(...) { }
|
||||
))
|
||||
|
|
@ -17,7 +17,7 @@ get_storage_properties.storage_endpoint <- function(object)
|
|||
get_storage_properties.blob_container <- function(object)
|
||||
{
|
||||
res <- do_container_op(object, options=list(restype="container"), http_status_handler="pass")
|
||||
httr::stop_for_status(res, )
|
||||
httr::stop_for_status(res, storage_error_message(res))
|
||||
httr::headers(res)
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ get_storage_properties.blob_container <- function(object)
|
|||
get_storage_properties.file_share <- function(object)
|
||||
{
|
||||
res <- do_container_op(object, options=list(restype="share"), http_status_handler="pass")
|
||||
httr::stop_for_status(res)
|
||||
httr::stop_for_status(res, storage_error_message(res))
|
||||
httr::headers(res)
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ get_storage_properties.file_share <- function(object)
|
|||
get_azure_blob_properties <- function(container, blob)
|
||||
{
|
||||
res <- do_container_op(container, blob, http_verb="HEAD", http_status_handler="pass")
|
||||
httr::stop_for_status(res)
|
||||
httr::stop_for_status(res, storage_error_message(res))
|
||||
httr::headers(res)
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ get_azure_blob_properties <- function(container, blob)
|
|||
get_azure_file_properties <- function(share, file)
|
||||
{
|
||||
res <- do_container_op(share, file, http_verb="HEAD", http_status_handler="pass")
|
||||
httr::stop_for_status(res)
|
||||
httr::stop_for_status(res, storage_error_message(res))
|
||||
httr::headers(res)
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ get_azure_file_properties <- function(share, file)
|
|||
get_azure_dir_properties <- function(share, dir)
|
||||
{
|
||||
res <- do_container_op(share, dir, options=list(restype="directory"), http_verb="HEAD", http_status_handler="pass")
|
||||
httr::stop_for_status(res)
|
||||
httr::stop_for_status(res, storage_error_message(res))
|
||||
httr::headers(res)
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,7 @@ do_storage_call <- function(endpoint_url, path, options=list(), headers=list(),
|
|||
if(handler != "pass")
|
||||
{
|
||||
handler <- get(paste0(handler, "_for_status"), getNamespace("httr"))
|
||||
handler(response, paste0("complete Storage Services operation. Message:\n",
|
||||
sub("\\.$", "", storage_error_message(response))))
|
||||
handler(response, storage_error_message(response))
|
||||
|
||||
# if file was written to disk, printing content(*) will read it back into memory!
|
||||
if(inherits(response$content, "path"))
|
||||
|
@ -62,15 +61,18 @@ do_storage_call <- function(endpoint_url, path, options=list(), headers=list(),
|
|||
}
|
||||
|
||||
|
||||
storage_error_message <- function(response)
|
||||
storage_error_message <- function(response, for_httr=TRUE)
|
||||
{
|
||||
cont <- suppressMessages(httr::content(response))
|
||||
if(inherits(cont, "xml_node"))
|
||||
cont <- httr::content(response)
|
||||
msg <- if(inherits(cont, "xml_node"))
|
||||
{
|
||||
cont <- xml2::as_list(cont)
|
||||
paste0(unlist(cont), collapse="\n")
|
||||
}
|
||||
else NULL
|
||||
if(for_httr)
|
||||
paste0("complete Storage Services operation. Message:\n", sub("\\.$", "", msg))
|
||||
else msg
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче