更新標籤

您可以使用 Vertex AI 特徵儲存庫,為下列類型的資源新增或更新標籤:

您可以在建立資源時新增標籤,也可以為現有資源新增標籤。請注意,為這些資源新增標籤是選用做法。

事前準備

Gemini Enterprise Agent Platform 驗證,除非您已完成驗證。

如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。

    安裝 Google Cloud CLI。

    若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI

詳情請參閱 Google Cloud 驗證說明文件中的「使用 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"
  }
}

後續步驟