管理訴訟保留
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
為遵循法規或履行保存義務,您可以設定訴訟保留狀態,無限期保存資料。通常會對一或多位使用者設定訴訟保留,確保與案件相關的資料在案件結束前不會遭到刪除。
如果設有訴訟保留的帳戶遭到使用者刪除資料,即便資料會從使用者的檢視畫面中移除,相關資料仍會留存在保管箱中。只要訴訟保留設定還在,保管箱管理員就可以搜尋和匯出該資料。
保留項目包含下列元件:
- 服務:負責保存資料的應用程式。服務可設為郵件、雲端硬碟或群組。
- 範圍:訴訟保留涵蓋的實體。範圍可設為一或多個使用者帳戶,或設為機構單位 (OU)。
- 其他選項 (選用):用於縮小定義範圍內資料範圍的具體詳細資料 (搜尋查詢或設定選項)。選項包括:
- 郵件、群組:縮小保留範圍的搜尋查詢
- 雲端硬碟:將共用雲端硬碟納入暫時保留範圍
如要使用 Vault 資源,帳戶必須具備必要的 Vault 權限,且有權存取案件。如要存取案件,帳戶必須是案件建立者、共用對象,或具備「查看所有案件」權限。
使用搜尋查詢,為特定使用者帳戶的郵件建立保留
以下範例說明如何為下列項目建立名為「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()
為機構單位建立 Google 雲端硬碟保留項目,並納入共用雲端硬碟內容
以下範例說明如何為下列項目建立名為「My First Drive OU Hold」的保留:
- 服務:雲端硬碟
- 實體:機構單位「Finance」(機構單位 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」的保留項目:
- 服務:群組
- 實體:群組帳戶「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()
- 時間戳記格式。此外,開始/結束時間會轉換為格林威治標準時間,並向下捨入至指定日期的開頭。
查詢及修改現有保留
以下範例說明如何列出現有暫緩處置中的所有帳戶:
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()
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間: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"]]