Library to use Google Vault with Google Apps Script
This library aim to let you use Google vault feature in Google Apps Script.
You can use the library asis just by linking it. But as it's usage can touch sensitive data you may prefer to copy the source to your own repository in order to have full control of what is beneth.
From the editor
page of your Google Apps Script Project select the +
in the Libraries
section to add a new library.
Pass the following script ID:
1yXuSYg04wH88jOi47oaPZahRjD3RN20tfkv7eQXrWvhnIi9c09i4q9up
and select look up
Select the last version available and let the default identifier to Vault
In order to use the library you need to activate Vault API in your Google Apps Script project. If you do not want to use a "classic" GCP Project but rather use the "Default" GCP Project, please refer to the following documentation: https://developers.google.com/apps-script/guides/admin/view-cloud-projects
Open the script: https://script.google.com/home/projects/1yXuSYg04wH88jOi47oaPZahRjD3RN20tfkv7eQXrWvhnIi9c09i4q9up Make a copy of it on your own domain. Check that there is nothing in the code that may harm your domain (otherwise cut it off at your own risk).
- Use it directly to make your development
In this scenario omit the keyword
Vault
to invoke the library as shown in the rest of the document Example, replace:byvar matter = Vault.openMatterById("id");
var matter = openMatterById("id");
or
- Create your own alternate library from it.
Use the
deploy
button on the top right corner to create a new publication (as library). You can then use the script ID (from the script URL) as in the section Link the library
You can invoke the library by it's instantiation name (default being "Vault")
Library methods are available through autocompletion
Note: The library is not wrote in modern JS with Class in order to allow autocompletion in GAS that is otherwise not supported
var listing = Vault.getMatters(); // will return a list of matters object
Method | Return type | Description |
---|---|---|
createMatter(name, description) | MATTER | Create a new Matter in DRAFT state |
listMatters(state) | Array | List all the matters corresponding to a given state (method do not list deleted matter if not explicitely requested) |
openMatterById(matterId) | MATTER | Open a matter from it's ID |
openExportById(matterId, exportId) | EXPORT | Open an export from the Matter Id and Export Id |
var matter = new Vault.Matter("name", "description");
var matter = new Vault.Matter();
matter.setName("name").setDescription("description");
Fields | |
---|---|
id | String The matter ID, which is generated by the server. Leave blank when creating a matter. |
name | String Matter name |
description | String Matter description |
state | enum Matter state |
exports | Array Matter exports |
TODO add matter permissions
Method | Return type | Description |
---|---|---|
setName(name) | Matter (for chaining) |
Set the name (String) of a matter in view to create it |
setDescription(description) | Matter (for chaining) |
Set a description (String) of the matter in view to create it |
openMatterById(matterId) | Matter | Open a matter from it's ID and return it |
getName() | name | Gather the name (String) of a given matter |
getDescription() | description | Gather the description (String) of a given matter |
getState() | STATE | retrieve the state of the active matter |
getInfos() | Object | retrieve raw informations regarding a matter |
create() | Matter (for chaining) |
Create a matter from the draft data |
getId() | MatterId | Gather matterId(String) |
close() | RawMatter | Close a Matter, will return a JSON representing the matter as in the "setStatus" method |
addCollaborator(email, role) | Collaborator | Add a collaborator with a given role to the active matter |
removeCollaborator(email) | "removed" | Removed a collaborator and return a confirmation String |
--- | --- | --- |
createUserExport(account, exportType, name, options) | Export | Create an export from a search of a user files |
createExport(name, query, exportOptions) | Export | Create an export from a query like in the official documentation |
getExports() | [Export] | Display the list of the actives exports from the matter |
openExportById(exportId) | Export | Open an export and return it as an Object |
listExports() | [Export] | Retrieve the list of the exports from the current Matter |
--- | --- | --- |
openHoldById(holdId) | Hold | Open an hold and return it as an Object |
listHolds() | [Hold] | Retrieve the list of the holds from the current Matter |
TODO Hold section
Enums | |
---|---|
ROLE_UNSPECIFIED | No role assigned. (I still don't know what to do with this information) |
COLLABORATOR | A collaborator on the matter. |
OWNER | The owner of the matter. |
Enums | |
---|---|
DRAFT | Matter yet to be created |
STATE_UNSPECIFIED | The matter has no specified state. |
OPEN | The matter is open. |
CLOSED | The matter is closed. |
DELETED | The matter is deleted. |
var matter = Vault.openMatterById(matterId);
var vaultExport = matter.openExportById(exportId);
var vaultExport = new Vault.Export(matterId, exportId);
Fields | |
---|---|
id | String The export ID, which is generated by the server. Leave blank when creating a matter. |
matterId | String Matter ID that held the export |
name | String name of the export |
state | enum export state |
files | Array exports files |
Method | Return type | Description |
---|---|---|
getId() | id | Get the exportId (String) |
setName(name) | Export for chaining | set the current export name |
getStatus() | EXPORT_STATUS | get the active export status |
getInfos() | ExportInfos | get the export raw informations |
getFiles() | [Files] | List of the files contained in the export |
remove() | null | Delete the current export |
https://developers.google.com/vault/reference/rest/v1/matters.exports#exportstatus
Enums | |
---|---|
EXPORT_STATUS_UNSPECIFIED | The status is unspecified. |
COMPLETED | The export completed. |
FAILED | The export failed. |
IN_PROGRESS | The export is in progress. |
Enums | |
---|---|
emails | |
DRIVE | Drive files |
GROUP | Not implemented yet |
CHAT | Not implemented yet |
VOICE | Not implemented yet |
Export format for messages
Enums | |
---|---|
EXPORT_FORMAT_UNSPECIFIED | No export format specified. |
MBOX | Export as MBOX. Only available for Gmail, Groups, Hangouts and Voice. |
PST | Export as PST. Only available for Gmail, Groups, Hangouts, Voice and Calendar. |
terms https://support.google.com/vault/answer/2474474
[Not yes implemented] https://developers.google.com/vault/reference/rest/v1/matters.holds
var matter = Vault.openMatterById(matterId);
var hold = matter.openHoldById(holdId);
var hold = new Vault.Hold(matterId, holdId);
Method | Return type | Description |
---|---|---|
getId() | id | Get the holdId (String) |
setName(name) | Hold for chaining | set the current hold name |
getInfos() | HoldInfos | get the hold raw informations |
getType() | HoldType | user or ou |
removeUser(email) | null | remove user from hold |
removeOu(orgUnitPath) | null | remove OU from hold |
close() |