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 has one or
more media objects (for example, video resources). These media objects
(asset
resources) contain metadata and resource annotations. Use the
following commands to manage these media objects.
Create an asset resource
REST
To create an asset resource, send a POST request by using the
projects.locations.corpora.assets.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 aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: (Optional) A user-provided value for the asset ID. In this request, the
value is added to the request URL in the form:
- https://ENDPOINT/v1/[...]/corpora/CORPUS_ID/assets?asset_id=ASSET_ID
- 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/CORPUS_ID/assets
Request JSON body:
{ }
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/CORPUS_ID/assets"
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/CORPUS_ID/assets" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" }
Update an asset resource
Update asset is only available for streaming video asset.
REST
To update an asset resource, send a PATCH request by using the
projects.locations.corpora.assets.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 aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
?updateMask=fieldToUpdate
: One of the available fields you can apply anupdateMask
to. Available fields:- Time-to-live (TTL):
?updateMask=ttl
- Update all fields:
?updateMask=*
- Time-to-live (TTL):
HTTP method and URL:
PATCH https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID?updateMask=ttl
Request JSON body:
{ "ttl": { "seconds": "1" } }
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/assets/ASSET_ID?updateMask=ttl"
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/assets/ASSET_ID?updateMask=ttl" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" }
List assets in a warehouse
REST
To list assets in a corpus, send a GET request by using the projects.locations.corpora.assets.list method.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
HTTP method and URL:
GET https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "assets": [ { "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID1", "ttl": "86400s" }, { "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID2", "ttl": "86400s" } ] }
Get an asset
REST
To get details about an asset, send a GET request using the projects.locations.corpora.assets.get method.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
HTTP method and URL:
GET https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID", "ttl": "86400s" }
Delete media assets
The following sample deletes a warehouse asset, making any annotations related to it inaccessible and removed from search results.
REST & CMD LINE
The following code sample deletes assets in a warehouse using the
projects.locations.corpora.assets.delete
method.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
HTTP method and URL:
DELETE https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" | Select-Object -Expand Content
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID/operations/OPERATION_ID" }
Get the operation status
To get the status of the long-running operation, call the
projects.locations.operations.get
method.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - OPERATION_ID: The operation ID that is returned when you start a long-running
operation. For example:
- projects/123456/locations/us-central1/[...]/operations/OPERATION_ID
HTTP method and URL:
GET https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/warehouseoperations/OPERATION_ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/warehouseoperations/OPERATION_ID"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/warehouseoperations/OPERATION_ID" | Select-Object -Expand Content
GetAsset
or ListAssets
.
Asset media data management
The media content for asset can be ingested into Vision Warehouse through different APIs.
Streaming video asset
To manage media content for streaming video assets, see the instructions that follow.
Get a video clip asset using temporal partitions
After you have created a warehouse and stored video asset
resources in
the warehouse you can get specific video clips. You can send a
ClipAssetRequest
to get media data
over a time range you define.
When sending a ClipAssetRequest
you must define the following:
temporal_partition
-The date range for the desired clips.
The following example considers a warehouse containing an asset with security camera footage for early September 2021 which has not exceeded its time-to-live (TTL).
To get a clip of the period ranging from 9/1/2021 2:51:59 GMT to 9/1/2021 2:52:30 GMT you first need to convert the start and end time to google.protobuf.Timestamp, which is expressed in duration since Unix epoch. After you have converted start and finish times, you can send a request similar to the following:
REST
To get details about a video clip, send a GET request by using the projects.locations.corpora.assets.clip method.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
- START_TIME: Start time of the partition, expressed in duration since Unix
epoch (for example,
1630464719
). - END_TIME: End time of the partition, expressed in duration since Unix
epoch (for example,
1630464750
).
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID:clip
Request JSON body:
{ "temporal_partition": { "start_time": { "seconds": START_TIME }, "end_time": { "seconds": END_TIME } } }
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/CORPUS_ID/assets/ASSET_ID:clip"
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/CORPUS_ID/assets/ASSET_ID:clip" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "time_indexed_uris" : { "temporal_partition" : { "start_time" : { "seconds": 1630464719 }, "end_time" : { "seconds": 1630464729 } }, "uri": "[...]" } }
A time_indexed_uris
includes a URI with a link to the clip retrieved and
a temporal_partition
detailing the start time and end time of the clip.
You can access
the link provided in the uri
field for up to 12 hours.
The clip returned will only display a short clip of the first content
available after start_time
, but before end_time
. This content may
extend beyond the temporal bounds in the request. For example, in the sample
request the clip returned only covers a 10 second clip that occurs after
1630464719
, even though there may still be more content that occurs after
1630464729
, and before the end_time
(1630464750
).
The clip returned can not be the exact length you requested. This behavior is expected and can be due to multiple reasons:
- The time range requested exceeded the data size limit of 100MB.
- The time range requested contains data which has exceeded its time-to-live (TTL).
- The time range requested has no data.
Get video clip assets using HTTP livestreaming
After you have created a warehouse and ingested video data (warehouse assets
)
in the warehouse, you can request a URI to an
HTTP Live Streaming (HLS) video stream manifest for a
series of specific segments of time. You can send a GenerateHlsUriRequest
to get media data over a series of time ranges you define.
When you send a GenerateHlsUriRequest
you must define the following:
temporal_partitions
- A collection of date ranges for the desired content you want to stream. The total duration should be less than 24h.
The following example uses a warehouse asset with security camera footage for September 2021 which has not exceeded its time-to-live (TTL). The sample request body specifies two video time periods:
- 9/1/2021 2:51:59 GMT to 9/1/2021 2:52:30 GMT
- 9/1/2021 4:59:00 GMT to 9/1/2021 5:05:30 GMT
You first need to convert the start and end times to a google.protobuf.Timestamp format, which is expressed in duration since Unix epoch. After you have converted these times to Unix times, you can send a request similar to the following:
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
- START_TIME: Start time of the partition, expressed in duration since Unix
epoch (for example,
1630464719
). - END_TIME: End time of the partition, expressed in duration since Unix
epoch (for example,
1630464750
).
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID:generateHlsUri
Request JSON body:
{ "temporal_partitions": { "start_time": { "seconds": 1630464719 }, "end_time": { "seconds": 1630464750 } }, "temporal_partitions": { "start_time": { "seconds": 1630472340 }, "end_time": { "seconds": 1630472730 } } }
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/CORPUS_ID/assets/ASSET_ID:generateHlsUri"
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/CORPUS_ID/assets/ASSET_ID:generateHlsUri" | Select-Object -Expand Content
The uri
in the response has a link to download the HLS manifest corresponding to
the requested times and each temporal_partitions
details the start and end time of
the clips included in the stream. The link provided in the uri
field can be accessed
for up to 12 hours.
A response may include multiple temporal_partitions
objects. Each
temporal_partitions
object represents an individual clip within the requested time
range. Clips are broken up if the source media does not contain data for a time within the
requested range, or if the request includes non-consecutive date ranges. In this example multiple
temporal_partitions
are returned because the request asked for data at two different
times on 9/1/2021.
The stream returned may not have the exact length you requested. This is expected and can be due to the following reasons:
- The time range requested contains data which has exceeded its time-to-live
- The time range requested has no data
{ "uri": "[...]", "temporal_partitions": { "start_time": { "seconds": 1630464719 }, "end_time": { "seconds": 1630464750 } }, "temporal_partitions": { "start_time": { "seconds": 1630472340 }, "end_time": { "seconds": 1630472730 } } }
View livestream by HLS
You can access an HTTP livestream (HLS) of the content currently being ingested.
Send a GenerateHlsUriRequest
to get a URI to this HLS video stream manifest, which is updated as new content is ingested. The livestream has three minutes of previously shown content, stops when ingestion stops, and restarts for new content. When you send GenerateHlsUriRequest
, define live_view_enabled
. This is the option to exclusively show a livestream of the asset,
with up to three minutes of backlog data. Set it to true.
You can send a request similar to the following:
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID:generateHlsUri
Request JSON body:
{ "live_view_enabled": true }
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/CORPUS_ID/assets/ASSET_ID:generateHlsUri"
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/CORPUS_ID/assets/ASSET_ID:generateHlsUri" | Select-Object -Expand Content
The uri
in the response has a link to the HLS manifest corresponding to a list of
content that's constantly updated as new video data is ingested. The link provided in the
uri
field can be accessed for up to 12 hours.
{ "uri": "[...]" }
Image asset
You can use the UploadAsset API to upload the image to the asset for later processing.
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID:upload
Request JSON body:
{ "asset_source": { "asset_gcs_source": { "gcs_uri": "GCS_URI" } } }
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/CORPUS_ID/assets/ASSET_ID:upload"
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/CORPUS_ID/assets/ASSET_ID:upload" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID/operations/OPERATION_ID", }
You can use the ImportAssets API to import a batch of images and its annotations to the corpus.
The Cloud Storage file for the ImportAsset request needs to be in JSONL format. In the file, each line corresponds to one asset and will be converted into InputImageAsset
proto. For example,
{"gcsUri":"gs://test/test1.png","assetId":"asset1","annotations":[{"key":"title","value":{"strValue":"cat"}}]}
{"gcsUri":"gs://test/test2.png","assetId":"asset2","annotations":[{"key":"title","value":{"strValue":"dog"}}]}
{"gcsUri":"gs://test/test3.png","assetId":"asset3","annotations":[{"key":"title","value":{"strValue":"rabbit"}}]}
Only one ImportAsset operation can happen on a corpus at a given time. Only five ImportAsset operations can happen within the same project at the same time.
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets:import
Request JSON body:
{ "parent": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID, "assets_gcs_uri": GCS_URI }
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/CORPUS_ID/assets:import"
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/CORPUS_ID/assets:import" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/operations/OPERATION_ID", }
After the asset is uploaded with an image or imported with image and annotations, you can analyze the whole corpus so that you can search all the image content later.
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID:analyze
Request JSON body:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID }
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/CORPUS_ID:analyze"
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/CORPUS_ID:analyze" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/operations/OPERATION_ID", }
Batch video asset
You can use the UploadAsset API to upload the video to the asset for later processing. The UploadAsset API supports common video formats, including MP4, AVI, FLV, MKV, MOV, MXF, WMV, and the formats decodable by FFmpeg.
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID:upload
Request JSON body:
{ "asset_source": { "asset_gcs_source": { "gcs_uri": "GCS_URI" } } }
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/CORPUS_ID/assets/ASSET_ID:upload"
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/CORPUS_ID/assets/ASSET_ID:upload" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID/operations/OPERATION_ID", }
After the asset is uploaded with a video, you can retrieve the URI by calling the GenerateRetrievalUrl API. If the uploaded video is in a separate project, you need to grant permission to the Vertex AI Vision serviceaccount. (go to IAM, check the box to show Include Google-provided role grants, search for "Cloud Vision AI Service Agent") to access it.
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID:generateHlsUri
Request JSON body:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID }
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/CORPUS_ID/assets/ASSET_ID:generateHlsUri"
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/CORPUS_ID/assets/ASSET_ID:generateHlsUri" | Select-Object -Expand Content
The uri
in the response has a link to the HLS manifest corresponding to a list of
content that's constantly updated as new video data is ingested. The link provided in the
uri
field can be accessed for up to 12 hours.
{ "uri": "[...]" }
After the asset is uploaded with a video, you can analyze the asset so that you can search the video content later.
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID:analyze
Request JSON body:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" }
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/CORPUS_ID/assets/ASSET_ID:analyze"
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/CORPUS_ID/assets/ASSET_ID:analyze" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID/operations/OPERATION_ID" }
Asset collection management
A collection is a container of references (CollectionItems) to original resources. You can add assets to a collection and can search within a collection.
Create a collection resource
REST
To create an asset resource, send a POST request by using the
projects.locations.corpora.collections.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 aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- COLLECTION_ID: The ID of your target collection.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections
Request JSON body:
{ "collection": { "display_name": "DISPLAY_NAME", "description": "COLLECTION_DESCRIPTION" } }
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/CORPUS_ID/collections"
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/CORPUS_ID/collections" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.visionai.v1.CreateCollectionMetadata" }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.visionai.v1.Collection", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID", "displayName": "DISPLAY_NAME", "description": "COLLECTION_DESCRIPTION" } }
Update a collection resource
REST
To update an asset resource, send a PATCH request by using the
projects.locations.corpora.collections.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 aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- COLLECTION_ID: The ID of your target collection.
?updateMask=fieldToUpdate
: One of the available fields you can apply anupdateMask
to. Available fields:- Display name:
?updateMask=display_name
- Description:
?updateMask=description
- Update all fields:
?updateMask=*
- Display name:
- UPDATED_FIELD_VALUE: A new value for the specified field. In this example, a new user-provided display name for the collection resource.
HTTP method and URL:
PATCH https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID?update_mask=display_name
Request JSON body:
{ "displayName": "UPDATED_FIELD_VALUE", "description": "Original description" }
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/collections/COLLECTION_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/collections/COLLECTION_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/collections/COLLECTION_ID", "displayName": "UPDATED_FIELD_VALUE", "description": "Original description" }
List collections in a warehouse
REST
To list collections in a corpus, send a GET request by using the
projects.locations.corpora.collections.list
method.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - COLLECTION_ID: The ID of your target collection.
HTTP method and URL:
GET https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "corpora": [ { "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID1", "displayName": "COLLECTION_DISPLAYNAME1", "description": "COLLECTION_DESCRIPTION1" }, { "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID2", "displayName": "COLLECTION_DISPLAYNAME2", "description": "COLLECTION_DESCRIPTION2" }, ], "nextPageToken": "ChM3MDk3NTk3Nzc2OTk3NDA3OTkzEAo" }
Get a collection
REST
To get details about a collection, send a GET request using the
projects.locations.corpora.collections.get
method.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- COLLECTION_ID: The ID of your target collection.
HTTP method and URL:
GET https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID", "displayName": "CCOLLECTION_DISPLAYNAME", "description": "CCOLLECTION__DESCRIPTION" }
Delete a collection
Deletes the collection using the following code sample. To delete the collection, all of its items must first be removed.
REST & CMD LINE
The following code sample deletes a collection
resource using the
projects.locations.corpora.collections.delete
method.
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- COLLECTION_ID: The ID of your target collection.
HTTP method and URL:
DELETE https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID" | Select-Object -Expand Content
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID/operations/OPERATION_ID" }
Add an item to a collection
You can add an asset item to the collection.
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- ASSET_ID: The ID of your target asset.
- COLLECTION_ID: The ID of your target collection.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID:addCollectionItem
Request JSON body:
{ "item": { "collection": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID, "type": "ASSET", "item_resource": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" } }
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/CORPUS_ID/collections/COLLECTION_ID:addCollectionItem"
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/CORPUS_ID/collections/COLLECTION_ID:addCollectionItem" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "item": { "collection": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID, "type": "ASSET", "item_resource": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" } }
Remove an item from a collection
You can remove an asset item from the collection.
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- COLLECTION_ID: The ID of your target collection.
- ASSET_ID: The ID of your target asset.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID:removeCollectionItem
Request JSON body:
{ "item": { "collection": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID, "type": "ASSET", "item_resource": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" } }
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/CORPUS_ID/collections/COLLECTION_ID:removeCollectionItem"
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/CORPUS_ID/collections/COLLECTION_ID:removeCollectionItem" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "item": { "collection": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID, "type": "ASSET", "item_resource": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" } }
View all items in a collection
You can view all items in a collection.
REST & CMD LINE
Before using any of the request data, make the following replacements:
- REGIONALIZED_ENDPOINT: Endpoint might include a prefix matching the
LOCATION_ID
such aseurope-west4-
. See more about regionalized endpoints. - PROJECT_NUMBER: Your Google Cloud project number.
- LOCATION_ID: The region where you are using
Vertex AI Vision. For example:
us-central1
,europe-west4
. See available regions. - CORPUS_ID: The ID of your target corpus.
- COLLECTION_ID: The ID of your target collection.
- ASSET_ID: The ID of your target asset.
HTTP method and URL:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID:viewCollectionItems
Request JSON body:
{ "collection": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID, "page_size": "50" }
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/CORPUS_ID/collections/COLLECTION_ID:viewCollectionItems"
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/CORPUS_ID/collections/COLLECTION_ID:viewCollectionItems" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "next_page_token": "jfyq45", "items": { "collection": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID, "type": "ASSET", "item_resource": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" }, "items": { "collection": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/collections/COLLECTION_ID, "type": "ASSET", "item_resource": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID" } }