จัดการการส่งออก

Vault API ช่วยให้คุณจัดการการส่งออกของห้องนิรภัยได้ โดยคุณสามารถทำดังนี้

ก่อนเริ่มต้น

หากต้องการตั้งค่าไลบรารีและการตรวจสอบสิทธิ์ที่จำเป็น ให้ทำตามการเริ่มต้นอย่างรวดเร็วสำหรับภาษาโปรแกรมที่คุณใช้

หากต้องการทำงานกับทรัพยากรของห้องนิรภัย บัญชีดังกล่าวต้องมีสิทธิ์ที่จำเป็นของห้องนิรภัยและสิทธิ์เข้าถึงกรณี หากต้องการเข้าถึงกรณี บัญชีจะต้องสร้างกรณี แชร์กรณีให้ก่อน หรือมีสิทธิ์ดูกรณีทั้งหมด

สร้างการส่งออก Gmail

ตัวอย่างต่อไปนี้แสดงวิธีสร้างการส่งออก Gmail คำขอนี้จะส่งออกข้อความใน Gmail และ Hangouts แบบคลาสสิกทั้งหมดที่ตรงกับเกณฑ์ต่อไปนี้

  • ข้อความที่เป็นของบัญชี email1 และ email2
  • ไม่รวมข้อความร่าง
  • ส่งข้อความถึง 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 APIs (ในตัวอย่างถัดไป)

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 คำขอนี้ใช้ API ของห้องนิรภัยและ Cloud

หมายเหตุ: หากต้องการดาวน์โหลดการส่งออก บัญชีจะต้องมีสิทธิ์จัดการการส่งออกและกรณีที่มีการแชร์กับตนเอง

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

โปรดดูข้อมูลเฉพาะเกี่ยวกับแอปในการค้นหาและการส่งออก รวมถึงขีดจำกัดการค้นหาที่หัวข้อเริ่มต้นใช้งานการค้นหาและการส่งออกของห้องนิรภัย