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