管理导出内容

借助 Vault API,您可以管理 Vault 导出内容。您可以:

  • 创建导出内容 - 向保险柜发送请求,以查找符合查询条件的邮件或文件,并将其导出到 Google Cloud。

    注意

    • 贵组织中同时运行的导出操作不能超过 20 项。为了加快导出速度,请将大型导出作业拆分为多个较小的导出作业。例如,按月导出数据,而不是一次性导出所有数据。另一种方法是在每次导出中包含较少的项目,例如用户、群组或聊天室。
    • 导出内容会在创建后保留 15 天,之后会被删除,无法再访问。

    示例:

  • 列出导出内容 - 检索与诉讼事宜关联的所有导出内容的状态。

  • 获取导出 - 检索有关导出的信息。

  • 下载导出内容 - 从 Google Cloud 下载导出内容。

  • 删除导出内容 - 在不再需要导出内容时,从事宜中移除导出内容。

准备工作

如需设置所需的库和身份验证,请完成相应编程语言的快速入门。

如需使用保险柜资源,相应账号必须拥有所需的保险柜权限,并且能够访问相应事宜。如需访问诉讼或调查,相应账号必须已创建该诉讼或调查、已与该账号共享该诉讼或调查,或者该账号拥有查看所有诉讼或调查的权限。

创建 Gmail 数据导出作业

以下示例展示了如何创建 Gmail 数据导出任务。此请求会导出符合以下条件的所有 Gmail 邮件和传统版 Hangouts 消息:

  • 归账号 email1email2 所有的消息。
  • 排除邮件草稿。
  • 发送给 ceo@solarmora.com 的消息。

提示:这些示例使用的是旧版 Gmail 导出系统。如需使用新版导出系统进行导出,请在 MailExportOptions 中将 useNewExport 设置为 true。

Java

public Export createMailAccountHeldDataExports(Vault client, String matterId) {
  AccountInfo emailsToSearch = new AccountInfo().setEmails(ImmutableList.of("email1", "email2"));
  MailOptions mailQueryOptions = new MailOptions().setExportFormat("PST");
  String queryTerms = "to:ceo@solarmora.com";
  Query mailQuery =
      new Query()
          .setCorpus("MAIL")
          .setDataScope("HELD_DATA")
          .setSearchMethod("ACCOUNT")
          .setAccountInfo(emailsToSearch)
          .setTerms(queryTerms)
          .setMailOptions(mailQueryOptions);
  MailExportOptions mailExportOptions =
      new MailExportOptions()
          .setExportFormat("MBOX")
          .showConfidentialModeContent(true);
  Export wantedExport =
      new Export()
          .setMatterId(matterId)
          .setName("My first mail accounts export")
          .setQuery(mailQuery)
          .setExportOptions(new ExportOptions().setMailOptions(mailExportOptions));
  return client.matters().exports().create(matter, wantedExport).execute();
}

Python

def create_mail_account_held_data_export(service, matter_id):
  emails_to_search = ['email1', 'email2']
  mail_query_options = {'excludeDrafts': True}
  query_terms = 'to:ceo@solarmora.com'
  mail_query = {
      'corpus': 'MAIL',
      'dataScope': 'HELD_DATA',
      'searchMethod': 'ACCOUNT',
      'accountInfo': {
          'emails': emails_to_search
      },
      'terms': query_terms,
      'mailOptions': mail_query_options,
  }
  mail_export_options = {
      'exportFormat': 'MBOX',
      'showConfidentialModeContent': True
      }
  wanted_export = {
      'name': 'My first mail accounts export',
      'query': mail_query,
      'exportOptions': {
          'mailOptions': mail_export_options
  }
}
return service.matters().exports().create(
  matterId=matter_id, body=wanted_export).execute()

创建云端硬盘导出

以下示例展示了如何创建 Google 云端硬盘导出。此请求会导出符合以下条件的所有文件,包括共享云端硬盘中的文件:

  • 属于指定组织部门(通过 Admin SDK 获取)。
  • 是在指定时间之间创建的。

Java

public Export createDriveOuAllDataExport(Vault client, String matterId) {
  OrgUnitInfo ouToSearch = new OrgUnitInfo().setOrgUnitId("ou id retrieved from admin sdk");
  DriveOptions driveQueryOptions = new DriveOptions().setIncludeSharedDrives(true);
  Query driveQuery =
      new Query()
          .setCorpus("DRIVE")
          .setDataScope("ALL_DATA")
          .setSearchMethod("ORG_UNIT")
          .setOrgUnitInfo(ouToSearch)
          .setDriveOptions(driveQueryOptions)
          .setStartTime("2017-03-16T00:00:00Z")
          .setEndTime("2017-03-16T00:00:00Z")
          .setTimeZone("Etc/GMT+2");
  DriveExportOptions driveExportOptions = new DriveExportOptions().setIncludeAccessInfo(false);
  Export wantedExport =
      new Export()
          .setName("My first drive ou export")
          .setQuery(driveQuery)
          .setExportOptions(new ExportOptions().setDriveOptions(driveExportOptions));
  return client.matters().exports().create(matter, wantedExport).execute();
}

