This commit is contained in:
Hong Ooi 2019-03-24 23:37:31 +11:00
Родитель e69154ee96
Коммит e65b786bc9
6 изменённых файлов: 126 добавлений и 16 удалений

Просмотреть файл

@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand
export(az_app)
export(az_device)
export(az_group)
export(az_object)
export(az_service_principal)

48
R/az_device.R Normal file
Просмотреть файл

@ -0,0 +1,48 @@
#' Device in Azure Active Directory
#'
#' Base class representing a registered device.
#'
#' @docType class
#' @section Fields:
#' - `token`: The token used to authenticate with the Graph host.
#' - `tenant`: The Azure Active Directory tenant for this group.
#' - `type`: always "device" for a device object.
#' - `properties`: The device properties.
#' @section Methods:
#' - `new(...)`: Initialize a new device object. Do not call this directly; see 'Initialization' below.
#' - `delete(confirm=TRUE)`: Delete a device. By default, ask for confirmation first.
#' - `update(...)`: Update the device information in Azure Active Directory.
#' - `do_operation(...)`: Carry out an arbitrary operation on the device.
#' - `sync_fields()`: Synchronise the R object with the app data in Azure Active Directory.
#' - `list_group_memberships()`: Return the IDs of all groups this device is a member of.
#' - `list_object_memberships()`: Return the IDs of all groups, administrative units and directory roles this device is a member of.
#'
#' @section Initialization:
#' Create objects of this class via the `list_registered_devices()` and `list_owned_devices()` methods of the `az_user` class.
#'
#' @seealso
#' [ms_graph], [az_user], [az_object]
#'
#' [Microsoft Graph overview](https://docs.microsoft.com/en-us/graph/overview),
#' [REST API reference](https://docs.microsoft.com/en-us/graph/api/overview?view=graph-rest-beta)
#'
#' @format An R6 object of class `az_device`, inheriting from `az_object`.
#' @export
az_device <- R6::R6Class("az_device", inherit=az_object,
public=list(
initialize=function(token, tenant=NULL, properties=NULL)
{
self$type <- "device"
super$initialize(token, tenant, properties)
},
print=function(...)
{
cat("<Graph device '", self$properties$displayName, "'>\n", sep="")
cat(" directory id:", self$properties$id, "\n")
cat(" device id:", self$properties$deviceId, "\n")
invisible(self)
}
))

Просмотреть файл

