Cloud Vision API v1 - Package cloud.google.com/go/vision/v2/apiv1 (v2.9.6)

Note: To get more information about this package, such as access to older versions, viewthis package on pkg.go.dev.

Package vision is an auto-generated package for theCloud Vision API.

Integrates Google Vision features, including image labeling, face, logo,and landmark detection, optical character recognition (OCR), and detectionof explicit content, into applications.

General documentation

For information that is relevant for all client libraries please referencehttps://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on thispage includes:

Example usage

To get started with this package, create a client.

// go get cloud.google.com/go/vision/v2/apiv1@latestctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()

The client will use your default application credentials. Clients should be reused instead of created as needed.The methods of Client are safe for concurrent use by multiple goroutines.The returned client must be Closed when it is done being used.

Using the Client

The following is an example of making an API call with the newly created client, mentioned above.

req:=&visionpb.AddProductToProductSetRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#AddProductToProductSetRequest.}err=c.AddProductToProductSet(ctx,req)iferr!=nil{// TODO: Handle error.}

Use of Context

The ctx passed to NewProductSearchClient is used for authentication requests andfor creating the underlying connection, but is not used for subsequent calls.Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

Functions

func DefaultAuthScopes

funcDefaultAuthScopes()[]string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

AsyncBatchAnnotateFilesOperation

