Manage Team Drives

Much of the information you'll need to get started creating and managing Team Drives is detailed in the Team Drives reference. Here are a few more important considerations when working with Team Drives.

Creating Team Drives

Use the teamdrives.create to create a new Team Drive.

Java

TeamDrive teamDriveMetadata = new TeamDrive();
teamDriveMetadata.setName("Project Resources");
String requestId = UUID.randomUUID().toString();
TeamDrive teamDrive = driveService.teamdrives().create(requestId,
    teamDriveMetadata)
    .execute();
System.out.println("Team Drive ID: " + teamDrive.getId());

Python

team_drive_metadata = {'name': 'Project Resources'}
request_id = str(uuid.uuid4())
team_drive = drive_service.teamdrives().create(body=team_drive_metadata,
                                               requestId=request_id,
                                               fields='id').execute()
print 'Team Drive ID: %s' % team_drive.get('id')

PHP

$teamDriveMetadata = new Google_Service_Drive_TeamDrive(array(
    'name' => 'Project Resources'));
$requestId = Uuid::uuid4()->toString();
$teamDrive = $driveService->teamdrives->create($requestId, $teamDriveMetadata, array(
    'fields' => 'id'));
printf("Team Drive ID: %s\n", $teamDrive->id);

.NET

var teamDriveMetadata = new TeamDrive()
{
    Name = "Project Resources"
};
var requestId = System.Guid.NewGuid().ToString();
var request = driveService.Teamdrives.Create(teamDriveMetadata, requestId);
request.Fields = "id";
var teamDrive = request.Execute();
Console.WriteLine("Team Drive ID: " + teamDrive.Id);

Ruby

team_drive_metadata = {
    name: 'Project Resources'
}
request_id = SecureRandom.uuid
team_drive = drive_service.create_teamdrive(request_id,
                                            team_drive_metadata,
                                            fields: 'id')
puts "Team Drive Id: #{team_drive.id}"

Node.js

var teamDriveMetadata = {
  'name': 'Project resources'
};
var requestId = uuid.v4();
drive.teamdrives.create({
  resource: teamDriveMetadata,
  requestId: requestId,
  fields: 'id'
}, function (err, teamDrive) {
  if (err) {
    // Handle error
    console.error(err);
  } else {
    console.log('Team Drive Id: ', teamDrive.id);
  }
});

Calls to teamdrives.create are idempotent. The requestId parameter identifies the logical attempt to create the Team Drive. If the request times out or returns an indeterminant backend error, the same request may be repeated. The requestId and body of the request must remain the same.

If the Team Drive was successfully created on a previous request or as a result of a retry, the normal response is returned. In some cases, such as after a prolonged period of time or if the body of the request has changed, a 409 error may be returned indicating the requestId must be discarded.

Managing members and permissions

Add or remove Team Drive member using the permissions collection.

To add a member, create the permission on the Team Drive itself. Permission methods can also be used on individual files within a Team Drive to grant members additional privileges or allow non-members to collaborate on specific items.

See manage sharing for additional details and sample code.

Deleting Team Drives

Use the teamdrives.delete method to remove a Team Drive. All content in the Team Drive must be trashed or deleted prior to deleting the Team Drive.

Enviar comentarios sobre…