зеркало из https://github.com/Azure/AzureRMR.git
require confirmation before delete
This commit is contained in:
Родитель
fa89b8b98d
Коммит
82739372f6
|
@ -3,3 +3,4 @@
|
|||
\.sln$
|
||||
\.Rproj$
|
||||
\.Rxproj$
|
||||
^\.Rproj\.user$
|
||||
|
|
|
@ -262,3 +262,4 @@ __pycache__/
|
|||
|
||||
.RHistory
|
||||
misc/
|
||||
.Rproj.user
|
||||
|
|
|
@ -6,8 +6,12 @@ AlwaysSaveHistory: Default
|
|||
|
||||
EnableCodeIndexing: Yes
|
||||
UseSpacesForTab: Yes
|
||||
NumSpacesForTab: 2
|
||||
NumSpacesForTab: 4
|
||||
Encoding: UTF-8
|
||||
|
||||
RnwWeave: Sweave
|
||||
LaTeX: pdfLaTeX
|
||||
|
||||
BuildType: Package
|
||||
PackageUseDevtools: Yes
|
||||
PackageInstallArgs: --no-multiarch --with-keep.source
|
||||
|
|
|
@ -34,8 +34,15 @@ public=list(
|
|||
NULL
|
||||
},
|
||||
|
||||
delete=function()
|
||||
delete=function(confirm=TRUE)
|
||||
{
|
||||
if(confirm && interactive())
|
||||
{
|
||||
yn <- readline(paste0("Do you really want to delete resource group '", self$name, "'? (y/N) "))
|
||||
if(tolower(substr(yn, 1, 1)) != "y")
|
||||
return(invisible(NULL))
|
||||
}
|
||||
|
||||
private$rg_op(http_verb="DELETE")
|
||||
message("Deleting resource group '", self$name, "'. This operation may take some time to complete.")
|
||||
private$is_valid <- FALSE
|
||||
|
|
|
@ -76,34 +76,50 @@ public=list(
|
|||
|
||||
sync_fields=function(force=FALSE)
|
||||
{
|
||||
if(self$is_synced && !force)
|
||||
return(invisible(NULL))
|
||||
if(force || !self$is_synced)
|
||||
self$initialize(self$token, self$subscription, id=self$id)
|
||||
invisible(NULL)
|
||||
},
|
||||
|
||||
delete=function(wait=FALSE)
|
||||
delete=function(confirm=TRUE, wait=FALSE)
|
||||
{
|
||||
if(confirm && interactive())
|
||||
{
|
||||
yn <- readline(paste0("Do you really want to delete resource '", self$type, "/", self$name, "'? (y/N) "))
|
||||
if(tolower(substr(yn, 1, 1)) != "y")
|
||||
return(invisible(NULL))
|
||||
}
|
||||
|
||||
private$res_op(http_verb="DELETE")
|
||||
message("Deleting resource '", file.path(self$type, self$name), "'")
|
||||
|
||||
status <- 200
|
||||
while(wait && status < 300)
|
||||
if(wait)
|
||||
{
|
||||
for(i in 1:1000)
|
||||
{
|
||||
status <- httr::status_code(private$res_op(http_status_handler="pass"))
|
||||
if(status >= 300)
|
||||
break
|
||||
Sys.sleep(5)
|
||||
res <- private$res_op(http_status_handler="pass")
|
||||
status <- httr::status_code(res)
|
||||
}
|
||||
if(status < 300)
|
||||
warning("Attempt to delete resource did not succeed", call.=FALSE)
|
||||
}
|
||||
|
||||
private$is_valid <- FALSE
|
||||
invisible(NULL)
|
||||
},
|
||||
|
||||
do_operation=function(http_verb="GET", ..., options=list())
|
||||
{
|
||||
private$res_op(..., http_verb=http_verb, options=options)
|
||||
},
|
||||
|
||||
check=function()
|
||||
{
|
||||
res <- private$res_op(http_verb="HEAD", http_status_handler="pass")
|
||||
private$is_valid <- httr::status_code(res) < 300
|
||||
private$is_valid
|
||||
# HEAD seems to be broken; do a GET and test whether it fails
|
||||
res <- try(private$res_op())
|
||||
!inherits(res, "try-error")
|
||||
}
|
||||
),
|
||||
|
||||
|
|
|
@ -47,8 +47,19 @@ public=list(
|
|||
invisible(NULL)
|
||||
},
|
||||
|
||||
delete=function(free_resources=FALSE)
|
||||
delete=function(confirm=TRUE, free_resources=FALSE)
|
||||
{
|
||||
if(confirm && interactive())
|
||||
{
|
||||
msg <- paste0("Do you really want to delete template '", self$name, "'")
|
||||
if(free_resources)
|
||||
msg <- paste0(msg, " and associated resources")
|
||||
msg <- paste0(msg, "? (y/N) ")
|
||||
yn <- readline(msg)
|
||||
if(tolower(substr(yn, 1, 1)) != "y")
|
||||
return(invisible(NULL))
|
||||
}
|
||||
|
||||
message("Deleting template '", self$name, "'")
|
||||
if(free_resources)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче