[英]Is there any way to download exported data from a Google Vault Export?
From documentation on https://developers.google.com/vault/guides/exports , I've been able to create, list, and retrieve exports, but I haven't found any way to download the exported data associated with a specific export.从https://developers.google.com/vault/guides/exports 上的文档中,我已经能够创建、列出和检索导出,但我还没有找到任何方法来下载与特定关联的导出数据出口。 Is there any way to download the exported files via the API, or is this only available through the vault UI?
有什么办法可以通过 API 下载导出的文件,还是只能通过 Vault UI 下载?
There is a cloudStorageSink
key in the export metadata, but trying to use the values provided using the cloud storage API results in a generic permissions issue (403 Error).导出元数据中有一个
cloudStorageSink
键,但尝试使用通过云存储 API 提供的值会导致通用权限问题(403 错误)。
Example export metadata response:示例导出元数据响应:
{
"status": "COMPLETED",
"cloudStorageSink": {
"files": [
{
"md5Hash": "da5e3979864d71d1e3ac776b618dcf48",
"bucketName": "408d9135-6155-4a43-9d3c-424f124b9474",
"objectName": "a740999b-e11b-4af5-b8b1-6c6def35d677/exportly-41dd7886-fe02-432f-83c-a4b6fd4520a5/Test_Export-1.zip",
"size": "37720"
},
{
"md5Hash": "d345a812e15cdae3b6277a0806668808",
"bucketName": "408d9135-6155-4a43-9d3c-424f124b9474",
"objectName": "a507999b-e11b-4af5-b8b1-6c6def35d677/exportly-41dd6886-fb02-4c2f-813c-a4b6fd4520a5/Test_Export-metadata.xml",
"size": "8943"
},
{
"md5Hash": "21e91e1c60e6c07490faaae30f8154fd",
"bucketName": "408d9135-6155-4a43-9d3c-424f124b9474",
"objectName": "a503959b-e11b-4af5-b8b1-6c6def35d677/exportly-41dd6786-fb02-42f-813c-a4b6fd4520a5/Test_Export-results-count.csv",
"size": "26"
}
]
},
"stats": {
"sizeInBytes": "46689",
"exportedArtifactCount": "7",
"totalArtifactCount": "7"
},
"name": "Test Export",
...
}
There are two approaches that can do the action you require:有两种方法可以执行您需要的操作:
The first:首先:
using OAuth 2.0 refresh and access keys however it requires the intervention of the user, acknowledging your app access.使用 OAuth 2.0 刷新和访问密钥,但是它需要用户的干预,确认您的应用程序访问。 You can find a nice playground supplied by Google and more info here: https://developers.google.com/oauthplayground/ .
您可以在此处找到 Google 提供的不错的游乐场以及更多信息: https : //developers.google.com/oauthplayground/ 。
https://www.googleapis.com/auth/devstorage.full_controll
under the Cloud Storage JSON API v1 section.https://www.googleapis.com/auth/devstorage.full_controll
: https://www.googleapis.com/auth/devstorage.full_controll
,位于Cloud Storage JSON API v1部分下。 The second:第二:
Programmatically download it using Google client libraries.使用 Google 客户端库以编程方式下载它。 This is the approach suggested by @darkfolcer however I believe that the documentation provided by Google is insufficient and thus does not really help.
这是@darkfolcer建议的方法,但我认为 Google 提供的文档是不够的,因此并没有真正的帮助。 If a python example will help, you can find one in the answer to the following question - How to download files from Google Vault export immediately after creating it with Python API?
如果 Python 示例会有所帮助,您可以在以下问题的答案中找到一个 - 如何在使用 Python API 创建文件后立即从 Google Vault 导出下载文件?
Once all the exports are created you'll need to wait for them to be completed.创建所有导出后,您需要等待它们完成。 You can use https://developers.google.com/vault/reference/rest/v1/matters.exports/list to check the status of every export in a matter.
您可以使用https://developers.google.com/vault/reference/rest/v1/matters.exports/list检查事务中每个导出的状态。 In the response refer to the “exports” array and check the value of “status” for each, any that say "COMPLETED" can be downloaded.
在响应中引用“exports”数组并检查每个“status”的值,任何说“COMPLETED”的都可以下载。
To download a completed export go to the “cloudStorageSink” object of each export and take the "bucketName" and "objectName" value of the first entry in the "files" Array.要下载完成的导出,请转到每个导出的“cloudStorageSink”对象,并获取“files”数组中第一个条目的“bucketName”和“objectName”值。 You'll need to use the Cloud Storage API and these two values to download the files.
您需要使用 Cloud Storage API 和这两个值来下载文件。 This page has code examples for all the popular languages and using the API https://cloud.google.com/storage/docs/downloading-objects#storage-download-object-cpp .
此页面包含所有流行语言和使用 API https://cloud.google.com/storage/docs/downloading-objects#storage-download-object-cpp 的代码示例。
Hope it helps.希望能帮助到你。
The issue you are seeing is because the API works with the principle of least privilege .您看到的问题是因为 API 使用了最低权限原则。
The implications for you is that, since your objective is to download the files from the export, you would get the permissions to download only the files, not the whole bucket (even if it contains only those files).对您的影响是,由于您的目标是从导出中下载文件,您将获得仅下载文件的权限,而不是整个存储桶(即使它只包含这些文件)。
This is why when you request information from the storage bucket, you get the 403 error (permission error).这就是为什么当您从存储桶请求信息时,您会收到 403 错误(权限错误)。 However, you do have permission to download the files inside the bucket.
但是,您确实有权下载存储桶中的文件。 In this way, what you should do is get each object directly , doing requests like this (using the information on the question):
这样,你应该做的是 直接获取每个对象,做这样的请求(使用问题上的信息):
GET https://storage.googleapis.com/storage/v1/b/408d9135-6155-4a43-9d3c-424f124b9474/o/a740999b-e11b-4af5-b8b1-6c6def35d677/exportly-41dd7886-fe02-432f-83c-a4b6fd4520a5/Test_Export-1.zip
So, in short, instead of getting the full bucket, get each individual file generated by the export.因此,简而言之,不是获取完整存储桶,而是获取导出生成的每个单独文件。
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.