@ -117,7 +117,7 @@ private=list(
res
},
filter_list=function(lst, type)
filter_list=function(lst, type=c("user", "group", "application", "servicePrincipal", "device"))
{
type <- paste0("#microsoft.graph.", type)
keep <- sapply(lst, function(obj) obj$`@odata.type` %in% type)
@ -128,19 +128,22 @@ private=list(
{
lapply(lst, function(obj)
{
if(obj$`@odata.type` == "#microsoft.graph.user")
az_user$new(self$token, self$tenant, obj)
else if(obj$`@odata.type` == "#microsoft.graph.group")
az_group$new(self$token, self$tenant, obj)
else if(obj$`@odata.type` == "#microsoft.graph.application")
az_app$new(self$token, self$tenant, obj)
else if(obj$`@odata.type` == "#microsoft.graph.servicePrincipal")
az_service_principal$new(self$token, self$tenant, obj)
else
{
warning("Unknown directory object type ", obj$`@odata.type`)
obj
}
switch(obj$`@odata.type`,
"#microsoft.graph.user"=
az_user$new(self$token, self$tenant, obj),
"#microsoft.graph.group"=
az_group$new(self$token, self$tenant, obj),
"#microsoft.graph.application"=
az_app$new(self$token, self$tenant, obj),
"#microsoft.graph.servicePrincipal"=
az_service_principal$new(self$token, self$tenant, obj),
"#microsoft.graph.device"=
az_device$new(self$token, self$tenant, obj),
{
warning("Unknown directory object type ", obj$`@odata.type`)
obj
}
)
})
},

Просмотреть файл

@ -19,13 +19,15 @@
#' - `list_direct_memberships(id_only=TRUE)`: List the groups this user is a direct member of. Set `id_only=TRUE` to return only a vector of group IDs (the default), or `id_only=FALSE` to return a list of group objects.
#' - `list_owned_objects(type=c("user", "group", "application", "servicePrincipal"))`: List directory objects (groups/apps/service principals) owned by this user. Specify the `type` argument to filter the result for specific object type(s).
#' - `list_created_objects(type=c("user", "group", "application", "servicePrincipal"))`: List directory objects (groups/apps/service principals) created by this user. Specify the `type` argument to filter the result for specific object type(s).
#' - `list_owned_devices()`: List the devices owned by this user.
#' - `list_registered_devices()`: List the devices registered by this user.
#' - `reset_password(password=NULL, force_password_change=TRUE): Resets a user password. By default the new password will be randomly generated, and must be changed at next login.
#'
#' @section Initialization:
#' Creating new objects of this class should be done via the `create_user` and `get_user` methods of the [ms_graph] and [az_app] classes. Calling the `new()` method for this class only constructs the R object; it does not call the Microsoft Graph API to create the actual user account.
#'
#' @seealso
#' [ms_graph], [az_app], [az_group], [az_object]
#' [ms_graph], [az_app], [az_group], [az_device], [az_object]
#'
#' [Microsoft Graph overview](https://docs.microsoft.com/en-us/graph/overview),
#' [REST API reference](https://docs.microsoft.com/en-us/graph/api/overview?view=graph-rest-beta)
@ -97,6 +99,12 @@ public=list(
private$init_list_objects(private$filter_list(res, type))
},
list_owned_devices=function()
{
res <- private$get_paged_list(self$do_operation("ownedDevices"))
private$init_list_objects(private$filter_list(res))
},
list_direct_memberships=function(id_only=TRUE)
{
res <- private$get_paged_list(self$do_operation("memberOf"))

48
man/az_device.Rd Normal file
Просмотреть файл

@ -0,0 +1,48 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/az_device.R
\docType{class}
\name{az_device}
\alias{az_device}
\title{Device in Azure Active Directory}
\format{An R6 object of class \code{az_device}, inheriting from \code{az_object}.}
\usage{
az_device
}
\description{
Base class representing a registered device.
}
\section{Fields}{
\itemize{
\item \code{token}: The token used to authenticate with the Graph host.
\item \code{tenant}: The Azure Active Directory tenant for this group.
\item \code{type}: always "device" for a device object.
\item \code{properties}: The device properties.
}
}
\section{Methods}{
\itemize{
\item \code{new(...)}: Initialize a new device object. Do not call this directly; see 'Initialization' below.
\item \code{delete(confirm=TRUE)}: Delete a device. By default, ask for confirmation first.
\item \code{update(...)}: Update the device information in Azure Active Directory.
\item \code{do_operation(...)}: Carry out an arbitrary operation on the device.
\item \code{sync_fields()}: Synchronise the R object with the app data in Azure Active Directory.
\item \code{list_group_memberships()}: Return the IDs of all groups this device is a member of.
\item \code{list_object_memberships()}: Return the IDs of all groups, administrative units and directory roles this device is a member of.
}
}
\section{Initialization}{
Create objects of this class via the \code{list_registered_devices()} and \code{list_owned_devices()} methods of the \code{az_user} class.
}
\seealso{
\link{ms_graph}, \link{az_user}, \link{az_object}
\href{https://docs.microsoft.com/en-us/graph/overview}{Microsoft Graph overview},
\href{https://docs.microsoft.com/en-us/graph/api/overview?view=graph-rest-beta}{REST API reference}
}
\keyword{datasets}

Просмотреть файл

@ -34,6 +34,8 @@ Base class representing an AAD user account.
\item \code{list_direct_memberships(id_only=TRUE)}: List the groups this user is a direct member of. Set \code{id_only=TRUE} to return only a vector of group IDs (the default), or \code{id_only=FALSE} to return a list of group objects.
\item \code{list_owned_objects(type=c("user", "group", "application", "servicePrincipal"))}: List directory objects (groups/apps/service principals) owned by this user. Specify the \code{type} argument to filter the result for specific object type(s).
\item \code{list_created_objects(type=c("user", "group", "application", "servicePrincipal"))}: List directory objects (groups/apps/service principals) created by this user. Specify the \code{type} argument to filter the result for specific object type(s).
\item \code{list_owned_devices()}: List the devices owned by this user.
\item \code{list_registered_devices()}: List the devices registered by this user.
\item `reset_password(password=NULL, force_password_change=TRUE): Resets a user password. By default the new password will be randomly generated, and must be changed at next login.
}
}
@ -66,7 +68,7 @@ usr$list_owned_objects(type=c("application", "servicePrincipal"))
}
}
\seealso{
\link{ms_graph}, \link{az_app}, \link{az_group}, \link{az_object}
\link{ms_graph}, \link{az_app}, \link{az_group}, \link{az_device}, \link{az_object}
\href{https://docs.microsoft.com/en-us/graph/overview}{Microsoft Graph overview},
\href{https://docs.microsoft.com/en-us/graph/api/overview?view=graph-rest-beta}{REST API reference}