更新資料集

將 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 查詢參數的預設值為 *,表示更新要求主體中指定的所有支援欄位。