您可以使用 Vertex AI 特徵儲存庫,為下列類型的資源新增或更新標籤:
- 特徵群組 (
FeatureGroup
) - 功能 (
Feature
) - 網路商店執行個體 (
FeatureOnlineStore
) - 特徵檢視區塊執行個體 (
FeatureView
)
您可以在建立資源時新增標籤,也可以為現有資源新增標籤。請注意,您可以選擇是否要為這些資源新增標籤。
事前準備
向 Vertex AI 進行驗證 (如果尚未完成)。
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
詳情請參閱 Google Cloud 驗證說明文件中的「Authenticate for using REST」。
更新特徵群組的標籤
使用下列範例更新現有特徵群組的標籤。
REST
如要更新現有 FeatureGroup
資源的標籤,請使用 featureGroups.patch 方法傳送 PATCH
要求。
使用任何要求資料之前,請先替換以下項目:
- LOCATION_ID:特徵群組所在的區域,例如
us-central1
。 - PROJECT_ID:您的專案 ID。
- FEATUREGROUP_NAME:要更新的特徵群組名稱。
- LABELS_JSON:要以 JSON 格式的鍵/值組合附加至特徵群組的標籤。
例如:
{"label1_key": "label1_value", "label2_key": "label2_value", ...}
HTTP 方法和網址:
PATCH https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups?feature_group_id=FEATUREGROUP_NAME
JSON 要求主體:
{ "labels": LABELS_JSON }
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups?feature_group_id=FEATUREGROUP_NAME"
PowerShell
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups?feature_group_id=FEATUREGROUP_NAME" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeatureGroupOperationMetadata", "genericMetadata": { "createTime": "2023-09-18T03:00:13.060636Z", "updateTime": "2023-09-18T03:00:13.060636Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.FeatureGroup", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME" } }
更新功能的標籤
使用下列範例更新現有功能的標籤。
REST
如要更新現有 Feature
資源的標籤,請使用 features.patch 方法傳送 PATCH
要求。
使用任何要求資料之前,請先替換以下項目:
- LOCATION_ID:含有特徵的特徵群組所在區域,例如
us-central1
。 - PROJECT_ID:您的專案 ID。
- FEATUREGROUP_NAME:包含特徵的特徵群組名稱。
- FEATURE_NAME:要更新的功能名稱。
- LABELS_JSON:要附加至特徵的標籤,格式為 JSON 鍵/值組合。
例如:
{"label1_key": "label1_value", "label2_key": "label2_value", ...}
HTTP 方法和網址:
PATCH https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features?feature_id=FEATURE_NAME
JSON 要求主體:
{ "labels": LABELS_JSON }
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features?feature_id=FEATURE_NAME"
PowerShell
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features?feature_id=FEATURE_NAME" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features/FEATURE_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeatureOperationMetadata", "genericMetadata": { "createTime": "2023-09-18T02:36:22.870679Z", "updateTime": "2023-09-18T02:36:22.870679Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.Feature", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features/FEATURE_NAME" } }
更新網路商店的標籤
使用下列範例更新現有線上商店例項的標籤。
REST
如要更新現有 FeatureOnlineStore
資源的標籤,請使用 featureOnlineStores.patch 方法傳送 PATCH
要求。
使用任何要求資料之前,請先替換以下項目:
- REGION_ID:線上商店所在的區域,例如
us-central1
。 - PROJECT_ID:您的專案 ID。
- FEATUREONLINESTORE_NAME:要更新的網路商店名稱。
- LABELS_JSON:要以 JSON 格式的鍵/值組合附加至網路商店的標籤。
例如:
{"label1_key": "label1_value", "label2_key": "label2_value", ...}
HTTP 方法和網址:
PATCH https://REGION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME
JSON 要求主體:
{ "labels": LABELS_JSON }
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://REGION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME"
PowerShell
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://REGION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureOnlineStoreOperationMetadata", "genericMetadata": { "createTime": "2023-09-18T17:49:23.847496Z", "updateTime": "2023-09-18T17:49:23.847496Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.FeatureView", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME" } }
更新特徵檢視表的標籤
使用下列範例更新現有特徵檢視區塊的標籤。
REST
如要更新現有 FeatureView
資源的標籤,請使用 featureViews.patch 方法傳送 PATCH
要求。
使用任何要求資料之前,請先替換以下項目:
- LOCATION_ID:線上商店所在的區域,例如
us-central1
。 - PROJECT_ID:您的專案 ID。
- FEATUREONLINESTORE_NAME:包含特徵檢視區塊的網路商店名稱。
- FEATUREVIEW_NAME:要更新的特徵檢視區塊名稱。
- LABELS_JSON:要以 JSON 格式的鍵/值組合附加至特徵檢視區塊的標籤。
例如:
{"label1_key": "label1_value", "label2_key": "label2_value", ...}
HTTP 方法和網址:
PATCH https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME
JSON 要求主體:
{ "labels": LABELS_JSON }
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME"
PowerShell
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeatureViewOperationMetadata", "genericMetadata": { "createTime": "2023-09-15T04:53:34.832192Z", "updateTime": "2023-09-15T04:53:34.832192Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.FeatureView", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME" } }
後續步驟
瞭解如何更新特徵群組。
瞭解如何更新功能。
瞭解如何更新網路商店執行個體。
瞭解如何更新特徵檢視區塊。