Python

def create_drive_ou_all_data_export(service, matter_id):
  ou_to_search = 'ou id retrieved from admin sdk'
  drive_query_options = {'includeSharedDrives': True}
  drive_query = {
    'corpus': 'DRIVE',
    'dataScope': 'ALL_DATA',
    'searchMethod': 'ORG_UNIT',
    'orgUnitInfo': {
        'org_unit_id': ou_to_search
    },
    'driveOptions': drive_query_options,
    'startTime': '2017-03-16T00:00:00Z',
    'endTime': '2017-09-23T00:00:00Z',
    'timeZone': 'Etc/GMT+2'
  }
  drive_export_options = {'includeAccessInfo': False}
  wanted_export = {
    'name': 'My first drive ou export',
    'query': drive_query,
    'exportOptions': {
        'driveOptions': drive_export_options
    }
  }
return service.matters().exports().create(
  matterId=matter_id, body=wanted_export).execute()

创建 Meet 导出

以下示例展示了如何创建 Meet 数据导出。此请求会导出指定组织部门中与账号关联的文件,这些文件的文件名遵循 Meet 录制内容的命名模式。

Python

def create_meet_export(service, matter_id, ou_to_search, export_name):
  export = {
    'name': export_name,
    'query': {
        'corpus': 'DRIVE',
        'dataScope': 'ALL_DATA',
        'searchMethod': 'ORG_UNIT',
        'terms': 'title:"...-...-... \\(....-..-.. at ..:.. *\\)"',
        'orgUnitInfo': {
            'orgUnitId': 'id:'+ou_to_search
        },
        'driveOptions': {
            'includeTeamDrives': True,
            'includeSharedDrives': True
        },
        'timeZone': 'Etc/GMT',
        'method': 'ORG_UNIT'
    },
    'exportOptions': {
        'driveOptions': {},
        'region': 'ANY'
    },
  }

  return service.matters().exports().create(
    matterId=matter_id, body=export).execute()

从已保存的查询中导出

以下示例展示了如何根据已保存的查询创建导出。

Python

def create_mail_export_from_saved_query(service, matter_id, saved_query_id, export_name):
  export = {
    'name': export_name,
    'exportOptions': {
      'mailOptions': {
        'exportFormat': 'PST',
        'showConfidentialModeContent': True
      },
    'region': 'ANY'
    }
  }

  export['query'] = service.matters().savedQueries().get(
    savedQueryId=saved_query_id, matterId=matter_id).execute()['query']
  return service.matters().exports().create(
    matterId=matter_id, body=export).execute()

列出导出作业

以下示例展示了如何检索与事宜关联的导出列表。

Java

public class exports {
  public ListExportsResponse listExports(Vault client, String matterId) {
    return client.matters().exports().list(matterId).execute();
}

Python

def list_exports(service, matter_id):
 return service.matters().exports().list(matterId=matter_id).execute()

获取导出作业的相关信息

以下示例展示了如何获取有关特定导出的信息。 注意:如需下载导出的文件和消息,您可以使用 Cloud API(请参阅下一个示例)。

Java

public Export getExportById(Vault client, String matterId, String exportId) {
  return client.matters().exports().get(matterId, exportId).execute();
}

Python

def get_export_by_id(service, matter_id, export_id):
  return service.matters().exports().get(
    matterId=matter_id, exportId=export_id).execute()

从 Google Cloud 下载导出内容

以下示例展示了如何从 Google Cloud 下载某个事宜中的所有已完成的导出内容。此请求使用 Vault 和 Cloud API。

注意:如需下载导出内容,相应账号需要拥有“管理导出内容”权限,并且需要与该账号共享诉讼或调查。

Python

def download_exports(service, matter_id):
"""Google Cloud storage service is authenticated by running
`gcloud auth application-default login` and expects a billing enabled project
in ENV variable `GOOGLE_CLOUD_PROJECT` """
gcpClient = storage.Client()
matter_id = os.environ['MATTERID']
  for export in vaultService.matters().exports().list(
      matterId=matter_id).execute()['exports']:
    if 'cloudStorageSink' in export:
      directory = export['name']
      if not os.path.exists(directory):
        os.makedirs(directory)
      print(export['id'])
      for sinkFile in export['cloudStorageSink']['files']:
        filename = '%s/%s' % (directory, sinkFile['objectName'].split('/')[-1])
        objectURI = 'gs://%s/%s' % (sinkFile['bucketName'],
                                    sinkFile['objectName'])
        print('get %s to %s' % (objectURI, filename))
        gcpClient.download_blob_to_file(objectURI, open(filename, 'wb+'))

删除导出内容

以下示例展示了如何删除导出作业。

Java

public void deleteExportById(Vault client, String matterId, String exportId) {
   client.matters().exports().delete(matterId, exportId).execute();

Python

def delete_export_by_id(service, matter_id, export_id):
  return service.matters().exports().delete(
    matterId=matter_id, exportId=export_id).execute()

如需了解有关搜索和导出的应用特定信息(包括搜索限制),请参阅保险柜搜索和导出功能使用入门