Vault API की मदद से, Vault से डेटा एक्सपोर्ट करने की प्रोसेस को मैनेज किया जा सकता है. आप:
एक्सपोर्ट बनाएं—Vault को एक अनुरोध भेजें, ताकि वह आपकी क्वेरी से मैच करने वाले मैसेज या फ़ाइलों को ढूंढ सके और उन्हें Google Cloud में एक्सपोर्ट कर सके.
ध्यान दें: आपके संगठन में, एक बार में 20 से ज़्यादा एक्सपोर्ट नहीं हो सकते. परफ़ॉर्मेंस को बेहतर बनाने के लिए, बड़े एक्सपोर्ट को छोटे सेट में बांटें. उदाहरण के लिए, एक साथ सारा डेटा एक्सपोर्ट करने के बजाय, उसे महीने के हिसाब से बांटकर एक्सपोर्ट करें. एक और उदाहरण, हर एक्सपोर्ट में कम इकाइयां शामिल करना है. जैसे, उपयोगकर्ता और ग्रुप, चैट स्पेस जैसी खास इकाइयां.
उदाहरण:
एक्सपोर्ट की सूची—किसी मामले से जुड़े सभी एक्सपोर्ट की स्थिति देखें.
एक्सपोर्ट पाएं—किसी एक्सपोर्ट के बारे में जानकारी पाएं.
एक्सपोर्ट डाउनलोड करें—Google Cloud से एक्सपोर्ट डाउनलोड करें.
एक्सपोर्ट मिटाना—जब किसी मामले में एक्सपोर्ट की ज़रूरत न हो, तो उन्हें हटाएं.
शुरू करने से पहले
ज़रूरी लाइब्रेरी और पुष्टि करने की सुविधा सेट अप करने के लिए, अपनी प्रोग्रामिंग भाषा के लिए, शुरू करने का तरीका देखें.
Vault के संसाधनों का इस्तेमाल करने के लिए, आपके खाते के पास Vault के ज़रूरी ऐक्सेस और मामले का ऐक्सेस होना चाहिए. किसी मामले को ऐक्सेस करने के लिए, ज़रूरी है कि खाते ने वह मामला बनाया हो, उसने वह मामला शेयर किया हो या उसके पास सभी मामले देखें की अनुमति हो.
Gmail से डेटा एक्सपोर्ट करना
यहां दिए गए उदाहरण में, Gmail से डेटा एक्सपोर्ट करने का तरीका बताया गया है. इस अनुरोध से, Gmail और Hangouts के क्लासिक वर्शन के वे सभी मैसेज एक्सपोर्ट हो जाते हैं जो इन शर्तों को पूरा करते हैं:
email1
औरemail2
के मालिकाना हक वाले मैसेज.- इसमें ड्राफ़्ट में मौजूद मैसेज शामिल नहीं होते.
ceo@solarmora.com
को भेजे गए मैसेज.
सलाह: इन उदाहरणों में, Gmail के क्लासिक एक्सपोर्ट सिस्टम का इस्तेमाल किया गया है. नए एक्सपोर्ट सिस्टम का इस्तेमाल करके डेटा एक्सपोर्ट करने के लिए, MailExportOptions में जाकर, useNewExport
को 'सही है' पर सेट करें.
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();
}
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()
Drive का डेटा एक्सपोर्ट करना
यहां दिए गए उदाहरण में, Drive से डेटा एक्सपोर्ट करने का तरीका बताया गया है. इस अनुरोध से, शेयर की गई ड्राइव में मौजूद फ़ाइलों के साथ-साथ, ऐसी सभी फ़ाइलें एक्सपोर्ट हो जाती हैं जो इन शर्तों को पूरा करती हैं:
- संगठन की किसी खास इकाई से जुड़े हों (यह जानकारी, Admin SDK से मिलती है).
तय किए गए समय के बीच बनाए गए हों.
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();
}
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 रिकॉर्डिंग के पैटर्न के मुताबिक है.
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()
सेव की गई क्वेरी से एक्सपोर्ट करना
यहां दिए गए उदाहरण में, सेव की गई क्वेरी से एक्सपोर्ट बनाने का तरीका बताया गया है.
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()
एक्सपोर्ट की सूची
इस उदाहरण में, किसी मामले से जुड़े एक्सपोर्ट की सूची को वापस पाने का तरीका बताया गया है.
public class exports {
public ListExportsResponse listExports(Vault client, String matterId) {
return client.matters().exports().list(matterId).execute();
}
def list_exports(service, matter_id):
return service.matters().exports().list(matterId=matter_id).execute()
एक्सपोर्ट के बारे में जानकारी पाना
यहां दिए गए उदाहरण में, किसी खास एक्सपोर्ट के बारे में जानकारी पाने का तरीका बताया गया है. ध्यान दें: एक्सपोर्ट की गई फ़ाइलों और मैसेज को डाउनलोड करने के लिए, अगले उदाहरण में बताए गए Cloud API का इस्तेमाल किया जाता है.
public Export getExportById(Vault client, String matterId, String exportId) {
return client.matters().exports().get(matterId, exportId).execute();
}
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 का इस्तेमाल करता है.
ध्यान दें: एक्सपोर्ट डाउनलोड करने के लिए, किसी खाते के पास एक्सपोर्ट मैनेज करने का ऐक्सेस होना चाहिए. साथ ही, उस खाते के साथ वह मेट्रिक शेयर की गई हो.
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+'))
एक्सपोर्ट मिटाना
यहां दिए गए उदाहरण में, एक्सपोर्ट मिटाने का तरीका बताया गया है.
public void deleteExportById(Vault client, String matterId, String exportId) {
client.matters().exports().delete(matterId, exportId).execute();
def delete_export_by_id(service, matter_id, export_id):
return service.matters().exports().delete(
matterId=matter_id, exportId=export_id).execute()
खोजने और एक्सपोर्ट करने की सुविधा के बारे में ऐप्लिकेशन के हिसाब से जानकारी पाने के लिए, Vault में खोजने और एक्सपोर्ट करने की सुविधा को इस्तेमाल करने के बारे में जानें लेख पढ़ें. इसमें, खोज की सीमाओं के बारे में भी बताया गया है.