更新数据集

如需更新数据集的相关信息,请向修补数据集端点发送 HTTP PATCH 请求,其中还包含数据集的 ID:

https://mapsplatformdatasets.googleapis.com/v1/projects/PROJECT_NUMBER_OR_ID/datasets/DATASET_ID

您可以更新数据集的 displayName 和/或 description 属性。

例如:

curl -X PATCH -d '{
    "displayName": "My Updated Dataset",
    "description": "This is an updated description"
  }' \
  -H 'X-Goog-User-Project: PROJECT_NUMBER_OR_ID' \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  "https://mapsplatformdatasets.googleapis.com/v1/projects/PROJECT_NUMBER_OR_ID/datasets/f57074a0-a8b6-403e-9df1-e8a9e4f9fc46"

该请求会返回更新后的数据集的相关信息:

{
  "name": "projects/PROJECT_NUMBER_OR_ID/datasets/f57074a0-a8b6-403e-9df1-e8a9e4f9fc46",
  "displayName": "My Updated Dataset",
  "description": "This is an updated description",
  "versionId": "5fb3b84e-1405-4ecd-8f81-9183631f1c07",
  "usage": [
    "USAGE_DATA_DRIVEN_STYLING"
  ],
  "gcsSource": {
    "inputUri": "gs://mybucket/my.csv",
    "fileFormat": "FILE_FORMAT_CSV"
  },
  "createTime": "2023-03-24T14:47:37.308977Z",
  "updateTime": "2023-03-28T15:17:17.919351Z",
  "versionCreateTime": "2023-03-24T14:48:05.053114Z",
  "status": {
    "state": "STATE_COMPLETED"
  }
}

指定字段掩码

默认情况下,更新会修改请求正文中指定的所有受支持字段,即 displayNamedescription。不过,您还可以在请求中添加 updateMask 查询参数,以明确指定要更新的请求正文中的字段。

使用 updateMask 指定要更新的字段的完全限定名称的逗号分隔列表。例如,如需仅更新 displayName 字段,请执行以下操作:

curl -X PATCH -d '{
    "displayName": "My Updated Dataset",
    "description": "This is an updated description"
  }' \
  -H 'X-Goog-User-Project: PROJECT_NUMBER_OR_ID' \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  "https://mapsplatformdatasets.googleapis.com/v1/projects/PROJECT_NUMBER_OR_ID/datasets/f57074a0-a8b6-403e-9df1-e8a9e4f9fc46?updateMask=displayName"

updateMask 查询参数的默认值为 *,表示更新请求正文中指定的所有受支持字段。