Manage exports

This API lets you programmatically manage Vault exports. You can:

  • create exports—send a request to Vault that gathers messages and files that match your criteria.
  • list exports—retrieve the status of all exports associated with a matter.
  • get exports—retrieve an export when Vault has finished processing your data.
  • delete exports—remove exports from a matter when they are no longer needed.

Create a mail export

The following example shows how to create a mail export. This request exports all messages that meet the following criteria:

  • messages owned by accounts email1 and email2.
  • excludes draft messages.
  • messages sent to ceo@solarmora.com.

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");
    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'}
  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()

Create a Drive export

The following example shows how to create a Drive export. This request exports all files, including those in Team Drives, that meet the following criteria:

  • belong to the specified organizational unit (obtained with the Admin SDK).
  • were created between the specified times.

Java

 public Export createDriveOuAllDataExport(Vault client, String matterId) {
    OrgUnitInfo ouToSearch = new OrgUnitInfo().setOrgUnitId("ou id retrieved from admin sdk");
    DriveOptions driveQueryOptions = new DriveOptions().setIncludeTeamDrives(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 = {'includeTeamDrives': 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()

List exports

The following example shows how to retrieve a list of exports associated with a matter.

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()

Get an export

Once Vault finishes processing an export you've created, use this method to get the export:

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()

Delete an export

The following example shows how to delete an export.

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()