I am creating an admin panel that creates a G Suite user account using Google API with a PHP SDK. I am done with the part in creating a user but now I am left wondering how can I create a Team Drive for the newly created user? I can't see a parameter where I can add the newly created user's id like email. Am I missing something?
https://developers.google.com/drive/api/v3/reference/teamdrives/create
Code below can create a Team Drive but it will be added into the G Suite account that created the service-account.
$service = new \Google_Service_Drive($this->client($scopes));
$metadata = new Google_Service_Drive_TeamDrive();
$metadata->setName('My New Drive');
do {
$requestId = Uuid::uuid4()->toString();
try {
$resp = $service->teamdrives->create($requestId, $metadata);
} catch (Google_Service_Exception $e) {
$resp['statusCode'] = $e->getCode();
$resp['errors'] = $e->getErrors();
$resp['message'] = $e->getMessage();
}
} while ( isset($resp['statusCode']) );