diff --git a/R/az_resgroup.R b/R/az_resgroup.R index 91cc776..1b04b67 100644 --- a/R/az_resgroup.R +++ b/R/az_resgroup.R @@ -218,7 +218,7 @@ public=list( location=location, ...) }, - lock=function(name, level=c("cannotdelete", "readonly"), notes="") + create_lock=function(name, level=c("cannotdelete", "readonly"), notes="") { level <- match.arg(level) api <- getOption("azure_api_mgmt_version") @@ -227,14 +227,24 @@ public=list( if(notes != "") body$notes <- notes - private$rg_op(op, body=body, encode="json", http_verb="PUT", api_version=api) + res <- private$rg_op(op, body=body, encode="json", http_verb="PUT", api_version=api) + az_resource$new(self$token, self$subscription, deployed_properties=res, api_version=api) }, - unlock=function(name) + get_lock=function(name) + { + api <- getOption("azure_api_mgmt_version") + op <- file.path("providers/Microsoft.Authorization/locks", name) + res <- private$rg_op(op, api_version=api) + az_resource$new(self$token, self$subscription, deployed_properties=res, api_version=api) + }, + + delete_lock=function(name) { api <- getOption("azure_api_mgmt_version") op <- file.path("providers/Microsoft.Authorization/locks", name) private$rg_op(op, http_verb="DELETE", api_version=api) + invisible(NULL) }, print=function(...) diff --git a/R/az_resource.R b/R/az_resource.R index 7c9a12b..523212d 100644 --- a/R/az_resource.R +++ b/R/az_resource.R @@ -255,7 +255,7 @@ public=list( self$tags }, - lock=function(name, level=c("cannotdelete", "readonly"), notes="") + create_lock=function(name, level=c("cannotdelete", "readonly"), notes="") { level <- match.arg(level) api <- getOption("azure_api_mgmt_version") @@ -264,14 +264,24 @@ public=list( if(notes != "") body$notes <- notes - self$do_operation(op, body=body, encode="json", http_verb="PUT", api_version=api) + res <- self$do_operation(op, body=body, encode="json", http_verb="PUT", api_version=api) + az_resource$new(self$token, self$subscription, deployed_properties=res, api_version=api) }, - unlock=function(name) + get_lock=function(name) + { + api <- getOption("azure_api_mgmt_version") + op <- file.path("providers/Microsoft.Authorization/locks", name) + res <- self$do_operation(op, api_version=api) + az_resource$new(self$token, self$subscription, deployed_properties=res, api_version=api) + }, + + delete_lock=function(name) { api <- getOption("azure_api_mgmt_version") op <- file.path("providers/Microsoft.Authorization/locks", name) self$do_operation(op, http_verb="DELETE", api_version=api) + invisible(NULL) }, print=function(...) @@ -380,7 +390,8 @@ private=list( validate_response_parms=function(parms) { required_names <- c("id", "name", "type") - optional_names <- c("location", "identity", "kind", "managedBy", "plan", "properties", "sku", "tags", "etag") + optional_names <- + c("identity", "kind", "location", "managedBy", "plan", "properties", "sku", "tags", "etag") validate_object_names(names(parms), required_names, optional_names) }, diff --git a/R/az_subscription.R b/R/az_subscription.R index 853ee7e..3ab0b91 100644 --- a/R/az_subscription.R +++ b/R/az_subscription.R @@ -172,7 +172,7 @@ public=list( lst }, - lock=function(name, level=c("cannotdelete", "readonly"), notes="") + create_lock=function(name, level=c("cannotdelete", "readonly"), notes="") { level <- match.arg(level) api <- getOption("azure_api_mgmt_version") @@ -181,14 +181,24 @@ public=list( if(notes != "") body$notes <- notes - call_azure_rm(self$token, self$id, op, body=body, encode="json", http_verb="PUT", api_version=api) + res <- call_azure_rm(self$token, self$id, op, body=body, encode="json", http_verb="PUT", api_version=api) + az_resource$new(self$token, self$id, deployed_properties=res, api_version=api) }, - unlock=function(name) + get_lock=function(name) + { + api <- getOption("azure_api_mgmt_version") + op <- file.path("providers/Microsoft.Authorization/locks", name) + res <- call_azure_rm(self$token, self$id, op, api_version=api) + az_resource$new(self$token, self$id, deployed_properties=res, api_version=api) + }, + + delete_lock=function(name) { api <- getOption("azure_api_mgmt_version") op <- file.path("providers/Microsoft.Authorization/locks", name) call_azure_rm(self$token, self$id, op, http_verb="DELETE", api_version=api) + invisible(NULL) }, print=function(...)