Manage warehouses (corpora)

The Vision Warehouse API allows you to manage Vision Warehouse resources using the command line.

A connected warehouse (corpus) in a data-ingesting deployed app is a resource in your Google Cloud project. Use the following commands to manage these resources.

Create a corpus resource

Streaming video corpus

The search_capability_setting field is not supported. The default_ttl field is required and it needs to be less than 10 years.

REST

To create a corpora resource, send a POST request by using the projects.locations.corpora.create method.

Before using any of the request data, make the following replacements:

  • REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the LOCATION_ID such as europe-west4-. See more about regionalized endpoints.
  • PROJECT_NUMBER: Your Google Cloud project number.
  • LOCATION_ID: The region where you are using Agent Platform Vision. For example: us-central1, europe-west4. See available regions.
  • DISPLAY_NAME: Display name for the warehouse.
  • WAREHOUSE_DESCRIPTION: The description of the warehouse (corpus).
  • TIME_TO_LIVE: The amount of time to live (TTL) for all assets under a corpus, or the TTL of a specific asset. For example, for a corpus with assets with a TTL of 100 days, provide the value 8640000 (seconds).

HTTP method and URL:

POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora

Request JSON body:

{
  "display_name": "DISPLAY_NAME",
  "description": "WAREHOUSE_DESCRIPTION",
  "type": "STREAM_VIDEO",
  "default_ttl": {
    "seconds": TIME_TO_LIVE
  }
}

To send your request, choose one of these options:

curl

Save the request body in a file named request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora"

PowerShell

Save the request body in a file named request.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/warehouseoperations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.visionai.v1.CreateCorpusMetadata"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.visionai.v1.Corpus",
    "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID",
    "displayName": "DISPLAY_NAME",
    "description": "WAREHOUSE_DESCRIPTION",
    "type": "STREAM_VIDEO",
    "defaultTtl": "TIME_TO_LIVE"
  }
}

Image corpus

The default_ttl field is not supported.

REST

To create a corpora resource, send a POST request by using the projects.locations.corpora.create method.

Before using any of the request data, make the following replacements:

  • REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the LOCATION_ID such as europe-west4-. See more about regionalized endpoints.
  • PROJECT_NUMBER: Your Google Cloud project number.
  • LOCATION_ID: The region where you are using Agent Platform Vision. For example: us-central1, europe-west4. See available regions.
  • DISPLAY_NAME: Display name for the warehouse.
  • WAREHOUSE_DESCRIPTION: The description of the warehouse (corpus).

HTTP method and URL:

POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora

Request JSON body:

{
  "display_name": "DISPLAY_NAME",
  "description": "WAREHOUSE_DESCRIPTION",
  "type": "IMAGE",
  "search_capability_setting": {
    "search_capabilities": {
      "type": "EMBEDDING_SEARCH"
    }
  }
}

To send your request, choose one of these options:

curl

Save the request body in a file named request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora"

PowerShell

Save the request body in a file named request.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/warehouseoperations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.visionai.v1.CreateCorpusMetadata"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.visionai.v1.Corpus",
    "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID",
    "displayName": "DISPLAY_NAME",
    "description": "WAREHOUSE_DESCRIPTION",
    "type": "IMAGE",
    "search_capability_setting": {
      "search_capabilities": {
        "type": "EMBEDDING_SEARCH"
      }
    }
  }
}

Batch video corpus

The default_ttl field is not supported.

REST

To create a corpora resource, send a POST request by using the projects.locations.corpora.create method.

Before using any of the request data, make the following replacements:

  • REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the LOCATION_ID such as europe-west4-. See more about regionalized endpoints.
  • PROJECT_NUMBER: Your Google Cloud project number.
  • LOCATION_ID: The region where you are using Agent Platform Vision. For example: us-central1, europe-west4. See available regions.
  • DISPLAY_NAME: Display name for the warehouse.
  • WAREHOUSE_DESCRIPTION: The description of the warehouse (corpus).

HTTP method and URL:

POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora

Request JSON body:

{
  "display_name": "DISPLAY_NAME",
  "description": "WAREHOUSE_DESCRIPTION",
  "type": "VIDEO_ON_DEMAND",
  "search_capability_setting": {
    "search_capabilities": {
      "type": "EMBEDDING_SEARCH"
    }
  }
}

To send your request, choose one of these options:

curl

Save the request body in a file named request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora"

PowerShell

Save the request body in a file named request.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/warehouseoperations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.visionai.v1.CreateCorpusMetadata"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.visionai.v1.Corpus",
    "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID",
    "displayName": "DISPLAY_NAME",
    "description": "WAREHOUSE_DESCRIPTION",
    "type": "VIDEO_ON_DEMAND",
    "search_capability_setting": {
      "search_capabilities": {
        "type": "EMBEDDING_SEARCH"
      }
    }
  }
}

Update a corpus resource

Streaming video corpus

The search_capability_setting field is not supported.

REST

To update a corpora resource, send a PATCH request by using the projects.locations.corpora.patch method.

Before using any of the request data, make the following replacements:

  • REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the LOCATION_ID such as europe-west4-. See more about regionalized endpoints.
  • PROJECT_NUMBER: Your Google Cloud project number.
  • LOCATION_ID: The region where you are using Agent Platform Vision. For example: us-central1, europe-west4. See available regions.
  • CORPUS_ID: The ID of your target corpus.
  • ?updateMask=fieldToUpdate: One of the available fields you can apply an updateMask to. Specify the corresponding new field value in the request body. This new value replaces the existing field value. Available fields:
    • Display name: ?updateMask=display_name
    • Description: ?updateMask=description
    • Default time-to-live (TTL): ?updateMask=default_ttl
    • Update all fields: ?updateMask=*
  • UPDATED_FIELD_VALUE: A new value for the specified field. In this example, a new user-provided display name for the warehouse resource.

HTTP method and URL:

PATCH https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID?update_mask=display_name

Request JSON body:

{
  "displayName": "UPDATED_FIELD_VALUE",
  "description": "Original description",
  "defaultTtl": {
    "seconds": "7800"
  }
}

To send your request, choose one of these options:

curl

Save the request body in a file named request.json, and execute the following command:

curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID?update_mask=display_name"

PowerShell

Save the request body in a file named request.json, and execute the following command:

$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://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID?update_mask=display_name" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_ID/locations/LOCATION_ID/corpora/CORPORA_ID",
  "displayName": "UPDATED_FIELD_VALUE",
  "description": "Original description",
  "defaultTtl": "7800s"
}

Image corpus

The default_ttl field is not supported.

REST

To update a corpora resource, send a PATCH request by using the projects.locations.corpora.patch method.

Before using any of the request data, make the following replacements:

  • REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the LOCATION_ID such as europe-west4-. See more about regionalized endpoints.
  • PROJECT_NUMBER: Your Google Cloud project number.
  • LOCATION_ID: The region where you are using Agent Platform Vision. For example: us-central1, europe-west4. See available regions.
  • CORPUS_ID: The ID of your target corpus.