This commit is contained in:
hong-revo 2018-05-28 14:41:57 +10:00
Родитель 9cc9b9a435
Коммит 501a68d105
6 изменённых файлов: 46 добавлений и 14 удалений

Просмотреть файл

@ -25,6 +25,7 @@ S3method(print,storage_endpoint)
export(acquire_lease)
export(az_storage)
export(blob_container)
export(blob_endpoint)
export(break_lease)
export(change_lease)
export(create_azure_dir)
@ -38,6 +39,7 @@ export(delete_file_share)
export(download_azure_file)
export(download_blob)
export(download_from_url)
export(file_endpoint)
export(file_share)
export(get_azure_dir_properties)
export(get_azure_file_properties)

Просмотреть файл

@ -6,10 +6,10 @@
#' @param api_version The storage API version to use when interacting with the host. Currently defaults to `"2017-07-29"`.
#'
#' @details
#' This is the starting point for the client-side storage interface in AzureRMR.
#' This is the starting point for the client-side storage interface in AzureRMR. `storage_endpoint` is a generic function to create an endpoint for any type of Azure storage while `blob_endpoint` and `file_endpoint` create endpoints for those types.
#'
#' @return
#' An object of S3 class `"blob_endpoint"`, `"file_endpoint"`, `"queue_endpoint"` or `"table_endpoint"` depending on the type of endpoint. All of these also inherit from class `"storage_endpoint"`.
#' `storage_endpoint` returns an object of S3 class `"blob_endpoint"`, `"file_endpoint"`, `"queue_endpoint"` or `"table_endpoint"` depending on the type of endpoint. All of these also inherit from class `"storage_endpoint"`. `blob_endpoint` and `file_endpoint` return an object of the respective type.
#'
#' @seealso
#' [az_storage], [file_share], [create_file_share], [blob_container], [create_blob_container]
@ -18,9 +18,6 @@
#' @export
storage_endpoint <- function(endpoint, key=NULL, sas=NULL, api_version=getOption("azure_storage_api_version"))
{
if(is_empty(endpoint))
stop("Invalid endpoint type", call.=FALSE)
type <- sapply(c("blob", "file", "queue", "table"),
function(x) is_endpoint_url(endpoint, x))
if(!any(type))
@ -32,6 +29,31 @@ storage_endpoint <- function(endpoint, key=NULL, sas=NULL, api_version=getOption
obj
}
#' @rdname storage_endpoint
#' @export
blob_endpoint <- function(endpoint, key=NULL, sas=NULL, api_version=getOption("azure_storage_api_version"))
{
if(!is_endpoint_url(endpoint, "blob"))
stop("Not a blob endpoint", call.=FALSE)
obj <- list(url=endpoint, key=key, sas=sas, api_version=api_version)
class(obj) <- c("blob_endpoint", "storage_endpoint")
obj
}
#' @rdname storage_endpoint
#' @export
file_endpoint <- function(endpoint, key=NULL, sas=NULL, api_version=getOption("azure_storage_api_version"))
{
if(!is_endpoint_url(endpoint, "file"))
stop("Not a file endpoint", call.=FALSE)
obj <- list(url=endpoint, key=key, sas=sas, api_version=api_version)
class(obj) <- c("file_endpoint", "storage_endpoint")
obj
}
#' @rdname storage_endpoint
#' @export
print.storage_endpoint <- function(object)

Просмотреть файл

@ -34,12 +34,12 @@
#'
#' The client-side interface in AzureStor is implemented using S3 classes. This is for consistency with other data access packages in R, which mostly use S3. It also emphasises the distinction between Resource Manager (which is for interacting with the storage account itself) and the client (which is for accessing files and data stored in the account).
#'
#' To create a storage endpoint independently of Resource Manager (for example if you are a user without admin or owner access to the account), use the [storage_endpoint] function. This is called under the hood by the `get_xxxx_endpoint` methods.
#' To create a storage endpoint independently of Resource Manager (for example if you are a user without admin or owner access to the account), use the [blob_endpoint] or [file_endpoint] functions.
#'
#' If a storage endpoint is created without an access key and SAS, only public (anonymous) access is possible.
#'
#' @seealso
#' [storage_endpoint],
#' [blob_endpoint], [file_endpoint],
#' [create_storage_account], [get_storage_account], [delete_storage_account], [Date], [POSIXt],
#' [Azure Storage Provider API reference](https://docs.microsoft.com/en-us/rest/api/storagerp/),
#' [Azure Storage Services API reference](https://docs.microsoft.com/en-us/rest/api/storageservices/)
@ -89,12 +89,12 @@ public=list(
get_blob_endpoint=function(key=self$list_keys()[1], sas=NULL)
{
storage_endpoint(self$properties$primaryEndpoints$blob, key=key, sas=sas)
blob_endpoint(self$properties$primaryEndpoints$blob, key=key, sas=sas)
},
get_file_endpoint=function(key=self$list_keys()[1], sas=NULL)
{
storage_endpoint(self$properties$primaryEndpoints$file, key=key, sas=sas)
file_endpoint(self$properties$primaryEndpoints$file, key=key, sas=sas)
},
print=function(...)

Просмотреть файл

@ -146,7 +146,7 @@ is_endpoint_url <- function(url, type)
{
# endpoint URL must be of the form {scheme}://{acctname}.{type}.{etc}
type <- sprintf("^https?://[a-z0-9]+\\.%s\\.", type)
grepl(type, url)
is_url(url) && grepl(type, url)
}

Просмотреть файл

@ -53,13 +53,13 @@ The client-side interaction with a storage account is via an \emph{endpoint}. A
The client-side interface in AzureStor is implemented using S3 classes. This is for consistency with other data access packages in R, which mostly use S3. It also emphasises the distinction between Resource Manager (which is for interacting with the storage account itself) and the client (which is for accessing files and data stored in the account).
To create a storage endpoint independently of Resource Manager (for example if you are a user without admin or owner access to the account), use the \link{storage_endpoint} function. This is called under the hood by the \code{get_xxxx_endpoint} methods.
To create a storage endpoint independently of Resource Manager (for example if you are a user without admin or owner access to the account), use the \link{blob_endpoint} or \link{file_endpoint} functions.
If a storage endpoint is created without an access key and SAS, only public (anonymous) access is possible.
}
\seealso{
\link{storage_endpoint},
\link{blob_endpoint}, \link{file_endpoint},
\link{create_storage_account}, \link{get_storage_account}, \link{delete_storage_account}, \link{Date}, \link{POSIXt},
\href{https://docs.microsoft.com/en-us/rest/api/storagerp/}{Azure Storage Provider API reference},
\href{https://docs.microsoft.com/en-us/rest/api/storageservices/}{Azure Storage Services API reference}

Просмотреть файл

@ -7,12 +7,20 @@
\alias{file_endpoint}
\alias{queue_endpoint}
\alias{table_endpoint}
\alias{blob_endpoint}
\alias{file_endpoint}
\alias{print.storage_endpoint}
\title{Create a storage endpoint object}
\usage{
storage_endpoint(endpoint, key = NULL, sas = NULL,
api_version = getOption("azure_storage_api_version"))
blob_endpoint(endpoint, key = NULL, sas = NULL,
api_version = getOption("azure_storage_api_version"))
file_endpoint(endpoint, key = NULL, sas = NULL,
api_version = getOption("azure_storage_api_version"))
\method{print}{storage_endpoint}(object)
}
\arguments{
@ -25,13 +33,13 @@ storage_endpoint(endpoint, key = NULL, sas = NULL,
\item{api_version}{The storage API version to use when interacting with the host. Currently defaults to \code{"2017-07-29"}.}
}
\value{
An object of S3 class \code{"blob_endpoint"}, \code{"file_endpoint"}, \code{"queue_endpoint"} or \code{"table_endpoint"} depending on the type of endpoint. All of these also inherit from class \code{"storage_endpoint"}.
\code{storage_endpoint} returns an object of S3 class \code{"blob_endpoint"}, \code{"file_endpoint"}, \code{"queue_endpoint"} or \code{"table_endpoint"} depending on the type of endpoint. All of these also inherit from class \code{"storage_endpoint"}. \code{blob_endpoint} and \code{file_endpoint} return an object of the respective type.
}
\description{
Create a storage endpoint object
}
\details{
This is the starting point for the client-side storage interface in AzureRMR.
This is the starting point for the client-side storage interface in AzureRMR. \code{storage_endpoint} is a generic function to create an endpoint for any type of Azure storage while \code{blob_endpoint} and \code{file_endpoint} create endpoints for those types.
}
\seealso{
\link{az_storage}, \link{file_share}, \link{create_file_share}, \link{blob_container}, \link{create_blob_container}