зеркало из https://github.com/Azure/AzureRMR.git
expose do_operation for sub and rg
This commit is contained in:
Родитель
03c6e8fecc
Коммит
435b038eb4
|
@ -1,6 +1,6 @@
|
|||
Package: AzureRMR
|
||||
Title: Interface to 'Azure Resource Manager'
|
||||
Version: 2.2.0
|
||||
Version: 2.2.1
|
||||
Authors@R: c(
|
||||
person("Hong", "Ooi", , "hongooi@microsoft.com", role = c("aut", "cre")),
|
||||
person("Microsoft", role="cph")
|
||||
|
|
4
NEWS.md
4
NEWS.md
|
@ -1,3 +1,7 @@
|
|||
# AzureRMR 2.2.1
|
||||
|
||||
- Expose `do_operation` methods for subscription and resource group objects, similar to that for resources. This allows arbitrary operations on a sub or RG.
|
||||
|
||||
# AzureRMR 2.2.0
|
||||
|
||||
- If the AzureGraph package is installed, `create_azure_login` can now create a login client for Microsoft Graph with the same credentials as the ARM client. This is to facilitate working with registered apps and service principals, eg when managing roles and permissions. Some Azure services also require creating service principals as part of creating a resource (eg Azure Kubernetes Service), and keeping the Graph credentials consistent with ARM helps ensure nothing breaks.
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#' - `delete_resource(..., confirm=TRUE, wait=FALSE)`: Delete an existing resource. Optionally wait for the delete to finish.
|
||||
#' - `resource_exists(...)`: Check if a resource exists.
|
||||
#' - `list_resources()`: Return a list of resource group objects for this subscription.
|
||||
#' - `do_operation(...)`: Carry out an operation. See 'Operations' for more details.
|
||||
#' - `set_tags(..., keep_existing=TRUE)`: Set the tags on this resource group. The tags can be either names or name-value pairs. To delete a tag, set it to `NULL`.
|
||||
#' - `get_tags()`: Get the tags on this resource.
|
||||
#' - `create_lock(name, level)`: Create a management lock on this resource group (which will propagate to all resources within it).
|
||||
|
@ -59,6 +60,15 @@
|
|||
#'
|
||||
#' To create/deploy a new resource, specify any extra parameters that the provider needs as named arguments to `create_resource()`. Like `deploy_template()`, `create_resource()` also takes an optional `wait` argument that specifies whether to wait until resource creation is complete before returning.
|
||||
#'
|
||||
#' @section Operations:
|
||||
#' The `do_operation()` method allows you to carry out arbitrary operations on the resource group. It takes the following arguments:
|
||||
#' - `op`: The operation in question, which will be appended to the URL path of the request.
|
||||
#' - `options`: A named list giving the URL query parameters.
|
||||
#' - `...`: Other named arguments passed to [call_azure_rm], and then to the appropriate call in httr. In particular, use `body` to supply the body of a PUT, POST or PATCH request, and `api_version` to set the API version.
|
||||
#' - `http_verb`: The HTTP verb as a string, one of `GET`, `PUT`, `POST`, `DELETE`, `HEAD` or `PATCH`.
|
||||
#'
|
||||
#' Consult the Azure documentation for what operations are supported.
|
||||
#'
|
||||
#' @section Role-based access control:
|
||||
#' AzureRMR implements a subset of the full RBAC functionality within Azure Active Directory. You can retrieve role definitions and add and remove role assignments, at the subscription, resource group and resource levels. See [rbac] for more information.
|
||||
#'
|
||||
|
@ -265,6 +275,11 @@ public=list(
|
|||
else self$tags
|
||||
},
|
||||
|
||||
do_operation=function(..., options=list(), http_verb="GET")
|
||||
{
|
||||
private$rg_op(..., options=options, http_verb=http_verb)
|
||||
},
|
||||
|
||||
print=function(...)
|
||||
{
|
||||
cat("<Azure resource group ", self$name, ">\n", sep="")
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#' - `list_resources()`: List all resources deployed under this subscription.
|
||||
#' - `list_locations()`: List locations available.
|
||||
#' - `get_provider_api_version(provider, type, which=1, stable_only=TRUE)`: Get the current API version for the given resource provider and type. If no resource type is supplied, returns a vector of API versions, one for each resource type for the given provider. If neither provider nor type is supplied, returns the API versions for all resources and providers. Set `stable_only=FALSE` to allow preview APIs to be returned. Set `which` to a number > 1 to return an API other than the most recent.
|
||||
#' - `do_operation(...)`: Carry out an operation. See 'Operations' for more details.
|
||||
#' - `create_lock(name, level)`: Create a management lock on this subscription (which will propagate to all resources within it).
|
||||
#' - `get_lock(name`): Returns a management lock object.
|
||||
#' - `delete_lock(name)`: Deletes a management lock object.
|
||||
|
@ -29,6 +30,15 @@
|
|||
#' @section Details:
|
||||
#' Generally, the easiest way to create a subscription object is via the `get_subscription` or `list_subscriptions` methods of the [az_rm] class. To create a subscription object in isolation, call the `new()` method and supply an Oauth 2.0 token of class [AzureToken], along with the ID of the subscription.
|
||||
#'
|
||||
#' @section Operations:
|
||||
#' The `do_operation()` method allows you to carry out arbitrary operations on the subscription. It takes the following arguments:
|
||||
#' - `op`: The operation in question, which will be appended to the URL path of the request.
|
||||
#' - `options`: A named list giving the URL query parameters.
|
||||
#' - `...`: Other named arguments passed to [call_azure_rm], and then to the appropriate call in httr. In particular, use `body` to supply the body of a PUT, POST or PATCH request, and `api_version` to set the API version.
|
||||
#' - `http_verb`: The HTTP verb as a string, one of `GET`, `PUT`, `POST`, `DELETE`, `HEAD` or `PATCH`.
|
||||
#'
|
||||
#' Consult the Azure documentation for what operations are supported.
|
||||
#'
|
||||
#' @section Role-based access control:
|
||||
#' AzureRMR implements a subset of the full RBAC functionality within Azure Active Directory. You can retrieve role definitions and add and remove role assignments, at the subscription, resource group and resource levels. See [rbac] for more information.
|
||||
#'
|
||||
|
@ -185,6 +195,11 @@ public=list(
|
|||
lst
|
||||
},
|
||||
|
||||
do_operation=function(..., options=list(), http_verb="GET")
|
||||
{
|
||||
private$sub_op(..., options=options, http_verb=http_verb)
|
||||
},
|
||||
|
||||
print=function(...)
|
||||
{
|
||||
cat("<Azure subscription ", self$id, ">\n", sep="")
|
||||
|
|
|
@ -26,6 +26,7 @@ Class representing an Azure resource group.
|
|||
\item \code{delete_resource(..., confirm=TRUE, wait=FALSE)}: Delete an existing resource. Optionally wait for the delete to finish.
|
||||
\item \code{resource_exists(...)}: Check if a resource exists.
|
||||
\item \code{list_resources()}: Return a list of resource group objects for this subscription.
|
||||
\item \code{do_operation(...)}: Carry out an operation. See 'Operations' for more details.
|
||||
\item \code{set_tags(..., keep_existing=TRUE)}: Set the tags on this resource group. The tags can be either names or name-value pairs. To delete a tag, set it to \code{NULL}.
|
||||
\item \code{get_tags()}: Get the tags on this resource.
|
||||
\item \code{create_lock(name, level)}: Create a management lock on this resource group (which will propagate to all resources within it).
|
||||
|
@ -83,6 +84,19 @@ Providing the \code{id} argument will fill in the values for all the other argum
|
|||
To create/deploy a new resource, specify any extra parameters that the provider needs as named arguments to \code{create_resource()}. Like \code{deploy_template()}, \code{create_resource()} also takes an optional \code{wait} argument that specifies whether to wait until resource creation is complete before returning.
|
||||
}
|
||||
|
||||
\section{Operations}{
|
||||
|
||||
The \code{do_operation()} method allows you to carry out arbitrary operations on the resource group. It takes the following arguments:
|
||||
\itemize{
|
||||
\item \code{op}: The operation in question, which will be appended to the URL path of the request.
|
||||
\item \code{options}: A named list giving the URL query parameters.
|
||||
\item \code{...}: Other named arguments passed to \link{call_azure_rm}, and then to the appropriate call in httr. In particular, use \code{body} to supply the body of a PUT, POST or PATCH request, and \code{api_version} to set the API version.
|
||||
\item \code{http_verb}: The HTTP verb as a string, one of \code{GET}, \code{PUT}, \code{POST}, \code{DELETE}, \code{HEAD} or \code{PATCH}.
|
||||
}
|
||||
|
||||
Consult the Azure documentation for what operations are supported.
|
||||
}
|
||||
|
||||
\section{Role-based access control}{
|
||||
|
||||
AzureRMR implements a subset of the full RBAC functionality within Azure Active Directory. You can retrieve role definitions and add and remove role assignments, at the subscription, resource group and resource levels. See \link{rbac} for more information.
|
||||
|
|
|
@ -23,6 +23,7 @@ Class representing an Azure subscription.
|
|||
\item \code{list_resources()}: List all resources deployed under this subscription.
|
||||
\item \code{list_locations()}: List locations available.
|
||||
\item \code{get_provider_api_version(provider, type, which=1, stable_only=TRUE)}: Get the current API version for the given resource provider and type. If no resource type is supplied, returns a vector of API versions, one for each resource type for the given provider. If neither provider nor type is supplied, returns the API versions for all resources and providers. Set \code{stable_only=FALSE} to allow preview APIs to be returned. Set \code{which} to a number > 1 to return an API other than the most recent.
|
||||
\item \code{do_operation(...)}: Carry out an operation. See 'Operations' for more details.
|
||||
\item \code{create_lock(name, level)}: Create a management lock on this subscription (which will propagate to all resources within it).
|
||||
\item \code{get_lock(name}): Returns a management lock object.
|
||||
\item \code{delete_lock(name)}: Deletes a management lock object.
|
||||
|
@ -41,6 +42,19 @@ Class representing an Azure subscription.
|
|||
Generally, the easiest way to create a subscription object is via the \code{get_subscription} or \code{list_subscriptions} methods of the \link{az_rm} class. To create a subscription object in isolation, call the \code{new()} method and supply an Oauth 2.0 token of class \link{AzureToken}, along with the ID of the subscription.
|
||||
}
|
||||
|
||||
\section{Operations}{
|
||||
|
||||
The \code{do_operation()} method allows you to carry out arbitrary operations on the subscription. It takes the following arguments:
|
||||
\itemize{
|
||||
\item \code{op}: The operation in question, which will be appended to the URL path of the request.
|
||||
\item \code{options}: A named list giving the URL query parameters.
|
||||
\item \code{...}: Other named arguments passed to \link{call_azure_rm}, and then to the appropriate call in httr. In particular, use \code{body} to supply the body of a PUT, POST or PATCH request, and \code{api_version} to set the API version.
|
||||
\item \code{http_verb}: The HTTP verb as a string, one of \code{GET}, \code{PUT}, \code{POST}, \code{DELETE}, \code{HEAD} or \code{PATCH}.
|
||||
}
|
||||
|
||||
Consult the Azure documentation for what operations are supported.
|
||||
}
|
||||
|
||||
\section{Role-based access control}{
|
||||
|
||||
AzureRMR implements a subset of the full RBAC functionality within Azure Active Directory. You can retrieve role definitions and add and remove role assignments, at the subscription, resource group and resource levels. See \link{rbac} for more information.
|
||||
|
|
|
@ -42,6 +42,9 @@ test_that("Subscription methods work",
|
|||
# locks (minimal testing at sub level right now)
|
||||
locks <- sub$list_locks()
|
||||
expect_true(is.list(locks))
|
||||
|
||||
res <- sub$do_operation("resourceGroups")
|
||||
expect_true(is.list(res))
|
||||
})
|
||||
|
||||
test_that("Subscription methods work with AAD v2.0",
|
||||
|
|
|
@ -26,6 +26,9 @@ test_that("Resource group methods work",
|
|||
expect_is(rgnew2, "az_resource_group")
|
||||
expect_equal(rgnew2$name, rgname)
|
||||
|
||||
res <- rgnew$do_operation("resources")
|
||||
expect_true(is.list(res))
|
||||
|
||||
# tagging
|
||||
rgnew$set_tags(tag1="value1")
|
||||
expect_identical(rgnew$get_tags(), list(tag1="value1"))
|
||||
|
|
Загрузка…
Ссылка в новой задаче