更新数据集

通过将 HTTP PATCH 请求发送到 补丁数据集端点, 还包含数据集的 ID:

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

您可以更新 displayNamedescription 属性,也可以同时更新 数据集的名称。

例如:

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 查询参数的默认值为 *,意思是 更新请求正文中指定的所有受支持字段。