Manage data schema

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

List data schema in a corpus

List all DataSchema under a specific corpus. The response contains all DataSchema resources, each with a DataSchema resource name that can be used to get a specific DataSchema.

REST

To list data schema, send a GET request by using the projects.locations.corpora.dataSchemas.list method.

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

  • PROJECT_NUMBER: Your Google Cloud project number.
  • LOCATION_ID: The region where you are using Vertex AI Vision. For example: us-central1, europe-west2, or asia-south1 (not an exhaustive list).
  • 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/dataSchemas

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/dataSchemas"

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/dataSchemas" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
  "dataSchemas": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/dataSchemas/KEY_STRING1",
      "key": "KEY_STRING1",
      "schemaDetails": {
        "type": "STRING",
        "granularity": "GRANULARITY_ASSET_LEVEL",
        "searchStrategy": {
          "searchStrategyType": "EXACT_SEARCH"
        }
      }
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/dataSchemas/KEY_STRING2",
      "key": "KEY_STRING2",
      "schemaDetails": {
        "type": "PROTO_ANY",
        "granularity": "GRANULARITY_PARTITION_LEVEL",
        "protoAnyConfig": {
          "typeUri": "type.googleapis.com/google.cloud.visionai.v1.VideoActionRecognitionPredictionResult"
        },
        "searchStrategy": {
          "searchStrategyType": "SMART_SEARCH"
        }
      }
    }
  ]
}

Get a data schema

Get the DataSchema of a specific DataSchema resource name.

REST

To get details about a specific data schema, send a GET request by using the projects.locations.corpora.dataSchemas.get method.

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

  • PROJECT_NUMBER: Your Google Cloud project number.
  • LOCATION_ID: The region where you are using Vertex AI Vision. For example: us-central1, europe-west2, or asia-south1 (not an exhaustive list).
  • CORPUS_ID: The ID of your target corpus.
  • DATASCHEMA_ID: The ID of your target data schema.

HTTP method and URL:

GET https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/dataSchemas/DATASCHEMA_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/dataSchemas/DATASCHEMA_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/dataSchemas/DATASCHEMA_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/dataSchemas/KEY_STRING",
  "key": "KEY_STRING",
  "schemaDetails": {
    "type": "STRING",
    "granularity": "GRANULARITY_ASSET_LEVEL",
    "searchStrategy": {
      "searchStrategyType": "EXACT_SEARCH"
    }
  }
}

Delete a data schema

REST & CMD LINE

The following code sample deletes a warehouse dataSchema using the projects.locations.corpora.dataSchemas.delete method.

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

  • PROJECT_NUMBER: Your Google Cloud project number.
  • LOCATION_ID: The region where you are using Vertex AI Vision. For example: us-central1, europe-west2, or asia-south1 (not an exhaustive list).
  • CORPUS_ID: The ID of your target corpus.
  • DATASCHEMA_ID: The ID of your target data schema.

HTTP method and URL:

DELETE https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/dataSchemas/DATASCHEMA_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/dataSchemas/DATASCHEMA_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/dataSchemas/DATASCHEMA_ID" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{}