As mentioned in Admin SDK Directory Service, developers are allowed to use the Admin SDK's Directory API in Apps Script. This API gives administrators of Google Apps domains (including resellers) the ability to manage devices, groups, users, and other entities in their domains.
With the Directory API, you can retrieve an organization unit using the GET
request and include the authorization described in Authorize requests. The orgUnitPath
query string is the full path for this organization unit.
Also discussed in the documentation:
If you are an administrator retrieving an organization unit, use my_customer
.
GET https://www.googleapis.com/admin/directory/v1/customer/my_customer/orgunits/orgUnitPath
If you are a reseller retrieving an organization unit for a resold customer, use the customerId
. To get the customerId
use the Retrieve a user operation.
GET https://www.googleapis.com/admin/directory/v1/customer/customerId/orgunits/orgUnitPath
If you want to print seperately, here is an example request wherein the 'frontline sales' organization unit is retrieved. Note the 'frontline+sales' HTTP encoding in the request's URI:
GET https://www.googleapis.com/admin/directory/v1/customer/my_customer/orgunits/corp/sales/frontline+sales
A successful response returns an HTTP 200 status code. Along with the status code, the response returns the organization unit's settings:
{
"kind": "directory#orgUnit",
"name": "frontline sales",
"description": "The frontline sales team",
"orgUnitPath": "/corp/sales/frontline sales",
"parentOrgUnitPath": "/corp/sales",
"blockInheritance": false
}
Hope that helps!