зеркало из https://github.com/Azure/AzureStor.git
add service arg to storage_endpoint
This commit is contained in:
Родитель
2eb4e0ae55
Коммит
78c7e46160
2
NEWS.md
2
NEWS.md
|
@ -5,6 +5,8 @@
|
||||||
- Fix a bug that caused `list_blobs` to fail when leases were present.
|
- Fix a bug that caused `list_blobs` to fail when leases were present.
|
||||||
- Use a raw connection instead of a raw vector when calling `readr::read_delim` and `read_csv2`. This works around an issue introduced in readr 1.4.0 (#85, #86).
|
- Use a raw connection instead of a raw vector when calling `readr::read_delim` and `read_csv2`. This works around an issue introduced in readr 1.4.0 (#85, #86).
|
||||||
- Update client API version to "2020-04-08". In particular, this allows specifying `resource_type="d"` when creating a service or user delegation SAS for blob storage.
|
- Update client API version to "2020-04-08". In particular, this allows specifying `resource_type="d"` when creating a service or user delegation SAS for blob storage.
|
||||||
|
- Add an optional `service` argument to `storage_endpoint`, to specify the service in question: blob, file, ADLS2, queue or table. This allows use of the generic endpoint function with URLs that don't fit the usual pattern where the service is part of the hostname, eg custom domain names, IP addresses, etc.
|
||||||
|
- For the same, reason, remove the warning about an unrecognised endpoint URL from `blob_endpoint`, `file_endpoint` and `adls_endpoint`.
|
||||||
|
|
||||||
# AzureStor 3.4.1
|
# AzureStor 3.4.1
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#' @param token An Azure Active Directory (AAD) authentication token. This can be either a string, or an object of class AzureToken created by [AzureRMR::get_azure_token]. The latter is the recommended way of doing it, as it allows for automatic refreshing of expired tokens.
|
#' @param token An Azure Active Directory (AAD) authentication token. This can be either a string, or an object of class AzureToken created by [AzureRMR::get_azure_token]. The latter is the recommended way of doing it, as it allows for automatic refreshing of expired tokens.
|
||||||
#' @param sas A shared access signature (SAS) for the account.
|
#' @param sas A shared access signature (SAS) for the account.
|
||||||
#' @param api_version The storage API version to use when interacting with the host. Defaults to `"2019-07-07"`.
|
#' @param api_version The storage API version to use when interacting with the host. Defaults to `"2019-07-07"`.
|
||||||
|
#' @param service For `storage_endpoint`, the service endpoint type: either "blob", "file", "adls", "queue" or "table". If this is missing, it is inferred from the endpoint hostname.
|
||||||
#' @param x For the print method, a storage endpoint object.
|
#' @param x For the print method, a storage endpoint object.
|
||||||
#' @param ... For the print method, further arguments passed to lower-level functions.
|
#' @param ... For the print method, further arguments passed to lower-level functions.
|
||||||
#'
|
#'
|
||||||
|
@ -62,24 +63,22 @@
|
||||||
#' }
|
#' }
|
||||||
#' @aliases endpoint blob_endpoint file_endpoint queue_endpoint table_endpoint
|
#' @aliases endpoint blob_endpoint file_endpoint queue_endpoint table_endpoint
|
||||||
#' @export
|
#' @export
|
||||||
storage_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL, api_version)
|
storage_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL, api_version, service)
|
||||||
{
|
{
|
||||||
type <- sapply(c("blob", "file", "queue", "table", "adls"),
|
if(missing(service))
|
||||||
function(x) is_endpoint_url(endpoint, x))
|
|
||||||
if(!any(type))
|
|
||||||
stop("Unknown endpoint type", call.=FALSE)
|
|
||||||
type <- names(type)[type]
|
|
||||||
|
|
||||||
# handle api version wart
|
|
||||||
if(missing(api_version))
|
|
||||||
{
|
{
|
||||||
api_version <- if(type == "adls")
|
service <- sapply(c("blob", "file", "queue", "table", "adls"),
|
||||||
getOption("azure_storage_api_version")
|
function(x) is_endpoint_url(endpoint, x))
|
||||||
else getOption("azure_storage_api_version")
|
if(!any(service))
|
||||||
|
stop("Unknown endpoint service", call.=FALSE)
|
||||||
|
service <- names(service)[service]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(missing(api_version))
|
||||||
|
api_version <- getOption("azure_storage_api_version")
|
||||||
|
|
||||||
obj <- list(url=endpoint, key=key, token=token, sas=sas, api_version=api_version)
|
obj <- list(url=endpoint, key=key, token=token, sas=sas, api_version=api_version)
|
||||||
class(obj) <- c(paste0(type, "_endpoint"), "storage_endpoint")
|
class(obj) <- c(paste0(service, "_endpoint"), "storage_endpoint")
|
||||||
obj
|
obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,9 +87,6 @@ storage_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL, api_versi
|
||||||
blob_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL,
|
blob_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL,
|
||||||
api_version=getOption("azure_storage_api_version"))
|
api_version=getOption("azure_storage_api_version"))
|
||||||
{
|
{
|
||||||
if(!is_endpoint_url(endpoint, "blob"))
|
|
||||||
warning("Not a recognised blob endpoint", call.=FALSE)
|
|
||||||
|
|
||||||
obj <- list(url=endpoint, key=key, token=token, sas=sas, api_version=api_version)
|
obj <- list(url=endpoint, key=key, token=token, sas=sas, api_version=api_version)
|
||||||
class(obj) <- c("blob_endpoint", "storage_endpoint")
|
class(obj) <- c("blob_endpoint", "storage_endpoint")
|
||||||
obj
|
obj
|
||||||
|
@ -101,9 +97,6 @@ blob_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL,
|
||||||
file_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL,
|
file_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL,
|
||||||
api_version=getOption("azure_storage_api_version"))
|
api_version=getOption("azure_storage_api_version"))
|
||||||
{
|
{
|
||||||
if(!is_endpoint_url(endpoint, "file"))
|
|
||||||
warning("Not a recognised file endpoint", call.=FALSE)
|
|
||||||
|
|
||||||
obj <- list(url=endpoint, key=key, token=token, sas=sas, api_version=api_version)
|
obj <- list(url=endpoint, key=key, token=token, sas=sas, api_version=api_version)
|
||||||
class(obj) <- c("file_endpoint", "storage_endpoint")
|
class(obj) <- c("file_endpoint", "storage_endpoint")
|
||||||
obj
|
obj
|
||||||
|
@ -114,9 +107,6 @@ file_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL,
|
||||||
adls_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL,
|
adls_endpoint <- function(endpoint, key=NULL, token=NULL, sas=NULL,
|
||||||
api_version=getOption("azure_storage_api_version"))
|
api_version=getOption("azure_storage_api_version"))
|
||||||
{
|
{
|
||||||
if(!is_endpoint_url(endpoint, "adls"))
|
|
||||||
warning("Not a recognised ADLS Gen2 endpoint", call.=FALSE)
|
|
||||||
|
|
||||||
obj <- list(url=endpoint, key=key, token=token, sas=sas, api_version=api_version)
|
obj <- list(url=endpoint, key=key, token=token, sas=sas, api_version=api_version)
|
||||||
class(obj) <- c("adls_endpoint", "storage_endpoint")
|
class(obj) <- c("adls_endpoint", "storage_endpoint")
|
||||||
obj
|
obj
|
||||||
|
|
|
@ -9,9 +9,14 @@ opts <- options(azure_storage_progress_bar=FALSE)
|
||||||
|
|
||||||
test_that("Blob storage methods work",
|
test_that("Blob storage methods work",
|
||||||
{
|
{
|
||||||
expect_warning(endp <- blob_endpoint("http://127.0.0.1:10000/account1", key="key1"))
|
endp <- blob_endpoint("http://127.0.0.1:10000/account1", key="key1")
|
||||||
expect_is(endp, "blob_endpoint")
|
expect_is(endp, "blob_endpoint")
|
||||||
|
|
||||||
|
expect_error(storage_endpoint("http://127.0.0.1:10000/account1", key="key1"))
|
||||||
|
|
||||||
|
endp2 <- storage_endpoint("http://127.0.0.1:10000/account1", key="key1", service="blob")
|
||||||
|
expect_is(endp2, "blob_endpoint")
|
||||||
|
|
||||||
expect_is(list_blob_containers(endp), "list")
|
expect_is(list_blob_containers(endp), "list")
|
||||||
cont <- create_blob_container(endp, "container1")
|
cont <- create_blob_container(endp, "container1")
|
||||||
expect_is(cont, "blob_container")
|
expect_is(cont, "blob_container")
|
||||||
|
|
Загрузка…
Ссылка в новой задаче