Platform Management
Background
The Platform Management API is useful for Tenant Administration and Management of Poly Lens accounts.
Some examples include tenant name, device user count, device count, and site & room information.
When you're testing the sample queries below, keep in mind that the GraphQL Playground uses user authentication
, so if you're an admin in multiple tenants you'll see data results from those tenants (unless you specifically target a tenantId
in your query).
We'll start by running a tenants
query to find the id
, name
, memberCount
, deviceCount
, and room count for all tenants we can access.
It's important to note that memberCount
in this query refers to Account Members, i.e., users that have access to the Poly Lens Admin Portal.
Query Tenant Information Using tenants
Test this query in the GraphQL Playground
query tenantInfo {
tenants {
id
name
memberCount
deviceCount
roomData {
total
}
}
}
In the example response below, you'll notice the structure of the data object matches the query. This predictability is one of GraphQL's benefits.
The tenant id
is redacted, but take note of your tenant id
as you'll need it for the next query.
Sample Response
{
"data": {
"tenants": [
{
"id": "695xxx-bxxx-4xxx-axxx-1xxxxx",
"name": "DFossDemo",
"memberCount": 15,
"deviceCount": 84,
"roomData": {
"total": 15
}
}
]
}
}
Now that we have the tenant id
, we can run a query to return details for users in this tenant. In Poly Lens, we use roles to distinguish and manage access. Users that with account management access will have a role of admin
, it-admin
, or user
. Users with access to Poly Lens Desktop/Mobile Applications will have the device_user
role. It's possible for a user to be both an Account Member (management access) and a Device User (Lens App User).
When you're passing these roles into the Lens API, you'll need to use one of the following:
admin
(Admin)it-admin
(Device Manager)user
(Guest)device_user
(Poly Lens App Users).
If you've spent time in the ACCOUNT > Manage Accounts > Accounts Members section of the Poly Lens Cloud UI, you've likely noticed these roles listed as: Admin, Device Manager, and Guest.
In this query, we need to pass two arguments into UserSearchParams
grants
:
roles
\one of the roles listed aboveresourceId
\this is the tenantid
We'll target Tenant Admins in this users
query example.
Query Tenant Admins Using users
Test this query in the GraphQL Playground
query tenantAdmins($params: UserSearchParams!) {
users(params: $params) {
count
edges {
node {
email
email_verified
last_ip
last_login
app_metadata {
info {
authedClients
}
}
}
}
}
}
Variables
{
"params": {
"grants": [
{
"roles": "admin",
"resourceId": "695xxx-bxxx-4xxx-axxx-1xxxxx"
}
]
}
}
This is a sample of the result from the query above (reduced to 1 user for brevity).
Sample Output From our Query
{
"data": {
"users": {
"count": 6, //total number of users with admin role
"edges": [
{
"node": {
"email": "danny.reed@poly.com",
"email_verified": true,
"last_ip": "8x.x1xx.1xx.1xx",
"last_login": "2023-01-30T03:52:43.684Z",
"app_metadata": {
"info": {
"authedClients": [
"Poly Lens Desktop",
"Poly Lens",
"GraphQL Playground"
]
}
}
}
}
]
}
}
}
The queries above are just a small subset of the power of the Platform and Management APIs. Please reach out if you have specific content requests or questions.