typeAsyncBatchAnnotateFilesOperationstruct{// contains filtered or unexported fields}

AsyncBatchAnnotateFilesOperation manages a long-running operation from AsyncBatchAnnotateFiles.

func (*AsyncBatchAnnotateFilesOperation) Done

Done reports whether the long-running operation has completed.

func (*AsyncBatchAnnotateFilesOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*AsyncBatchAnnotateFilesOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*AsyncBatchAnnotateFilesOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*AsyncBatchAnnotateFilesOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

AsyncBatchAnnotateImagesOperation

typeAsyncBatchAnnotateImagesOperationstruct{// contains filtered or unexported fields}

AsyncBatchAnnotateImagesOperation manages a long-running operation from AsyncBatchAnnotateImages.

func (*AsyncBatchAnnotateImagesOperation) Done

Done reports whether the long-running operation has completed.

func (*AsyncBatchAnnotateImagesOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*AsyncBatchAnnotateImagesOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*AsyncBatchAnnotateImagesOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*AsyncBatchAnnotateImagesOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

ImageAnnotatorCallOptions

typeImageAnnotatorCallOptionsstruct{BatchAnnotateImages[]gax.CallOptionBatchAnnotateFiles[]gax.CallOptionAsyncBatchAnnotateImages[]gax.CallOptionAsyncBatchAnnotateFiles[]gax.CallOptionGetOperation[]gax.CallOption}

ImageAnnotatorCallOptions contains the retry settings for each method of ImageAnnotatorClient.

ImageAnnotatorClient

typeImageAnnotatorClientstruct{// The call options for this service.CallOptions*ImageAnnotatorCallOptions// LROClient is used internally to handle long-running operations.// It is exposed so that its CallOptions can be modified if required.// Users should not Close this client.LROClient*lroauto.OperationsClient// contains filtered or unexported fields}

ImageAnnotatorClient is a client for interacting with Cloud Vision API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Service that performs Google Cloud Vision API detection tasks over clientimages, such as face, landmark, logo, label, and text detection. TheImageAnnotator service returns detected entities from the images.

func NewImageAnnotatorClient

funcNewImageAnnotatorClient(ctxcontext.Context,opts...option.ClientOption)(*ImageAnnotatorClient,error)

NewImageAnnotatorClient creates a new image annotator client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.

Service that performs Google Cloud Vision API detection tasks over clientimages, such as face, landmark, logo, label, and text detection. TheImageAnnotator service returns detected entities from the images.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewImageAnnotatorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}

func NewImageAnnotatorRESTClient

funcNewImageAnnotatorRESTClient(ctxcontext.Context,opts...option.ClientOption)(*ImageAnnotatorClient,error)

NewImageAnnotatorRESTClient creates a new image annotator rest client.

Service that performs Google Cloud Vision API detection tasks over clientimages, such as face, landmark, logo, label, and text detection. TheImageAnnotator service returns detected entities from the images.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewImageAnnotatorRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}

func (*ImageAnnotatorClient) AsyncBatchAnnotateFiles

AsyncBatchAnnotateFiles run asynchronous image detection and annotation for a list of genericfiles, such as PDF files, which may contain multiple pages and multipleimages per page. Progress and results can be retrieved through thegoogle.longrunning.Operations interface.Operation.metadata contains OperationMetadata (metadata).Operation.response contains AsyncBatchAnnotateFilesResponse (results).

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewImageAnnotatorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.AsyncBatchAnnotateFilesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#AsyncBatchAnnotateFilesRequest.}op,err:=c.AsyncBatchAnnotateFiles(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ImageAnnotatorClient) AsyncBatchAnnotateFilesOperation

func(c*ImageAnnotatorClient)AsyncBatchAnnotateFilesOperation(namestring)*AsyncBatchAnnotateFilesOperation

AsyncBatchAnnotateFilesOperation returns a new AsyncBatchAnnotateFilesOperation from a given name.The name must be that of a previously created AsyncBatchAnnotateFilesOperation, possibly from a different process.

func (*ImageAnnotatorClient) AsyncBatchAnnotateImages

AsyncBatchAnnotateImages run asynchronous image detection and annotation for a list of images.

Progress and results can be retrieved through thegoogle.longrunning.Operations interface.Operation.metadata contains OperationMetadata (metadata).Operation.response contains AsyncBatchAnnotateImagesResponse (results).

This service will write image annotation outputs to json files in customerGCS bucket, each json file containing BatchAnnotateImagesResponse proto.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewImageAnnotatorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.AsyncBatchAnnotateImagesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#AsyncBatchAnnotateImagesRequest.}op,err:=c.AsyncBatchAnnotateImages(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ImageAnnotatorClient) AsyncBatchAnnotateImagesOperation

func(c*ImageAnnotatorClient)AsyncBatchAnnotateImagesOperation(namestring)*AsyncBatchAnnotateImagesOperation

AsyncBatchAnnotateImagesOperation returns a new AsyncBatchAnnotateImagesOperation from a given name.The name must be that of a previously created AsyncBatchAnnotateImagesOperation, possibly from a different process.

func (*ImageAnnotatorClient) BatchAnnotateFiles

BatchAnnotateFiles service that performs image detection and annotation for a batch of files.Now only “application/pdf”, “image/tiff” and “image/gif” are supported.

This service will extract at most 5 (customers can specify which 5 inAnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from eachfile provided and perform detection and annotation for each imageextracted.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewImageAnnotatorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.BatchAnnotateFilesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#BatchAnnotateFilesRequest.}resp,err:=c.BatchAnnotateFiles(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ImageAnnotatorClient) BatchAnnotateImages

BatchAnnotateImages run image detection and annotation for a batch of images.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewImageAnnotatorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.BatchAnnotateImagesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#BatchAnnotateImagesRequest.}resp,err:=c.BatchAnnotateImages(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ImageAnnotatorClient) Close

Close closes the connection to the API service. The user should invoke this whenthe client is no longer required.

func (*ImageAnnotatorClient) Connection (deprecated)

func(c*ImageAnnotatorClient)Connection()*grpc.ClientConn

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.

func (*ImageAnnotatorClient) GetOperation

GetOperation is a utility method from google.longrunning.Operations.

Example

packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"vision"cloud.google.com/go/vision/v2/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewImageAnnotatorClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.GetOperationRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.}resp,err:=c.GetOperation(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

ImportProductSetsOperation

typeImportProductSetsOperationstruct{// contains filtered or unexported fields}

ImportProductSetsOperation manages a long-running operation from ImportProductSets.

func (*ImportProductSetsOperation) Done

Done reports whether the long-running operation has completed.

func (*ImportProductSetsOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*ImportProductSetsOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*ImportProductSetsOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*ImportProductSetsOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

ProductIterator

typeProductIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*visionpb.Product,nextPageTokenstring,errerror)// contains filtered or unexported fields}

ProductIterator manages a stream of *visionpb.Product.

func (*ProductIterator) All

func(it*ProductIterator)All()iter.Seq2[*visionpb.Product,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*ProductIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*ProductIterator) PageInfo

func(it*ProductIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

ProductSearchCallOptions

typeProductSearchCallOptionsstruct{CreateProductSet[]gax.CallOptionListProductSets[]gax.CallOptionGetProductSet[]gax.CallOptionUpdateProductSet[]gax.CallOptionDeleteProductSet[]gax.CallOptionCreateProduct[]gax.CallOptionListProducts[]gax.CallOptionGetProduct[]gax.CallOptionUpdateProduct[]gax.CallOptionDeleteProduct[]gax.CallOptionCreateReferenceImage[]gax.CallOptionDeleteReferenceImage[]gax.CallOptionListReferenceImages[]gax.CallOptionGetReferenceImage[]gax.CallOptionAddProductToProductSet[]gax.CallOptionRemoveProductFromProductSet[]gax.CallOptionListProductsInProductSet[]gax.CallOptionImportProductSets[]gax.CallOptionPurgeProducts[]gax.CallOptionGetOperation[]gax.CallOption}

ProductSearchCallOptions contains the retry settings for each method of ProductSearchClient.

ProductSearchClient

typeProductSearchClientstruct{// The call options for this service.CallOptions*ProductSearchCallOptions// LROClient is used internally to handle long-running operations.// It is exposed so that its CallOptions can be modified if required.// Users should not Close this client.LROClient*lroauto.OperationsClient// contains filtered or unexported fields}

ProductSearchClient is a client for interacting with Cloud Vision API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Manages Products and ProductSets of reference images for use in productsearch. It uses the following resource model:

The API has a collection of ProductSetresources, named projects/*/locations/*/productSets/*, which acts as a wayto put different products into groups to limit identification.

In parallel,

The API has a collection of Productresources, namedprojects/*/locations/*/products/*Each Product has a collection ofReferenceImage resources, namedprojects/*/locations/*/products/*/referenceImages/*

func NewProductSearchClient

funcNewProductSearchClient(ctxcontext.Context,opts...option.ClientOption)(*ProductSearchClient,error)

NewProductSearchClient creates a new product search client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.

Manages Products and ProductSets of reference images for use in productsearch. It uses the following resource model:

The API has a collection of ProductSetresources, named projects/*/locations/*/productSets/*, which acts as a wayto put different products into groups to limit identification.

In parallel,

The API has a collection of Productresources, namedprojects/*/locations/*/products/*Each Product has a collection ofReferenceImage resources, namedprojects/*/locations/*/products/*/referenceImages/*

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}

func NewProductSearchRESTClient

funcNewProductSearchRESTClient(ctxcontext.Context,opts...option.ClientOption)(*ProductSearchClient,error)

NewProductSearchRESTClient creates a new product search rest client.

Manages Products and ProductSets of reference images for use in productsearch. It uses the following resource model:

The API has a collection of ProductSetresources, named projects/*/locations/*/productSets/*, which acts as a wayto put different products into groups to limit identification.

In parallel,

The API has a collection of Productresources, namedprojects/*/locations/*/products/*Each Product has a collection ofReferenceImage resources, namedprojects/*/locations/*/products/*/referenceImages/*

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}

func (*ProductSearchClient) AddProductToProductSet

AddProductToProductSet adds a Product to the specified ProductSet. If the Product is alreadypresent, no change is made.

One Product can be added to at most 100 ProductSets.

Possible errors:

Returns NOT_FOUND if the Product or the ProductSet doesn’t exist.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.AddProductToProductSetRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#AddProductToProductSetRequest.}err=c.AddProductToProductSet(ctx,req)iferr!=nil{// TODO: Handle error.}}

func (*ProductSearchClient) Close

Close closes the connection to the API service. The user should invoke this whenthe client is no longer required.

func (*ProductSearchClient) Connection (deprecated)

func(c*ProductSearchClient)Connection()*grpc.ClientConn

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.

func (*ProductSearchClient) CreateProduct

CreateProduct creates and returns a new product resource.

Possible errors:

Returns INVALID_ARGUMENT if display_name is missing or longer than 4096characters.Returns INVALID_ARGUMENT if description is longer than 4096 characters.Returns INVALID_ARGUMENT if product_category is missing or invalid.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.CreateProductRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#CreateProductRequest.}resp,err:=c.CreateProduct(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ProductSearchClient) CreateProductSet

CreateProductSet creates and returns a new ProductSet resource.

Possible errors:

Returns INVALID_ARGUMENT if display_name is missing, or is longer than4096 characters.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.CreateProductSetRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#CreateProductSetRequest.}resp,err:=c.CreateProductSet(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ProductSearchClient) CreateReferenceImage

CreateReferenceImage creates and returns a new ReferenceImage resource.

The bounding_poly field is optional. If bounding_poly is not specified,the system will try to detect regions of interest in the image that arecompatible with the product_category on the parent product. If it isspecified, detection is ALWAYS skipped. The system converts polygons intonon-rotated rectangles.

Note that the pipeline will resize the image if the image resolution is toolarge to process (above 50MP).

Possible errors:

Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096characters.Returns INVALID_ARGUMENT if the product does not exist.Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothingcompatible with the parent product’s product_category is detected.Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.CreateReferenceImageRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#CreateReferenceImageRequest.}resp,err:=c.CreateReferenceImage(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ProductSearchClient) DeleteProduct

DeleteProduct permanently deletes a product and its reference images.

Metadata of the product and all its images will be deleted right away, butsearch queries against ProductSets containing the product may still workuntil all related caches are refreshed.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.DeleteProductRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#DeleteProductRequest.}err=c.DeleteProduct(ctx,req)iferr!=nil{// TODO: Handle error.}}

func (*ProductSearchClient) DeleteProductSet

DeleteProductSet permanently deletes a ProductSet. Products and ReferenceImages in theProductSet are not deleted.

The actual image files are not deleted from Google Cloud Storage.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.DeleteProductSetRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#DeleteProductSetRequest.}err=c.DeleteProductSet(ctx,req)iferr!=nil{// TODO: Handle error.}}

func (*ProductSearchClient) DeleteReferenceImage

DeleteReferenceImage permanently deletes a reference image.

The image metadata will be deleted right away, but search queriesagainst ProductSets containing the image may still work until all relatedcaches are refreshed.

The actual image files are not deleted from Google Cloud Storage.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.DeleteReferenceImageRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#DeleteReferenceImageRequest.}err=c.DeleteReferenceImage(ctx,req)iferr!=nil{// TODO: Handle error.}}

func (*ProductSearchClient) GetOperation

GetOperation is a utility method from google.longrunning.Operations.

Example

packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"vision"cloud.google.com/go/vision/v2/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.GetOperationRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.}resp,err:=c.GetOperation(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ProductSearchClient) GetProduct

GetProduct gets information associated with a Product.

Possible errors:

Returns NOT_FOUND if the Product does not exist.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.GetProductRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#GetProductRequest.}resp,err:=c.GetProduct(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ProductSearchClient) GetProductSet

GetProductSet gets information associated with a ProductSet.

Possible errors:

Returns NOT_FOUND if the ProductSet does not exist.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.GetProductSetRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#GetProductSetRequest.}resp,err:=c.GetProductSet(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ProductSearchClient) GetReferenceImage

GetReferenceImage gets information associated with a ReferenceImage.

Possible errors:

Returns NOT_FOUND if the specified image does not exist.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.GetReferenceImageRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#GetReferenceImageRequest.}resp,err:=c.GetReferenceImage(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ProductSearchClient) ImportProductSets

ImportProductSets asynchronous API that imports a list of reference images to specifiedproduct sets based on a list of image information.

The google.longrunning.Operation API can beused to keep track of the progress and results of the request.Operation.metadata contains BatchOperationMetadata. (progress)Operation.response contains ImportProductSetsResponse. (results)

The input source of this method is a csv file on Google Cloud Storage.For the format of the csv file please seeImportProductSetsGcsSource.csv_file_uri.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.ImportProductSetsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#ImportProductSetsRequest.}op,err:=c.ImportProductSets(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ProductSearchClient) ImportProductSetsOperation

func(c*ProductSearchClient)ImportProductSetsOperation(namestring)*ImportProductSetsOperation

ImportProductSetsOperation returns a new ImportProductSetsOperation from a given name.The name must be that of a previously created ImportProductSetsOperation, possibly from a different process.

func (*ProductSearchClient) ListProductSets

ListProductSets lists ProductSets in an unspecified order.

Possible errors:

Returns INVALID_ARGUMENT if page_size is greater than 100, or lessthan 1.

Examples

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.ListProductSetsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#ListProductSetsRequest.}it:=c.ListProductSets(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*visionpb.ListProductSetsResponse)}}
all
packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.ListProductSetsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#ListProductSetsRequest.}forresp,err:=rangec.ListProductSets(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*ProductSearchClient) ListProducts

ListProducts lists products in an unspecified order.

Possible errors:

Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.

Examples

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.ListProductsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#ListProductsRequest.}it:=c.ListProducts(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*visionpb.ListProductsResponse)}}
all
packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.ListProductsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#ListProductsRequest.}forresp,err:=rangec.ListProducts(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*ProductSearchClient) ListProductsInProductSet

ListProductsInProductSet lists the Products in a ProductSet, in an unspecified order. If theProductSet does not exist, the products field of the response will beempty.

Possible errors:

Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.

Examples

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.ListProductsInProductSetRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#ListProductsInProductSetRequest.}it:=c.ListProductsInProductSet(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*visionpb.ListProductsInProductSetResponse)}}
all
packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.ListProductsInProductSetRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#ListProductsInProductSetRequest.}forresp,err:=rangec.ListProductsInProductSet(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*ProductSearchClient) ListReferenceImages

ListReferenceImages lists reference images.

Possible errors:

Returns NOT_FOUND if the parent product does not exist.Returns INVALID_ARGUMENT if the page_size is greater than 100, or lessthan 1.

Examples

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.ListReferenceImagesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#ListReferenceImagesRequest.}it:=c.ListReferenceImages(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*visionpb.ListReferenceImagesResponse)}}
all
packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.ListReferenceImagesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#ListReferenceImagesRequest.}forresp,err:=rangec.ListReferenceImages(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*ProductSearchClient) PurgeProducts

PurgeProducts asynchronous API to delete all Products in a ProductSet or all Productsthat are in no ProductSet.

If a Product is a member of the specified ProductSet in addition to otherProductSets, the Product will still be deleted.

It is recommended to not delete the specified ProductSet until after thisoperation has completed. It is also recommended to not add any of theProducts involved in the batch delete to a new ProductSet while thisoperation is running because those Products may still end up deleted.

It’s not possible to undo the PurgeProducts operation. Therefore, it isrecommended to keep the csv files used in ImportProductSets (if that washow you originally built the Product Set) before starting PurgeProducts, incase you need to re-import the data after deletion.

If the plan is to purge all of the Products from a ProductSet and thenre-use the empty ProductSet to re-import new Products into the emptyProductSet, you must wait until the PurgeProducts operation has finishedfor that ProductSet.

The google.longrunning.Operation API can beused to keep track of the progress and results of the request.Operation.metadata contains BatchOperationMetadata. (progress)

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.PurgeProductsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#PurgeProductsRequest.}op,err:=c.PurgeProducts(ctx,req)iferr!=nil{// TODO: Handle error.}err=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}}

func (*ProductSearchClient) PurgeProductsOperation

func(c*ProductSearchClient)PurgeProductsOperation(namestring)*PurgeProductsOperation

PurgeProductsOperation returns a new PurgeProductsOperation from a given name.The name must be that of a previously created PurgeProductsOperation, possibly from a different process.

func (*ProductSearchClient) RemoveProductFromProductSet

RemoveProductFromProductSet removes a Product from the specified ProductSet.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.RemoveProductFromProductSetRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#RemoveProductFromProductSetRequest.}err=c.RemoveProductFromProductSet(ctx,req)iferr!=nil{// TODO: Handle error.}}

func (*ProductSearchClient) UpdateProduct

UpdateProduct makes changes to a Product resource.Only the display_name, description, and labels fields can be updatedright now.

If labels are updated, the change will not be reflected in queries untilthe next index time.

Possible errors:

Returns NOT_FOUND if the Product does not exist.Returns INVALID_ARGUMENT if display_name is present in update_mask but ismissing from the request or longer than 4096 characters.Returns INVALID_ARGUMENT if description is present in update_mask but islonger than 4096 characters.Returns INVALID_ARGUMENT if product_category is present in update_mask.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.UpdateProductRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#UpdateProductRequest.}resp,err:=c.UpdateProduct(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*ProductSearchClient) UpdateProductSet

UpdateProductSet makes changes to a ProductSet resource.Only display_name can be updated currently.

Possible errors:

Returns NOT_FOUND if the ProductSet does not exist.Returns INVALID_ARGUMENT if display_name is present in update_mask butmissing from the request or longer than 4096 characters.

Example

packagemainimport("context"vision"cloud.google.com/go/vision/v2/apiv1"visionpb"cloud.google.com/go/vision/v2/apiv1/visionpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=vision.NewProductSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&visionpb.UpdateProductSetRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/vision/v2/apiv1/visionpb#UpdateProductSetRequest.}resp,err:=c.UpdateProductSet(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

ProductSetIterator

typeProductSetIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*visionpb.ProductSet,nextPageTokenstring,errerror)// contains filtered or unexported fields}

ProductSetIterator manages a stream of *visionpb.ProductSet.

func (*ProductSetIterator) All

func(it*ProductSetIterator)All()iter.Seq2[*visionpb.ProductSet,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*ProductSetIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*ProductSetIterator) PageInfo

func(it*ProductSetIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

PurgeProductsOperation

typePurgeProductsOperationstruct{// contains filtered or unexported fields}

PurgeProductsOperation manages a long-running operation from PurgeProducts.

func (*PurgeProductsOperation) Done

Done reports whether the long-running operation has completed.

func (*PurgeProductsOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*PurgeProductsOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*PurgeProductsOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*PurgeProductsOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

ReferenceImageIterator

typeReferenceImageIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*visionpb.ReferenceImage,nextPageTokenstring,errerror)// contains filtered or unexported fields}

ReferenceImageIterator manages a stream of *visionpb.ReferenceImage.

func (*ReferenceImageIterator) All

func(it*ReferenceImageIterator)All()iter.Seq2[*visionpb.ReferenceImage,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*ReferenceImageIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*ReferenceImageIterator) PageInfo

func(it*ReferenceImageIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-30 UTC.