管理匯出作業

Vault API 可讓您管理保管箱匯出內容。方法如下:

  • 建立匯出作業:將要求傳送至保管箱,找出與查詢相符的訊息或檔案,然後將這些訊息或檔案匯出至 Google Cloud。

    注意:貴機構最多只能執行 20 項匯出作業。為提升效能,請將大型匯出作業分成數個較小的集合。例如,您可以按照月份分割匯出項目,而不是一次匯出所有資料。另一個例子是,減少每項匯出作業中的實體數量 (例如使用者和群組和聊天室等特殊實體)。

    示例:

  • 清單匯出項目:擷取與案件相關聯的所有匯出狀態。

  • 取得匯出內容:擷取匯出相關資訊。

  • 下載匯出項目:從 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()

建立雲端硬碟匯出作業

以下範例將展示如何建立雲端硬碟匯出項目。這項要求會匯出符合下列條件的所有檔案,包括共用雲端硬碟中的檔案:

  • 屬於指定機構單位 (已透過 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()

如需關於搜尋與匯出特定應用程式的資訊 (包括搜尋限制),請參閱開始使用保管箱搜尋和匯出功能