Filtering when listing

You can use filtering to return more specific results when listing resources, evaluations, or operations.

Operations

You can filter listed operations using the following parameters:

Filters

  • operation_id - returns all operations with an ID equal to the provided value. You can also specify operations not equal (!=) to a certain value.
  • done - returns all operations with a status of "done": true. You can also specify operations that are still ongoing (not "done").

    Queries:

    • ?filter="done=true"
    • ?filter="done!=true"
  • worksOn - returns all operations that work on a resource (dataset or model). You can also specify operations not equal (!=) to a certain value.

    Queries:

    • dataset - ?filter="worksOn=projects/project-id/locations/us-central1/datasets/dataset-id"
    • model - ?filter="worksOn=projects/project-id/locations/us-central1/models/model-id"

Additional query parameters

  • pageSize - Limits the results returned to a set number of lines. If not specified, the server will choose a default size.
  • pageToken - A token to retrieve next page of results. An initial query with a set pageSize and results greater than will fit on that page size also returns a nextPageToken. This token can then be passed to pageToken to get subsequent results.

The following command line code sample shows how to filter listed operations by operations that are completed (have a status of "done": true).

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

  • project-id: your Google Cloud Platform project ID.

HTTP method and URL:

GET https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/operations?filter="done=true"

To send your request, choose one of these options:

curl

Execute the following command:

curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/operations?filter="done=true"

PowerShell

Execute the following command:

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

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/operations?filter="done=true"" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format.

The following response is from a project with multiple AutoML operations, filtered by operations that have completed (?filter="done=true").

Additional query parameters

To query with other parameters (pageSize, pageToken) append the parameter to the URL:

https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/model/model-id/modelEvaluations?pageSize=INT

You can also concatenate parameters with an ampersand (&):

https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/model/model-id/modelEvaluations?filter="done=true&pageSize=INT&pageToken=next-page-token"

Datasets

You can filter listed datasets using the following parameters:

Filters

  • dataset_metadata - returns all datasets with the target metadata type.

Additional query parameters

  • pageSize - Limits the results returned to a set number of lines. If not specified, the server will choose a default size.
  • pageToken - A token to retrieve next page of results. An initial query with a set pageSize and results greater than will fit on that page size also returns a nextPageToken. This token can then be passed to pageToken to get subsequent results.

The following command line code sample shows how to filter listed datasets by specifying the dataset_metadata.

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

  • project-id: your Google Cloud Platform project ID.
  • dataset-metadata-value: the type of dataset_metadata you are filtering. These values depend on the AutoML problem type.

HTTP method and URL:

GET https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/datasets?filter="dataset-metadata-value"

To send your request, choose one of these options:

curl

Execute the following command:

curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/datasets?filter="dataset-metadata-value"

PowerShell

Execute the following command:

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

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/datasets?filter="dataset-metadata-value"" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format.

The following response is from a project with multiple AutoML dataset types, filtered for AutoML Translation datasets (?filter="translationDatasetMetadata:*").

Response:

Additional query parameters

To query with other parameters (pageSize, pageToken) append the parameter to the URL:

https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/datasets?pageSize=INT

You can also concatenate parameters with an ampersand (&):

https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/datasets?filter="dataset-metadata-value&pageSize=INT&pageToken=next-page-token"

Models

You can filter listed models using the following parameters:

Filters

  • model_metadata - returns all models with the target metadata type.
  • datasetId - returns all models created from a specific dataset.

Additional query parameters

  • pageSize - Limits the results returned to a set number of lines. If not specified, the server will choose a default size.
  • pageToken - A token to retrieve next page of results. An initial query with a set pageSize and results greater than will fit on that page size also returns a nextPageToken. This token can then be passed to pageToken to get subsequent results.

The following command line code sample shows how to filter listed models by specifying the model_metadata.

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

  • project-id: your Google Cloud Platform project ID.
  • model-metadata-value: the type of model_metadata you are filtering. These values depend on the AutoML problem type.

HTTP method and URL:

GET https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models?filter="model-metadata-value"

To send your request, choose one of these options:

curl

Execute the following command:

curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models?filter="model-metadata-value"

PowerShell

Execute the following command:

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

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models?filter="model-metadata-value"" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format.

The following response is from a project with multiple AutoML model types, filtered for AutoML Natural Language models (?filter="textClassificationModelMetadata:*").

Additional query parameters

To query with other parameters (pageSize, pageToken) append the parameter to the URL:

https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models?pageSize=INT

You can also concatenate parameters with an ampersand (&):

https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models?filter="model-metadata-value&pageSize=INT&pageToken=next-page-token"

modelEvaulations

You can filter listed model evaluations using the following parameters:

Filters

  • annotationSpecId - returns all model evaluations with an ID equal to the provided value. You can also specify model evaulations not equal (!=) to a certain value.

Additional query parameters

  • pageSize - Limits the results returned to a set number of lines. If not specified, the server will choose a default size.
  • pageToken - A token to retrieve next page of results. An initial query with a set pageSize and results greater than will fit on that page size also returns a nextPageToken. This token can then be passed to pageToken to get subsequent results.

The following command line code sample shows how to filter listed model evaluations by specifying the annotationSpecId.

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

  • project-id: your Google Cloud Platform project ID.
  • model-id: the ID of the model you want evaluations for.
  • annotation-spec-id: The ID of the annotation spec that the model evaluation applies to. The The ID is empty for the overall model evaluation.

HTTP method and URL:

GET https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models/model-id/modelEvaluations?filter="annotationSpecId=annotation-spec-id"

To send your request, choose one of these options:

curl

Execute the following command:

curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models/model-id/modelEvaluations?filter="annotationSpecId=annotation-spec-id"

PowerShell

Execute the following command:

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

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models/model-id/modelEvaluations?filter="annotationSpecId=annotation-spec-id"" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format.

The following response is from a project with multiple AutoML model types, filtered for model evaluations from a single model (?filter="annotationSpecId=1231173747155664896").

Additional query parameters

To query with other parameters (pageSize, pageToken) append the parameter to the URL:

https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/model/model-id/modelEvaluations?pageSize=INT

You can also concatenate parameters with an ampersand (&):

https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/model/model-id/modelEvaluations?filter="annotationSpecId=annotation-spec-id&pageSize=INT&pageToken=next-page-token"