A connected Vision Warehouse ( corpus
) in a data-ingesting deployed
app has one or more media object resources (for example, video resources).
These media
objects ( asset
resources) contain metadata and resource annotations. Use the
following commands to create and update these media objects.
Create a streaming video warehouse asset
After you have created a warehouse
( corpus
resource),
you can add one or more video asset
resources to the warehouse.
REST & CMD LINE
The following code creates a new asset under the given warehouse ( corpus
)
with the option to specify the asset's ID and a TTL.
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:
{ "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/ 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 ", "ttl": " TIME_TO_LIVE s" }
Vertex AI Vision SDK
To send a request to read a model output stream you must install the Vertex AI Vision SDK .
When using the vaictl
command line tool to create an asset you are not
able to specify an asset ID or TTL.
Make the following variable substitutions:
- PROJECT_NUMBER : Your Google Cloud project number.
- LOCATION_ID
: Your location ID. For example,
us-central1
. Supported regions . More information . - CORPUS_ID
: The ID of the target warehouse (
corpus
resource).
vaictl --project-id= PROJECT_NUMBER
\
--location-id= LOCATION_ID
\
--service-endpoint=warehouse-visionai.googleapis.com \
create asset CORPUS_ID
After an asset is created you can ingest video data
directly
into the warehouse for that asset by using the vaictl
command line tool.
Update a streaming video warehouse asset
Use the following code sample to update an asset's time-to-live (TTL). You can only update the TTL field.
Use the updateMask
query parameter in the following code sample to update an
asset's TTL. You can use a query parameter to update the TTL field only. The updateMask
works as follows:
- If specified, only the fields in the
updateMask
are updated. - If update mask value is
*
, the request updates all the fields. -
If the update mask is not specified, only the fields in the request URL with a value provided in the request body are updated.
REST & CMD LINE
The following code samples modify an asset's TTL using the projects.locations.corpora.assets.patch
method.
Change a TTL value
This sample uses ?updateMask=ttl
in the request URL, and includes a
new ttl.seconds
value in the request body to update the asset.
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 " }
Remove a TTL value
This sample uses ?updateMask=ttl
in the request URL, and includes an
empty request body to clear the asset's TTL value.
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:
{}
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 " }