管理保全
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
保全可无限期保留数据,以便履行法律义务或保留义务。通常,保全措施会针对一位或多位用户的数据设置,以确保在相关事宜不再有效之前,可能与该事宜相关的数据不会被删除。
如果处于保全状态的用户删除了受保全的数据,相应数据会从该用户的视图中移除,但仍会保留在保险柜中。只要保全未解除,保险柜管理员就可以搜索和导出这些数据。
搁置请求包含以下组件:
- 服务 - 负责保存数据的应用。该服务可以设置为 Gmail、云端硬盘或 Google 群组。
- 范围 - 保全涵盖的实体。范围可以设置为一个或多个用户账号,也可以设置为组织部门 (OU)。
- 其他选项(可选)- 用于缩小要保留在定义范围内的数据的具体详细信息(搜索查询或配置选项)。选项包括:
- 邮件、群组:用于缩小保留范围的搜索查询
- 云端硬盘:在保留中包含共享云端硬盘
如需使用保险柜资源,相应账号必须拥有所需的保险柜权限,并且能够访问相应事宜。如需访问诉讼或调查,相应账号必须已创建该诉讼或调查、已与该账号共享该诉讼或调查,或者该账号拥有查看所有诉讼或调查的权限。
使用搜索查询为特定用户账号中的邮件创建保留
以下示例展示了如何为以下对象创建名为“My First mail Accounts Hold”的保留:
- 服务:mail
- 实体:用户账号“user1”和“user2”
- 其他选项:搜索查询“to:ceo@company.com”
从 Directory API 中检索用户账号 ID。
请注意,HeldAccount 可以接受账号 ID 或电子邮件地址。如果同时提供这两个参数,系统会使用电子邮件地址,并忽略账号 ID。
Java
HeldMailQuery mailQuery = new HeldMailQuery().setTerms("to:ceo@company.com");
List accounts = Lists.newArrayList();
accounts.add(new HeldAccount().setAccountId(user1accountId));
accounts.add(new HeldAccount().setEmail(user2Email));
Hold hold = new Hold()
.setName("My First mail Accounts Hold")
.setCorpus("MAIL");
.setQuery(new CorpusQuery().setMailQuery(mailQuery))
.setAccounts(accounts);
Hold createdHold = client.matters().holds().create(matterId, hold).execute();
Python
def create_hold_mail_accounts(service, matter_id, account_id):
mail_query = {'terms': 'to:ceo@company.com'}
accounts = [
{'accountId': user1_account_id},
{'email': user2_email}
]
wanted_hold = {
'name': 'My First mail Accounts Hold',
'corpus': 'MAIL',
'query': {
'mailQuery': mail_query
},
'accounts': accounts
}
return service.matters().holds().create(
matterId=matter_id, body=wanted_hold).execute()
为某个 OU 创建云端硬盘保留设置,并纳入共享云端硬盘内容
以下示例展示了如何为以下对象创建名为“My First Drive OU Hold”的保留设置:
- 服务:云端硬盘
- 实体:组织部门“财务”(组织部门 ID 捕获在 orgUnitId 中)
- 其他选项:包含此组织部门中的用户所属的共享云端硬盘
从 Directory API 中检索组织部门 ID。
Java
HeldOrgUnit orgUnit = new HeldOrgUnit().setOrgUnitId(orgUnitId);
// Include shared drives content.
HeldDriveQuery driveQuery = new HeldDriveQuery().setIncludeSharedDriveFiles(true);
// Create the hold.
Hold hold = new Hold()
.setName("My First Drive OU Hold")
.setCorpus("DRIVE")
.setQuery(new CorpusQuery().setDriveQuery(driveQuery))
.setOrgUnit(orgUnit);
Hold createdHold = client.matters().holds().create(matterId, hold).execute();
return createdHold;
Python
def create_hold_drive_org(service, matter_id, org_unit_id):
drive_query = {'includeSharedDriveFiles': True}
org_unit = {'orgUnitId': org_unit_id}
wanted_hold = {
'name': 'My First Drive OU Hold',
'corpus': 'DRIVE',
'orgUnit': org_unit,
'query': {
'driveQuery': drive_query
}
}
return service.matters().holds().create(
matterId=matter_id, body=wanted_hold).execute()
为特定群组账号中的群组创建保全,并指定日期范围
以下示例展示了如何为以下内容创建名为“My First Group Hold”的保留:
- 服务:Google 群组
- 实体:群组账号“group1”和“group2”
- 其他选项:仅保留发送日期介于“startTime”和“endTime”之间的邮件
从 Directory API 中检索群组账号 ID。
Java
String APRIL_2_2017_GMT = "2017-04-02T00:00:00Z"; // See below for format*.
List accounts = Lists.newArrayList();
accounts.add(new HeldAccount().setAccountId(accountId));
accounts.add(new HeldAccount().setAccountId(accountId2));
HeldGroupsQuery groupQuery = new HeldGroupsQuery();
// Restrict by sent date.
groupQuery.setStartTime(APRIL_2_2017_GMT);
groupQuery.setEndTime(APRIL_2_2017_GMT);
// create the hold
Hold hold = new Hold()
.setName("My First Group Hold")
.setCorpus("GROUPS")
.setQuery(new CorpusQuery().setGroupsQuery(groupQuery));
hold.setAccounts(accounts);
Hold createdHold = client.matters().holds().create(matterId, hold).execute();
Python
def create_hold_groups_date_range(service, matter_id, group_account_id):
groups_query = {
'startTime': '2017-04-02T00:00:00Z', # See below for format*
'endTime': '2017-04-02T00:00:00Z'
}
accounts = [{'accountId': group_account_id}]
wanted_hold = {
'name': 'My First Group Hold',
'corpus': 'GROUPS',
'query': {
'groupsQuery': groups_query
},
'accounts': accounts
}
return service.matters().holds().create(
matterId=matter_id, body=wanted_hold).execute()
- 时间戳格式。此外,start/endTimes 会转换为 GMT,并向下舍入到指定日期的开始时间。
查询和修改现有中止
以下示例展示了如何列出现有保留中包含的所有账号:
Java
client.matters().holds().accounts().list(matterId, holdId).execute().getAccounts();
Python
# If no accounts are on hold, ['accounts'] will raise an error.
def list_held_accounts(service, matter_id, hold_id):
return service.matters().holds().accounts().list(
matterId=matter_id, holdId=hold_id).execute()['accounts']
以下示例展示了如何向现有中止中添加账号以及从中移除账号:
Java
// Add an account by id.
client
.matters()
.holds()
.accounts()
.create(matterId, holdId, new HeldAccount().setAccountId(accountId))
.execute();
// Remove an account by id.
client.matters().holds().accounts().delete(matterId, holdId, accountId).execute();
String email = "email@email.com";
// Add an account by email.
client
.matters()
.holds()
.accounts()
.create(matterId, holdId, new HeldAccount().setEmail(email))
.execute();
Python
def add_held_account(service, matter_id, hold_id, account_id):
held_account = {'accountId': account_id}
return service.matters().holds().accounts().create(
matterId=matter_id, holdId=hold_id, body=held_account).execute()
def remove_held_account(service, matter_id, hold_id, account_id):
return service.matters().holds().accounts().delete(
matterId=matter_id, holdId=hold_id, accountId=account_id).execute()
def add_held_account(service, matter_id, hold_id, email):
held_account = {'email': email}
return service.matters().holds().accounts().create(
matterId=matter_id, holdId=hold_id, body=held_account).execute()
以下示例展示了如何修改现有组织部门保留设置中的组织部门:
Java
Hold hold = client.matters().holds().get(matterId, holdId).execute();
hold.getOrgUnit().setOrgUnitId(newOrgUnitId);
Hold modifiedHold = client.matters().holds().update(matterId, holdId, hold).execute();
return modifiedHold;
Python
def update_hold_ou(service, matter_id, hold_id, org_unit_id):
current_hold = get_hold(matter_id, hold_id)
current_hold['orgUnit'] = {'orgUnitId': org_unit_id}
return service.matters().holds().update(
matterId=matter_id, holdId=hold_id, body=current_hold).execute()
以下示例展示了如何列出诉讼的所有暂缓保留设置:
Java
String matterId = "Matter Id";
// List all holds.
List holdsList =
client.matters().holds().list(matterId).execute().getHolds();
// Paginate on holds.
ListHoldsResponse response = client
.matters()
.holds()
.list(matterId)
.setPageSize(10)
.execute();
String nextPageToken = response.getNextPageToken();
if (nextPageToken != null) {
client
.matters()
.holds()
.list(matterId)
.setPageSize(10)
.setPageToken(nextPageToken)
.execute();
}
Python
# This can paginate in the same manner as with matters.
def list_holds(service, matter_id):
return service.matters().holds().list(matterId=matter_id).execute()
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Manage Holds\n\nHolds preserve data indefinitely to meet legal or preservation obligations. Usually holds are placed on one or more users to ensure that the data potentially relevant to a matter cannot be deleted until that matter is no longer active.\n\nIf a user who is subject to a hold deletes held data, that data is removed from the user's view, but it is preserved in Vault. As long as the hold is in place, a Vault admin can search and export that data.\n\nHolds have the following components:\n\n- **A service---**the application responsible for the data to be held. The service can be set to mail, Drive, or Groups.\n- **A scope---**the entities covered by the hold. The scope can be set to one or more user accounts, or to an organizational unit (OU).\n- **Additional options (optional)---** the specific details (search queries or configuration options) used to narrow down the data to be held within the defined scope. Options include:\n - mail, Groups: search query to narrow down the hold\n - Drive: include shared drives in the hold\n\nTo work with Vault resources, the account must have the [required Vault\nprivileges](https://support.google.com/vault/answer/2799699) and access to the\nmatter. To access a matter, the account must have created the matter, have the\nmatter shared with them, or have the **View All Matters** privilege.\n| **Note:** A [matter](/workspace/vault/guides/matters) must exist before you can create a hold.\n\nCreate a hold for mail on specific user accounts with a search query\n--------------------------------------------------------------------\n\nThe following example shows how a hold named \"My First mail Accounts Hold\" is created for:\n\n- Service: mail\n- Entity: user accounts \"user1\" and \"user2\"\n- Additional options: search query \"to:ceo@company.com\"\n\nRetrieve user account IDs from the\n[Directory API](/workspace/admin/directory).\nNote that the HeldAccount can take in account ID or email. If both are given,\nemail is used and account ID is ignored. \n\n### Java\n\n```java\nHeldMailQuery mailQuery = new HeldMailQuery().setTerms(\"to:ceo@company.com\");\nList accounts = Lists.newArrayList();\naccounts.add(new HeldAccount().setAccountId(user1accountId));\naccounts.add(new HeldAccount().setEmail(user2Email));\nHold hold = new Hold()\n .setName(\"My First mail Accounts Hold\")\n .setCorpus(\"MAIL\");\n .setQuery(new CorpusQuery().setMailQuery(mailQuery))\n .setAccounts(accounts);\nHold createdHold = client.matters().holds().create(matterId, hold).execute();\n \n```\n\n### Python\n\n```python\ndef create_hold_mail_accounts(service, matter_id, account_id):\n mail_query = {'terms': 'to:ceo@company.com'}\n accounts = [\n {'accountId': user1_account_id},\n {'email': user2_email}\n ]\n wanted_hold = {\n 'name': 'My First mail Accounts Hold',\n 'corpus': 'MAIL',\n 'query': {\n 'mailQuery': mail_query\n },\n 'accounts': accounts\n }\n return service.matters().holds().create(\n matterId=matter_id, body=wanted_hold).execute()\n```\n\nCreate a hold for Drive on an OU and include shared drive content\n-----------------------------------------------------------------\n\nThe following example shows how a hold named \"My First Drive OU Hold\" is created for:\n\n- Service: Drive\n- Entity: org unit \"Finance\" (OU ID is captured in orgUnitId)\n- Additional options: include shared drives that users in this org unit are members of\n\nRetrieve OU IDs from the [Directory API](/workspace/admin/directory). \n\n### Java\n\n```java\nHeldOrgUnit orgUnit = new HeldOrgUnit().setOrgUnitId(orgUnitId);\n// Include shared drives content.\nHeldDriveQuery driveQuery = new HeldDriveQuery().setIncludeSharedDriveFiles(true);\n// Create the hold.\nHold hold = new Hold()\n .setName(\"My First Drive OU Hold\")\n .setCorpus(\"DRIVE\")\n .setQuery(new CorpusQuery().setDriveQuery(driveQuery))\n .setOrgUnit(orgUnit);\nHold createdHold = client.matters().holds().create(matterId, hold).execute();\nreturn createdHold;\n```\n\n### Python\n\n```python\ndef create_hold_drive_org(service, matter_id, org_unit_id):\n drive_query = {'includeSharedDriveFiles': True}\n org_unit = {'orgUnitId': org_unit_id}\n wanted_hold = {\n 'name': 'My First Drive OU Hold',\n 'corpus': 'DRIVE',\n 'orgUnit': org_unit,\n 'query': {\n 'driveQuery': drive_query\n }\n }\n return service.matters().holds().create(\n matterId=matter_id, body=wanted_hold).execute()\n```\n\nCreate a hold for Groups on specific group accounts with a date range\n---------------------------------------------------------------------\n\nThe following example shows how a hold named \"My First Group Hold\" is created for:\n\n- Service: Groups\n- Entity: group accounts \"group1\" and \"group2\"\n- Additional options: hold only messages with sent dates between \"startTime\" and \"endTime\"\n\nRetrieve group account IDs from the\n[Directory API](/workspace/admin/directory). \n\n### Java\n\n```java\nString APRIL_2_2017_GMT = \"2017-04-02T00:00:00Z\"; // See below for format*.\n \nList accounts = Lists.newArrayList();\naccounts.add(new HeldAccount().setAccountId(accountId));\naccounts.add(new HeldAccount().setAccountId(accountId2));\nHeldGroupsQuery groupQuery = new HeldGroupsQuery();\n// Restrict by sent date.\ngroupQuery.setStartTime(APRIL_2_2017_GMT);\ngroupQuery.setEndTime(APRIL_2_2017_GMT);\n// create the hold\nHold hold = new Hold()\n .setName(\"My First Group Hold\")\n .setCorpus(\"GROUPS\")\n .setQuery(new CorpusQuery().setGroupsQuery(groupQuery));\n hold.setAccounts(accounts);\nHold createdHold = client.matters().holds().create(matterId, hold).execute();\n \n```\n\n### Python\n\n```python\ndef create_hold_groups_date_range(service, matter_id, group_account_id):\n groups_query = {\n 'startTime': '2017-04-02T00:00:00Z', # See below for format*\n 'endTime': '2017-04-02T00:00:00Z'\n }\n accounts = [{'accountId': group_account_id}]\n wanted_hold = {\n 'name': 'My First Group Hold',\n 'corpus': 'GROUPS',\n 'query': {\n 'groupsQuery': groups_query\n },\n 'accounts': accounts\n }\n return service.matters().holds().create(\n matterId=matter_id, body=wanted_hold).execute()\n \n```\n\n- [Timestamp format](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto#L99). Additionally, start/endTimes are converted to GMT and rounded down to the start of the given date.\n\nQuery and modify existing holds\n-------------------------------\n\nThe following example shows how to list all of the accounts included in an existing hold: \n\n### Java\n\n```java\nclient.matters().holds().accounts().list(matterId, holdId).execute().getAccounts();\n```\n\n### Python\n\n```python\n# If no accounts are on hold, ['accounts'] will raise an error.\ndef list_held_accounts(service, matter_id, hold_id):\n return service.matters().holds().accounts().list(\n matterId=matter_id, holdId=hold_id).execute()['accounts'] \n```\n\nThe following example shows how to add an account to, and remove an account from, an existing hold: \n\n### Java\n\n```java\n// Add an account by id.\nclient\n .matters()\n .holds()\n .accounts()\n .create(matterId, holdId, new HeldAccount().setAccountId(accountId))\n .execute();\n// Remove an account by id.\nclient.matters().holds().accounts().delete(matterId, holdId, accountId).execute();\n\nString email = \"email@email.com\";\n// Add an account by email.\nclient\n .matters()\n .holds()\n .accounts()\n .create(matterId, holdId, new HeldAccount().setEmail(email))\n .execute();\n```\n\n### Python\n\n```python\n \ndef add_held_account(service, matter_id, hold_id, account_id):\n held_account = {'accountId': account_id}\n return service.matters().holds().accounts().create(\n matterId=matter_id, holdId=hold_id, body=held_account).execute()\n\ndef remove_held_account(service, matter_id, hold_id, account_id):\n return service.matters().holds().accounts().delete(\n matterId=matter_id, holdId=hold_id, accountId=account_id).execute()\n\ndef add_held_account(service, matter_id, hold_id, email):\n held_account = {'email': email}\n return service.matters().holds().accounts().create(\n matterId=matter_id, holdId=hold_id, body=held_account).execute()\n \n```\n\nThe following example shows how to modify the OU on an existing OU hold: \n\n### Java\n\n```java\nHold hold = client.matters().holds().get(matterId, holdId).execute();\nhold.getOrgUnit().setOrgUnitId(newOrgUnitId);\nHold modifiedHold = client.matters().holds().update(matterId, holdId, hold).execute();\nreturn modifiedHold;\n \n```\n\n### Python\n\n```python\ndef update_hold_ou(service, matter_id, hold_id, org_unit_id):\n current_hold = get_hold(matter_id, hold_id)\n current_hold['orgUnit'] = {'orgUnitId': org_unit_id}\n return service.matters().holds().update(\n matterId=matter_id, holdId=hold_id, body=current_hold).execute() \n```\n\nThe following example shows how to list all holds for a matter: \n\n### Java\n\n```java\n \nString matterId = \"Matter Id\";\n\n// List all holds.\nList holdsList = \n client.matters().holds().list(matterId).execute().getHolds();\n\n// Paginate on holds.\nListHoldsResponse response = client\n .matters()\n .holds()\n .list(matterId)\n .setPageSize(10)\n .execute();\n\nString nextPageToken = response.getNextPageToken();\nif (nextPageToken != null) {\n client\n .matters()\n .holds()\n .list(matterId)\n .setPageSize(10)\n .setPageToken(nextPageToken)\n .execute();\n}\n \n```\n\n### Python\n\n```python\n# This can paginate in the same manner as with matters.\ndef list_holds(service, matter_id):\n return service.matters().holds().list(matterId=matter_id).execute()\n \n```\n\n\u003cbr /\u003e"]]