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_IDsuch aseurope-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.
- 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_IDsuch aseurope-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.
- ASSET_ID: The ID of your target asset.
?updateMask=fieldToUpdate: One of the available fields you can apply anupdateMaskto. 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_IDsuch aseurope-west4-. See more about regionalized endpoints.