зеркало из https://github.com/Azure/AzureRMR.git
set package-wide default API version
This commit is contained in:
Родитель
730998e6dc
Коммит
7810d18d95
|
@ -0,0 +1,6 @@
|
||||||
|
.onLoad <- function(libname, pkgname)
|
||||||
|
{
|
||||||
|
azure_api_version="2018-05-01"
|
||||||
|
options(azure_api_version=azure_api_version)
|
||||||
|
invisible(NULL)
|
||||||
|
}
|
|
@ -68,9 +68,9 @@ private=list(
|
||||||
# obtain subscription IDs owned by this app
|
# obtain subscription IDs owned by this app
|
||||||
set_subs=function()
|
set_subs=function()
|
||||||
{
|
{
|
||||||
cont <- call_azure_sm(private$token, subscription="", operation="", api_version="2016-06-01")
|
cont <- call_azure_sm(private$token, subscription="", operation="")
|
||||||
|
|
||||||
df <- lapply(cont, data.frame, stringsAsFactors=FALSE)
|
df <- lapply(cont$value, data.frame, stringsAsFactors=FALSE)
|
||||||
df <- do.call(rbind, df)
|
df <- do.call(rbind, df)
|
||||||
|
|
||||||
# update subscription IDs; notify if more than one found
|
# update subscription IDs; notify if more than one found
|
||||||
|
|
|
@ -18,7 +18,7 @@ public=list(
|
||||||
self$name <- name
|
self$name <- name
|
||||||
|
|
||||||
op <- paste0("resourcegroups/", self$name)
|
op <- paste0("resourcegroups/", self$name)
|
||||||
cont <- call_azure_sm(private$token, self$subscription, operation=op, api_version="2018-05-01")
|
cont <- call_azure_sm(private$token, self$subscription, op)
|
||||||
self$id <- cont$id
|
self$id <- cont$id
|
||||||
self$location <- cont$location
|
self$location <- cont$location
|
||||||
self$managed_by <- cont$managedBy
|
self$managed_by <- cont$managedBy
|
||||||
|
@ -40,7 +40,7 @@ private=list(
|
||||||
set_res=function()
|
set_res=function()
|
||||||
{
|
{
|
||||||
op <- paste0("resourcegroups/", self$name, "/resources")
|
op <- paste0("resourcegroups/", self$name, "/resources")
|
||||||
cont <- call_azure_sm(private$token, self$subscription, operation=op, api_version="2018-05-01")
|
cont <- call_azure_sm(private$token, self$subscription, op)
|
||||||
self$resources <- sapply(cont$value, `[[`, "name")
|
self$resources <- sapply(cont$value, `[[`, "name")
|
||||||
NULL
|
NULL
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public=list(
|
||||||
{
|
{
|
||||||
private$token <- token
|
private$token <- token
|
||||||
self$id <- id
|
self$id <- id
|
||||||
info <- call_azure_sm(token, id, "", api_version="2018-05-01")
|
info <- call_azure_sm(token, id, "")
|
||||||
self$name <- info$displayName
|
self$name <- info$displayName
|
||||||
self$state <- info$state
|
self$state <- info$state
|
||||||
self$policies <- info$subscriptionPolicies
|
self$policies <- info$subscriptionPolicies
|
||||||
|
@ -44,7 +44,7 @@ private=list(
|
||||||
token=NULL,
|
token=NULL,
|
||||||
set_rgrps=function()
|
set_rgrps=function()
|
||||||
{
|
{
|
||||||
cont <- call_azure_sm(private$token, self$id, operation="resourcegroups", api_version="2018-05-01")
|
cont <- call_azure_sm(private$token, self$id, "resourcegroups")
|
||||||
self$resource_groups <- sapply(cont$value, `[[`, "name")
|
self$resource_groups <- sapply(cont$value, `[[`, "name")
|
||||||
NULL
|
NULL
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
call_azure_sm <- function(token, subscription, operation, api_version,
|
call_azure_sm <- function(token, subscription, operation, api_version=getOption("azure_api_version"),
|
||||||
http_verb=c("GET", "DELETE", "PUT", "POST", "HEAD"),
|
http_verb=c("GET", "DELETE", "PUT", "POST", "HEAD"),
|
||||||
catch=c("stop", "warn", "message", "pass"), ...)
|
catch=c("stop", "warn", "message", "pass"), ...)
|
||||||
{
|
{
|
||||||
creds <- token$credentials
|
creds <- token$credentials
|
||||||
|
|
||||||
|
# TODO: if token has expired, renew it
|
||||||
|
|
||||||
url <- httr::parse_url(creds$resource)
|
url <- httr::parse_url(creds$resource)
|
||||||
url$path <- file.path("subscriptions", subscription, operation, fsep="/")
|
url$path <- file.path("subscriptions", subscription, operation, fsep="/")
|
||||||
url$query <- list(`api-version`=api_version)
|
url$query <- list(`api-version`=api_version)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче