Vertex AI Search for commerce API v2 - Package cloud.google.com/go/retail/apiv2 (v1.25.1) Stay organized with collections Save and categorize content based on your preferences.
Package retail is an auto-generated package for theVertex AI Search for commerce API.
Vertex AI Search for commerce API is made up of Retail Search, Browse andRecommendations. These discovery AI solutions help you implementpersonalized search, browse and recommendations, based on machine learningmodels, across your websites and mobile 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:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/retail/apiv2@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:=retail.NewAnalyticsClient(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:=&retailpb.ExportAnalyticsMetricsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ExportAnalyticsMetricsRequest.}op,err:=c.ExportAnalyticsMetrics(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp
Use of Context
The ctx passed to NewAnalyticsClient 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()[]stringDefaultAuthScopes reports the default set of authentication scopes to use with this package.
AddFulfillmentPlacesOperation
typeAddFulfillmentPlacesOperationstruct{// contains filtered or unexported fields}AddFulfillmentPlacesOperation manages a long-running operation from AddFulfillmentPlaces.
func (*AddFulfillmentPlacesOperation) Done
func(op*AddFulfillmentPlacesOperation)Done()boolDone reports whether the long-running operation has completed.
func (*AddFulfillmentPlacesOperation) Metadata
func(op*AddFulfillmentPlacesOperation)Metadata()(*retailpb.AddFulfillmentPlacesMetadata,error)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 (*AddFulfillmentPlacesOperation) Name
func(op*AddFulfillmentPlacesOperation)Name()stringName 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 (*AddFulfillmentPlacesOperation) Poll
func(op*AddFulfillmentPlacesOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.AddFulfillmentPlacesResponse,error)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 (*AddFulfillmentPlacesOperation) Wait
func(op*AddFulfillmentPlacesOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.AddFulfillmentPlacesResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
AddLocalInventoriesOperation
typeAddLocalInventoriesOperationstruct{// contains filtered or unexported fields}AddLocalInventoriesOperation manages a long-running operation from AddLocalInventories.
func (*AddLocalInventoriesOperation) Done
func(op*AddLocalInventoriesOperation)Done()boolDone reports whether the long-running operation has completed.
func (*AddLocalInventoriesOperation) Metadata
func(op*AddLocalInventoriesOperation)Metadata()(*retailpb.AddLocalInventoriesMetadata,error)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 (*AddLocalInventoriesOperation) Name
func(op*AddLocalInventoriesOperation)Name()stringName 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 (*AddLocalInventoriesOperation) Poll
func(op*AddLocalInventoriesOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.AddLocalInventoriesResponse,error)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 (*AddLocalInventoriesOperation) Wait
func(op*AddLocalInventoriesOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.AddLocalInventoriesResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
AnalyticsCallOptions
typeAnalyticsCallOptionsstruct{ExportAnalyticsMetrics[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}AnalyticsCallOptions contains the retry settings for each method of AnalyticsClient.
AnalyticsClient
typeAnalyticsClientstruct{// The call options for this service.CallOptions*AnalyticsCallOptions// 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}AnalyticsClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for managing & accessing retail search business metric.Retail recommendation business metric is currently not available.
func NewAnalyticsClient
funcNewAnalyticsClient(ctxcontext.Context,opts...option.ClientOption)(*AnalyticsClient,error)NewAnalyticsClient creates a new analytics service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for managing & accessing retail search business metric.Retail recommendation business metric is currently not available.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewAnalyticsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewAnalyticsRESTClient
funcNewAnalyticsRESTClient(ctxcontext.Context,opts...option.ClientOption)(*AnalyticsClient,error)NewAnalyticsRESTClient creates a new analytics service rest client.
Service for managing & accessing retail search business metric.Retail recommendation business metric is currently not available.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewAnalyticsRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*AnalyticsClient) Close
func(c*AnalyticsClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*AnalyticsClient) Connection (deprecated)
func(c*AnalyticsClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*AnalyticsClient) ExportAnalyticsMetrics
func(c*AnalyticsClient)ExportAnalyticsMetrics(ctxcontext.Context,req*retailpb.ExportAnalyticsMetricsRequest,opts...gax.CallOption)(*ExportAnalyticsMetricsOperation,error)ExportAnalyticsMetrics exports analytics metrics.
Operation.response is of type ExportAnalyticsMetricsResponse.Operation.metadata is of type ExportMetadata.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewAnalyticsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ExportAnalyticsMetricsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ExportAnalyticsMetricsRequest.}op,err:=c.ExportAnalyticsMetrics(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*AnalyticsClient) ExportAnalyticsMetricsOperation
func(c*AnalyticsClient)ExportAnalyticsMetricsOperation(namestring)*ExportAnalyticsMetricsOperationExportAnalyticsMetricsOperation returns a new ExportAnalyticsMetricsOperation from a given name.The name must be that of a previously created ExportAnalyticsMetricsOperation, possibly from a different process.
func (*AnalyticsClient) GetOperation
func(c*AnalyticsClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewAnalyticsClient(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 (*AnalyticsClient) ListOperations
func(c*AnalyticsClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewAnalyticsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewAnalyticsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}CatalogCallOptions
typeCatalogCallOptionsstruct{ListCatalogs[]gax.CallOptionUpdateCatalog[]gax.CallOptionSetDefaultBranch[]gax.CallOptionGetDefaultBranch[]gax.CallOptionGetCompletionConfig[]gax.CallOptionUpdateCompletionConfig[]gax.CallOptionGetAttributesConfig[]gax.CallOptionUpdateAttributesConfig[]gax.CallOptionAddCatalogAttribute[]gax.CallOptionRemoveCatalogAttribute[]gax.CallOptionReplaceCatalogAttribute[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}CatalogCallOptions contains the retry settings for each method of CatalogClient.
CatalogClient
typeCatalogClientstruct{// The call options for this service.CallOptions*CatalogCallOptions// contains filtered or unexported fields}CatalogClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for managing catalog configuration.
func NewCatalogClient
funcNewCatalogClient(ctxcontext.Context,opts...option.ClientOption)(*CatalogClient,error)NewCatalogClient creates a new catalog service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for managing catalog configuration.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewCatalogRESTClient
funcNewCatalogRESTClient(ctxcontext.Context,opts...option.ClientOption)(*CatalogClient,error)NewCatalogRESTClient creates a new catalog service rest client.
Service for managing catalog configuration.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewCatalogRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*CatalogClient) AddCatalogAttribute
func(c*CatalogClient)AddCatalogAttribute(ctxcontext.Context,req*retailpb.AddCatalogAttributeRequest,opts...gax.CallOption)(*retailpb.AttributesConfig,error)AddCatalogAttribute adds the specifiedCatalogAttribute to theAttributesConfig.
If the CatalogAttribute to addalready exists, an ALREADY_EXISTS error is returned.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.AddCatalogAttributeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#AddCatalogAttributeRequest.}resp,err:=c.AddCatalogAttribute(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*CatalogClient) Close
func(c*CatalogClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*CatalogClient) Connection (deprecated)
func(c*CatalogClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*CatalogClient) GetAttributesConfig
func(c*CatalogClient)GetAttributesConfig(ctxcontext.Context,req*retailpb.GetAttributesConfigRequest,opts...gax.CallOption)(*retailpb.AttributesConfig,error)GetAttributesConfig gets an AttributesConfig.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.GetAttributesConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#GetAttributesConfigRequest.}resp,err:=c.GetAttributesConfig(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*CatalogClient) GetCompletionConfig
func(c*CatalogClient)GetCompletionConfig(ctxcontext.Context,req*retailpb.GetCompletionConfigRequest,opts...gax.CallOption)(*retailpb.CompletionConfig,error)GetCompletionConfig gets a CompletionConfig.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.GetCompletionConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#GetCompletionConfigRequest.}resp,err:=c.GetCompletionConfig(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*CatalogClient) GetDefaultBranch
func(c*CatalogClient)GetDefaultBranch(ctxcontext.Context,req*retailpb.GetDefaultBranchRequest,opts...gax.CallOption)(*retailpb.GetDefaultBranchResponse,error)GetDefaultBranch get which branch is currently default branch set byCatalogService.SetDefaultBranchmethod under a specified parent catalog.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.GetDefaultBranchRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#GetDefaultBranchRequest.}resp,err:=c.GetDefaultBranch(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*CatalogClient) GetOperation
func(c*CatalogClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewCatalogClient(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 (*CatalogClient) ListCatalogs
func(c*CatalogClient)ListCatalogs(ctxcontext.Context,req*retailpb.ListCatalogsRequest,opts...gax.CallOption)*CatalogIteratorListCatalogs lists all the Catalogs associated withthe project.
Examples
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb""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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListCatalogsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ListCatalogsRequest.}it:=c.ListCatalogs(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.(*retailpb.ListCatalogsResponse)}}all
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListCatalogsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ListCatalogsRequest.}forresp,err:=rangec.ListCatalogs(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*CatalogClient) ListOperations
func(c*CatalogClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*CatalogClient) RemoveCatalogAttribute
func(c*CatalogClient)RemoveCatalogAttribute(ctxcontext.Context,req*retailpb.RemoveCatalogAttributeRequest,opts...gax.CallOption)(*retailpb.AttributesConfig,error)RemoveCatalogAttribute removes the specifiedCatalogAttribute from theAttributesConfig.
If the CatalogAttribute toremove does not exist, a NOT_FOUND error is returned.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.RemoveCatalogAttributeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#RemoveCatalogAttributeRequest.}resp,err:=c.RemoveCatalogAttribute(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*CatalogClient) ReplaceCatalogAttribute
func(c*CatalogClient)ReplaceCatalogAttribute(ctxcontext.Context,req*retailpb.ReplaceCatalogAttributeRequest,opts...gax.CallOption)(*retailpb.AttributesConfig,error)ReplaceCatalogAttribute replaces the specifiedCatalogAttribute in theAttributesConfig by updating thecatalog attribute with the sameCatalogAttribute.key.
If the CatalogAttribute toreplace does not exist, a NOT_FOUND error is returned.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ReplaceCatalogAttributeRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ReplaceCatalogAttributeRequest.}resp,err:=c.ReplaceCatalogAttribute(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*CatalogClient) SetDefaultBranch
func(c*CatalogClient)SetDefaultBranch(ctxcontext.Context,req*retailpb.SetDefaultBranchRequest,opts...gax.CallOption)errorSetDefaultBranch set a specified branch id as default branch. API methods such asSearchService.Search,ProductService.GetProduct,ProductService.ListProductswill treat requests using “default_branch” to the actual branch id set asdefault.
For example, if projects//locations//catalogs//branches/1 is set asdefault, settingSearchRequest.branch toprojects//locations//catalogs//branches/default_branch is equivalentto settingSearchRequest.branch toprojects//locations//catalogs/*/branches/1.
Using multiple branches can be useful when developers would liketo have a staging branch to test and verify for future usage. When itbecomes ready, developers switch on the staging branch using this APIwhile keeping usingprojects//locations//catalogs/*/branches/default_branch asSearchRequest.branch toroute the traffic to this staging branch.
CAUTION: If you have live predict/search traffic, switching the defaultbranch could potentially cause outages if the ID space of the new branchis very different from the old one.
More specifically:
PredictionService will only return product IDs from branch {newBranch}.SearchService will only return product IDs from branch {newBranch}(if branch is not explicitly set).UserEventService will only join events with products from branch{newBranch}.Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.SetDefaultBranchRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#SetDefaultBranchRequest.}err=c.SetDefaultBranch(ctx,req)iferr!=nil{// TODO: Handle error.}}func (*CatalogClient) UpdateAttributesConfig
func(c*CatalogClient)UpdateAttributesConfig(ctxcontext.Context,req*retailpb.UpdateAttributesConfigRequest,opts...gax.CallOption)(*retailpb.AttributesConfig,error)UpdateAttributesConfig updates the AttributesConfig.
The catalog attributes in the request will be updated in the catalog, orinserted if they do not exist. Existing catalog attributes not included inthe request will remain unchanged. Attributes that are assigned toproducts, but do not exist at the catalog level, are always included in theresponse. The product attribute is assigned default values for missingcatalog attribute fields, e.g., searchable and dynamic facetable options.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.UpdateAttributesConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#UpdateAttributesConfigRequest.}resp,err:=c.UpdateAttributesConfig(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*CatalogClient) UpdateCatalog
func(c*CatalogClient)UpdateCatalog(ctxcontext.Context,req*retailpb.UpdateCatalogRequest,opts...gax.CallOption)(*retailpb.Catalog,error)UpdateCatalog updates the Catalogs.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.UpdateCatalogRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#UpdateCatalogRequest.}resp,err:=c.UpdateCatalog(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*CatalogClient) UpdateCompletionConfig
func(c*CatalogClient)UpdateCompletionConfig(ctxcontext.Context,req*retailpb.UpdateCompletionConfigRequest,opts...gax.CallOption)(*retailpb.CompletionConfig,error)UpdateCompletionConfig updates the CompletionConfigs.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCatalogClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.UpdateCompletionConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#UpdateCompletionConfigRequest.}resp,err:=c.UpdateCompletionConfig(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}CatalogIterator
typeCatalogIteratorstruct{// 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[]*retailpb.Catalog,nextPageTokenstring,errerror)// contains filtered or unexported fields}CatalogIterator manages a stream of *retailpb.Catalog.
func (*CatalogIterator) All
func(it*CatalogIterator)All()iter.Seq2[*retailpb.Catalog,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*CatalogIterator) Next
func(it*CatalogIterator)Next()(*retailpb.Catalog,error)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 (*CatalogIterator) PageInfo
func(it*CatalogIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
CompletionCallOptions
typeCompletionCallOptionsstruct{CompleteQuery[]gax.CallOptionImportCompletionData[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}CompletionCallOptions contains the retry settings for each method of CompletionClient.
CompletionClient
typeCompletionClientstruct{// The call options for this service.CallOptions*CompletionCallOptions// 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}CompletionClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Autocomplete service for retail.
This feature is only available for users who have Retail Search enabled.Enable Retail Search on Cloud Console before using this feature.
func NewCompletionClient
funcNewCompletionClient(ctxcontext.Context,opts...option.ClientOption)(*CompletionClient,error)NewCompletionClient creates a new completion service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Autocomplete service for retail.
This feature is only available for users who have Retail Search enabled.Enable Retail Search on Cloud Console before using this feature.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewCompletionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewCompletionRESTClient
funcNewCompletionRESTClient(ctxcontext.Context,opts...option.ClientOption)(*CompletionClient,error)NewCompletionRESTClient creates a new completion service rest client.
Autocomplete service for retail.
This feature is only available for users who have Retail Search enabled.Enable Retail Search on Cloud Console before using this feature.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewCompletionRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*CompletionClient) Close
func(c*CompletionClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*CompletionClient) CompleteQuery
func(c*CompletionClient)CompleteQuery(ctxcontext.Context,req*retailpb.CompleteQueryRequest,opts...gax.CallOption)(*retailpb.CompleteQueryResponse,error)CompleteQuery completes the specified prefix with keyword suggestions.
This feature is only available for users who have Retail Search enabled.Enable Retail Search on Cloud Console before using this feature.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCompletionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.CompleteQueryRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#CompleteQueryRequest.}resp,err:=c.CompleteQuery(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*CompletionClient) Connection (deprecated)
func(c*CompletionClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*CompletionClient) GetOperation
func(c*CompletionClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewCompletionClient(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 (*CompletionClient) ImportCompletionData
func(c*CompletionClient)ImportCompletionData(ctxcontext.Context,req*retailpb.ImportCompletionDataRequest,opts...gax.CallOption)(*ImportCompletionDataOperation,error)ImportCompletionData bulk import of processed completion dataset.
Request processing is asynchronous. Partial updating is not supported.
The operation is successfully finished only after the imported suggestionsare indexed successfully and ready for serving. The process takes hours.
This feature is only available for users who have Retail Search enabled.Enable Retail Search on Cloud Console before using this feature.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewCompletionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ImportCompletionDataRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ImportCompletionDataRequest.}op,err:=c.ImportCompletionData(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*CompletionClient) ImportCompletionDataOperation
func(c*CompletionClient)ImportCompletionDataOperation(namestring)*ImportCompletionDataOperationImportCompletionDataOperation returns a new ImportCompletionDataOperation from a given name.The name must be that of a previously created ImportCompletionDataOperation, possibly from a different process.
func (*CompletionClient) ListOperations
func(c*CompletionClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewCompletionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewCompletionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}ControlCallOptions
typeControlCallOptionsstruct{CreateControl[]gax.CallOptionDeleteControl[]gax.CallOptionUpdateControl[]gax.CallOptionGetControl[]gax.CallOptionListControls[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}ControlCallOptions contains the retry settings for each method of ControlClient.
ControlClient
typeControlClientstruct{// The call options for this service.CallOptions*ControlCallOptions// contains filtered or unexported fields}ControlClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for modifying Control.
func NewControlClient
funcNewControlClient(ctxcontext.Context,opts...option.ClientOption)(*ControlClient,error)NewControlClient creates a new control service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for modifying Control.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewControlClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewControlRESTClient
funcNewControlRESTClient(ctxcontext.Context,opts...option.ClientOption)(*ControlClient,error)NewControlRESTClient creates a new control service rest client.
Service for modifying Control.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewControlRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*ControlClient) Close
func(c*ControlClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*ControlClient) Connection (deprecated)
func(c*ControlClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*ControlClient) CreateControl
func(c*ControlClient)CreateControl(ctxcontext.Context,req*retailpb.CreateControlRequest,opts...gax.CallOption)(*retailpb.Control,error)CreateControl creates a Control.
If the Control to create already exists,an ALREADY_EXISTS error is returned.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewControlClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.CreateControlRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#CreateControlRequest.}resp,err:=c.CreateControl(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ControlClient) DeleteControl
func(c*ControlClient)DeleteControl(ctxcontext.Context,req*retailpb.DeleteControlRequest,opts...gax.CallOption)errorDeleteControl deletes a Control.
If the Control to delete does not exist,a NOT_FOUND error is returned.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewControlClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.DeleteControlRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#DeleteControlRequest.}err=c.DeleteControl(ctx,req)iferr!=nil{// TODO: Handle error.}}func (*ControlClient) GetControl
func(c*ControlClient)GetControl(ctxcontext.Context,req*retailpb.GetControlRequest,opts...gax.CallOption)(*retailpb.Control,error)GetControl gets a Control.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewControlClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.GetControlRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#GetControlRequest.}resp,err:=c.GetControl(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ControlClient) GetOperation
func(c*ControlClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewControlClient(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 (*ControlClient) ListControls
func(c*ControlClient)ListControls(ctxcontext.Context,req*retailpb.ListControlsRequest,opts...gax.CallOption)*ControlIteratorListControls lists all Controls by their parentCatalog.
Examples
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb""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:=retail.NewControlClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListControlsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ListControlsRequest.}it:=c.ListControls(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.(*retailpb.ListControlsResponse)}}all
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewControlClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListControlsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ListControlsRequest.}forresp,err:=rangec.ListControls(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*ControlClient) ListOperations
func(c*ControlClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewControlClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewControlClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*ControlClient) UpdateControl
func(c*ControlClient)UpdateControl(ctxcontext.Context,req*retailpb.UpdateControlRequest,opts...gax.CallOption)(*retailpb.Control,error)UpdateControl updates a Control.
Control cannot be set to a differentoneof field, if so an INVALID_ARGUMENT is returned. If theControl to update does not exist, aNOT_FOUND error is returned.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewControlClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.UpdateControlRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#UpdateControlRequest.}resp,err:=c.UpdateControl(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}ControlIterator
typeControlIteratorstruct{// 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[]*retailpb.Control,nextPageTokenstring,errerror)// contains filtered or unexported fields}ControlIterator manages a stream of *retailpb.Control.
func (*ControlIterator) All
func(it*ControlIterator)All()iter.Seq2[*retailpb.Control,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*ControlIterator) Next
func(it*ControlIterator)Next()(*retailpb.Control,error)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 (*ControlIterator) PageInfo
func(it*ControlIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ConversationalSearchCallOptions
typeConversationalSearchCallOptionsstruct{ConversationalSearch[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}ConversationalSearchCallOptions contains the retry settings for each method of ConversationalSearchClient.
ConversationalSearchClient
typeConversationalSearchClientstruct{// The call options for this service.CallOptions*ConversationalSearchCallOptions// contains filtered or unexported fields}ConversationalSearchClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for retail conversational search.
This feature is only available for users who have Retail ConversationalSearch enabled. Enable Retail Conversational Search on Cloud Consolebefore using this feature.
func NewConversationalSearchClient
funcNewConversationalSearchClient(ctxcontext.Context,opts...option.ClientOption)(*ConversationalSearchClient,error)NewConversationalSearchClient creates a new conversational search service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for retail conversational search.
This feature is only available for users who have Retail ConversationalSearch enabled. Enable Retail Conversational Search on Cloud Consolebefore using this feature.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewConversationalSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewConversationalSearchRESTClient
funcNewConversationalSearchRESTClient(ctxcontext.Context,opts...option.ClientOption)(*ConversationalSearchClient,error)NewConversationalSearchRESTClient creates a new conversational search service rest client.
Service for retail conversational search.
This feature is only available for users who have Retail ConversationalSearch enabled. Enable Retail Conversational Search on Cloud Consolebefore using this feature.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewConversationalSearchRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*ConversationalSearchClient) Close
func(c*ConversationalSearchClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*ConversationalSearchClient) Connection (deprecated)
func(c*ConversationalSearchClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*ConversationalSearchClient) ConversationalSearch
func(c*ConversationalSearchClient)ConversationalSearch(ctxcontext.Context,req*retailpb.ConversationalSearchRequest,opts...gax.CallOption)(retailpb.ConversationalSearchService_ConversationalSearchClient,error)ConversationalSearch performs a conversational search.
This feature is only available for users who have Conversational Searchenabled.
func (*ConversationalSearchClient) GetOperation
func(c*ConversationalSearchClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewConversationalSearchClient(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 (*ConversationalSearchClient) ListOperations
func(c*ConversationalSearchClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewConversationalSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewConversationalSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}CreateModelOperation
typeCreateModelOperationstruct{// contains filtered or unexported fields}CreateModelOperation manages a long-running operation from CreateModel.
func (*CreateModelOperation) Done
func(op*CreateModelOperation)Done()boolDone reports whether the long-running operation has completed.
func (*CreateModelOperation) Metadata
func(op*CreateModelOperation)Metadata()(*retailpb.CreateModelMetadata,error)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 (*CreateModelOperation) Name
func(op*CreateModelOperation)Name()stringName 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 (*CreateModelOperation) Poll
func(op*CreateModelOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.Model,error)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 (*CreateModelOperation) Wait
func(op*CreateModelOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.Model,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
ExportAnalyticsMetricsOperation
typeExportAnalyticsMetricsOperationstruct{// contains filtered or unexported fields}ExportAnalyticsMetricsOperation manages a long-running operation from ExportAnalyticsMetrics.
func (*ExportAnalyticsMetricsOperation) Done
func(op*ExportAnalyticsMetricsOperation)Done()boolDone reports whether the long-running operation has completed.
func (*ExportAnalyticsMetricsOperation) Metadata
func(op*ExportAnalyticsMetricsOperation)Metadata()(*retailpb.ExportMetadata,error)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 (*ExportAnalyticsMetricsOperation) Name
func(op*ExportAnalyticsMetricsOperation)Name()stringName 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 (*ExportAnalyticsMetricsOperation) Poll
func(op*ExportAnalyticsMetricsOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.ExportAnalyticsMetricsResponse,error)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 (*ExportAnalyticsMetricsOperation) Wait
func(op*ExportAnalyticsMetricsOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.ExportAnalyticsMetricsResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
GenerativeQuestionCallOptions
typeGenerativeQuestionCallOptionsstruct{UpdateGenerativeQuestionsFeatureConfig[]gax.CallOptionGetGenerativeQuestionsFeatureConfig[]gax.CallOptionListGenerativeQuestionConfigs[]gax.CallOptionUpdateGenerativeQuestionConfig[]gax.CallOptionBatchUpdateGenerativeQuestionConfigs[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}GenerativeQuestionCallOptions contains the retry settings for each method of GenerativeQuestionClient.
GenerativeQuestionClient
typeGenerativeQuestionClientstruct{// The call options for this service.CallOptions*GenerativeQuestionCallOptions// contains filtered or unexported fields}GenerativeQuestionClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for managing LLM generated questions in search serving.
func NewGenerativeQuestionClient
funcNewGenerativeQuestionClient(ctxcontext.Context,opts...option.ClientOption)(*GenerativeQuestionClient,error)NewGenerativeQuestionClient creates a new generative question service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for managing LLM generated questions in search serving.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewGenerativeQuestionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewGenerativeQuestionRESTClient
funcNewGenerativeQuestionRESTClient(ctxcontext.Context,opts...option.ClientOption)(*GenerativeQuestionClient,error)NewGenerativeQuestionRESTClient creates a new generative question service rest client.
Service for managing LLM generated questions in search serving.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewGenerativeQuestionRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*GenerativeQuestionClient) BatchUpdateGenerativeQuestionConfigs
func(c*GenerativeQuestionClient)BatchUpdateGenerativeQuestionConfigs(ctxcontext.Context,req*retailpb.BatchUpdateGenerativeQuestionConfigsRequest,opts...gax.CallOption)(*retailpb.BatchUpdateGenerativeQuestionConfigsResponse,error)BatchUpdateGenerativeQuestionConfigs allows management of multiple questions.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewGenerativeQuestionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.BatchUpdateGenerativeQuestionConfigsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#BatchUpdateGenerativeQuestionConfigsRequest.}resp,err:=c.BatchUpdateGenerativeQuestionConfigs(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GenerativeQuestionClient) Close
func(c*GenerativeQuestionClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*GenerativeQuestionClient) Connection (deprecated)
func(c*GenerativeQuestionClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*GenerativeQuestionClient) GetGenerativeQuestionsFeatureConfig
func(c*GenerativeQuestionClient)GetGenerativeQuestionsFeatureConfig(ctxcontext.Context,req*retailpb.GetGenerativeQuestionsFeatureConfigRequest,opts...gax.CallOption)(*retailpb.GenerativeQuestionsFeatureConfig,error)GetGenerativeQuestionsFeatureConfig manages overal generative question feature state – enables togglingfeature on and off.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewGenerativeQuestionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.GetGenerativeQuestionsFeatureConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#GetGenerativeQuestionsFeatureConfigRequest.}resp,err:=c.GetGenerativeQuestionsFeatureConfig(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GenerativeQuestionClient) GetOperation
func(c*GenerativeQuestionClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewGenerativeQuestionClient(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 (*GenerativeQuestionClient) ListGenerativeQuestionConfigs
func(c*GenerativeQuestionClient)ListGenerativeQuestionConfigs(ctxcontext.Context,req*retailpb.ListGenerativeQuestionConfigsRequest,opts...gax.CallOption)(*retailpb.ListGenerativeQuestionConfigsResponse,error)ListGenerativeQuestionConfigs returns all questions for a given catalog.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewGenerativeQuestionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListGenerativeQuestionConfigsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ListGenerativeQuestionConfigsRequest.}resp,err:=c.ListGenerativeQuestionConfigs(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GenerativeQuestionClient) ListOperations
func(c*GenerativeQuestionClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewGenerativeQuestionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewGenerativeQuestionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*GenerativeQuestionClient) UpdateGenerativeQuestionConfig
func(c*GenerativeQuestionClient)UpdateGenerativeQuestionConfig(ctxcontext.Context,req*retailpb.UpdateGenerativeQuestionConfigRequest,opts...gax.CallOption)(*retailpb.GenerativeQuestionConfig,error)UpdateGenerativeQuestionConfig allows management of individual questions.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewGenerativeQuestionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.UpdateGenerativeQuestionConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#UpdateGenerativeQuestionConfigRequest.}resp,err:=c.UpdateGenerativeQuestionConfig(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GenerativeQuestionClient) UpdateGenerativeQuestionsFeatureConfig
func(c*GenerativeQuestionClient)UpdateGenerativeQuestionsFeatureConfig(ctxcontext.Context,req*retailpb.UpdateGenerativeQuestionsFeatureConfigRequest,opts...gax.CallOption)(*retailpb.GenerativeQuestionsFeatureConfig,error)UpdateGenerativeQuestionsFeatureConfig manages overal generative question feature state – enables togglingfeature on and off.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewGenerativeQuestionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.UpdateGenerativeQuestionsFeatureConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#UpdateGenerativeQuestionsFeatureConfigRequest.}resp,err:=c.UpdateGenerativeQuestionsFeatureConfig(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}ImportCompletionDataOperation
typeImportCompletionDataOperationstruct{// contains filtered or unexported fields}ImportCompletionDataOperation manages a long-running operation from ImportCompletionData.
func (*ImportCompletionDataOperation) Done
func(op*ImportCompletionDataOperation)Done()boolDone reports whether the long-running operation has completed.
func (*ImportCompletionDataOperation) Metadata
func(op*ImportCompletionDataOperation)Metadata()(*retailpb.ImportMetadata,error)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 (*ImportCompletionDataOperation) Name
func(op*ImportCompletionDataOperation)Name()stringName 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 (*ImportCompletionDataOperation) Poll
func(op*ImportCompletionDataOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.ImportCompletionDataResponse,error)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 (*ImportCompletionDataOperation) Wait
func(op*ImportCompletionDataOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.ImportCompletionDataResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
ImportProductsOperation
typeImportProductsOperationstruct{// contains filtered or unexported fields}ImportProductsOperation manages a long-running operation from ImportProducts.
func (*ImportProductsOperation) Done
func(op*ImportProductsOperation)Done()boolDone reports whether the long-running operation has completed.
func (*ImportProductsOperation) Metadata
func(op*ImportProductsOperation)Metadata()(*retailpb.ImportMetadata,error)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 (*ImportProductsOperation) Name
func(op*ImportProductsOperation)Name()stringName 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 (*ImportProductsOperation) Poll
func(op*ImportProductsOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.ImportProductsResponse,error)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 (*ImportProductsOperation) Wait
func(op*ImportProductsOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.ImportProductsResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
ImportUserEventsOperation
typeImportUserEventsOperationstruct{// contains filtered or unexported fields}ImportUserEventsOperation manages a long-running operation from ImportUserEvents.
func (*ImportUserEventsOperation) Done
func(op*ImportUserEventsOperation)Done()boolDone reports whether the long-running operation has completed.
func (*ImportUserEventsOperation) Metadata
func(op*ImportUserEventsOperation)Metadata()(*retailpb.ImportMetadata,error)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 (*ImportUserEventsOperation) Name
func(op*ImportUserEventsOperation)Name()stringName 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 (*ImportUserEventsOperation) Poll
func(op*ImportUserEventsOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.ImportUserEventsResponse,error)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 (*ImportUserEventsOperation) Wait
func(op*ImportUserEventsOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.ImportUserEventsResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
ModelCallOptions
typeModelCallOptionsstruct{CreateModel[]gax.CallOptionGetModel[]gax.CallOptionPauseModel[]gax.CallOptionResumeModel[]gax.CallOptionDeleteModel[]gax.CallOptionListModels[]gax.CallOptionUpdateModel[]gax.CallOptionTuneModel[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}ModelCallOptions contains the retry settings for each method of ModelClient.
ModelClient
typeModelClientstruct{// The call options for this service.CallOptions*ModelCallOptions// 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}ModelClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for performing CRUD operations on models.Recommendation models contain all the metadata necessary to generate a set ofmodels for the Predict() API. A model is queriedindirectly via a ServingConfig, which associates a model with agiven Placement (e.g. Frequently Bought Together on Home Page).
This service allows you to do the following:
Initiate training of a model.Pause training of an existing model.List all the available models along with their metadata.Control their tuning schedule.func NewModelClient
funcNewModelClient(ctxcontext.Context,opts...option.ClientOption)(*ModelClient,error)NewModelClient creates a new model service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for performing CRUD operations on models.Recommendation models contain all the metadata necessary to generate a set ofmodels for the Predict() API. A model is queriedindirectly via a ServingConfig, which associates a model with agiven Placement (e.g. Frequently Bought Together on Home Page).
This service allows you to do the following:
Initiate training of a model.Pause training of an existing model.List all the available models along with their metadata.Control their tuning schedule.Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewModelRESTClient
funcNewModelRESTClient(ctxcontext.Context,opts...option.ClientOption)(*ModelClient,error)NewModelRESTClient creates a new model service rest client.
Service for performing CRUD operations on models.Recommendation models contain all the metadata necessary to generate a set ofmodels for the Predict() API. A model is queriedindirectly via a ServingConfig, which associates a model with agiven Placement (e.g. Frequently Bought Together on Home Page).
This service allows you to do the following:
Initiate training of a model.Pause training of an existing model.List all the available models along with their metadata.Control their tuning schedule.Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewModelRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*ModelClient) Close
func(c*ModelClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*ModelClient) Connection (deprecated)
func(c*ModelClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*ModelClient) CreateModel
func(c*ModelClient)CreateModel(ctxcontext.Context,req*retailpb.CreateModelRequest,opts...gax.CallOption)(*CreateModelOperation,error)CreateModel creates a new model.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.CreateModelRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#CreateModelRequest.}op,err:=c.CreateModel(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ModelClient) CreateModelOperation
func(c*ModelClient)CreateModelOperation(namestring)*CreateModelOperationCreateModelOperation returns a new CreateModelOperation from a given name.The name must be that of a previously created CreateModelOperation, possibly from a different process.
func (*ModelClient) DeleteModel
func(c*ModelClient)DeleteModel(ctxcontext.Context,req*retailpb.DeleteModelRequest,opts...gax.CallOption)errorDeleteModel deletes an existing model.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.DeleteModelRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#DeleteModelRequest.}err=c.DeleteModel(ctx,req)iferr!=nil{// TODO: Handle error.}}func (*ModelClient) GetModel
func(c*ModelClient)GetModel(ctxcontext.Context,req*retailpb.GetModelRequest,opts...gax.CallOption)(*retailpb.Model,error)GetModel gets a model.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.GetModelRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#GetModelRequest.}resp,err:=c.GetModel(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ModelClient) GetOperation
func(c*ModelClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewModelClient(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 (*ModelClient) ListModels
func(c*ModelClient)ListModels(ctxcontext.Context,req*retailpb.ListModelsRequest,opts...gax.CallOption)*ModelIteratorListModels lists all the models linked to this event store.
Examples
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb""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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListModelsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ListModelsRequest.}it:=c.ListModels(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.(*retailpb.ListModelsResponse)}}all
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListModelsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ListModelsRequest.}forresp,err:=rangec.ListModels(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*ModelClient) ListOperations
func(c*ModelClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*ModelClient) PauseModel
func(c*ModelClient)PauseModel(ctxcontext.Context,req*retailpb.PauseModelRequest,opts...gax.CallOption)(*retailpb.Model,error)PauseModel pauses the training of an existing model.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.PauseModelRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#PauseModelRequest.}resp,err:=c.PauseModel(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ModelClient) ResumeModel
func(c*ModelClient)ResumeModel(ctxcontext.Context,req*retailpb.ResumeModelRequest,opts...gax.CallOption)(*retailpb.Model,error)ResumeModel resumes the training of an existing model.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ResumeModelRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ResumeModelRequest.}resp,err:=c.ResumeModel(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ModelClient) TuneModel
func(c*ModelClient)TuneModel(ctxcontext.Context,req*retailpb.TuneModelRequest,opts...gax.CallOption)(*TuneModelOperation,error)TuneModel tunes an existing model.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.TuneModelRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#TuneModelRequest.}op,err:=c.TuneModel(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ModelClient) TuneModelOperation
func(c*ModelClient)TuneModelOperation(namestring)*TuneModelOperationTuneModelOperation returns a new TuneModelOperation from a given name.The name must be that of a previously created TuneModelOperation, possibly from a different process.
func (*ModelClient) UpdateModel
func(c*ModelClient)UpdateModel(ctxcontext.Context,req*retailpb.UpdateModelRequest,opts...gax.CallOption)(*retailpb.Model,error)UpdateModel update of model metadata. Only fields thatcurrently can be updated are: filtering_option andperiodic_tuning_state.If other values are provided, this API method ignores them.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewModelClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.UpdateModelRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#UpdateModelRequest.}resp,err:=c.UpdateModel(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}ModelIterator
typeModelIteratorstruct{// 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[]*retailpb.Model,nextPageTokenstring,errerror)// contains filtered or unexported fields}ModelIterator manages a stream of *retailpb.Model.
func (*ModelIterator) All
func(it*ModelIterator)All()iter.Seq2[*retailpb.Model,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*ModelIterator) Next
func(it*ModelIterator)Next()(*retailpb.Model,error)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 (*ModelIterator) PageInfo
func(it*ModelIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
OperationIterator
typeOperationIteratorstruct{// 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[]*longrunningpb.Operation,nextPageTokenstring,errerror)// contains filtered or unexported fields}OperationIterator manages a stream of *longrunningpb.Operation.
func (*OperationIterator) All
func(it*OperationIterator)All()iter.Seq2[*longrunningpb.Operation,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*OperationIterator) Next
func(it*OperationIterator)Next()(*longrunningpb.Operation,error)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 (*OperationIterator) PageInfo
func(it*OperationIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
PredictionCallOptions
typePredictionCallOptionsstruct{Predict[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}PredictionCallOptions contains the retry settings for each method of PredictionClient.
PredictionClient
typePredictionClientstruct{// The call options for this service.CallOptions*PredictionCallOptions// contains filtered or unexported fields}PredictionClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for making recommendation prediction.
func NewPredictionClient
funcNewPredictionClient(ctxcontext.Context,opts...option.ClientOption)(*PredictionClient,error)NewPredictionClient creates a new prediction service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for making recommendation prediction.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewPredictionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewPredictionRESTClient
funcNewPredictionRESTClient(ctxcontext.Context,opts...option.ClientOption)(*PredictionClient,error)NewPredictionRESTClient creates a new prediction service rest client.
Service for making recommendation prediction.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewPredictionRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*PredictionClient) Close
func(c*PredictionClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*PredictionClient) Connection (deprecated)
func(c*PredictionClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*PredictionClient) GetOperation
func(c*PredictionClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewPredictionClient(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 (*PredictionClient) ListOperations
func(c*PredictionClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewPredictionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewPredictionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*PredictionClient) Predict
func(c*PredictionClient)Predict(ctxcontext.Context,req*retailpb.PredictRequest,opts...gax.CallOption)(*retailpb.PredictResponse,error)Predict makes a recommendation prediction.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewPredictionClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.PredictRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#PredictRequest.}resp,err:=c.Predict(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}ProductCallOptions
typeProductCallOptionsstruct{CreateProduct[]gax.CallOptionGetProduct[]gax.CallOptionListProducts[]gax.CallOptionUpdateProduct[]gax.CallOptionDeleteProduct[]gax.CallOptionPurgeProducts[]gax.CallOptionImportProducts[]gax.CallOptionSetInventory[]gax.CallOptionAddFulfillmentPlaces[]gax.CallOptionRemoveFulfillmentPlaces[]gax.CallOptionAddLocalInventories[]gax.CallOptionRemoveLocalInventories[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}ProductCallOptions contains the retry settings for each method of ProductClient.
ProductClient
typeProductClientstruct{// The call options for this service.CallOptions*ProductCallOptions// 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}ProductClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for ingesting Product informationof the customer’s website.
func NewProductClient
funcNewProductClient(ctxcontext.Context,opts...option.ClientOption)(*ProductClient,error)NewProductClient creates a new product service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for ingesting Product informationof the customer’s website.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewProductRESTClient
funcNewProductRESTClient(ctxcontext.Context,opts...option.ClientOption)(*ProductClient,error)NewProductRESTClient creates a new product service rest client.
Service for ingesting Product informationof the customer’s website.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewProductRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*ProductClient) AddFulfillmentPlaces
func(c*ProductClient)AddFulfillmentPlaces(ctxcontext.Context,req*retailpb.AddFulfillmentPlacesRequest,opts...gax.CallOption)(*AddFulfillmentPlacesOperation,error)AddFulfillmentPlaces we recommend that you use theProductService.AddLocalInventoriesmethod instead of theProductService.AddFulfillmentPlacesmethod.ProductService.AddLocalInventoriesachieves the same results but provides more fine-grained control overingesting local inventory data.
Incrementally adds place IDs toProduct.fulfillment_info.place_ids.
This process is asynchronous and does not require theProduct to exist before updatingfulfillment information. If the request is valid, the update will beenqueued and processed downstream. As a consequence, when a response isreturned, the added place IDs are not immediately manifested in theProduct queried byProductService.GetProductorProductService.ListProducts.
The returned Operations will be obsoleteafter 1 day, and GetOperationAPI will return NOT_FOUND afterwards.
If conflicting updates are issued, theOperations associated with the staleupdates will not be marked as doneuntil being obsolete.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.AddFulfillmentPlacesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#AddFulfillmentPlacesRequest.}op,err:=c.AddFulfillmentPlaces(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ProductClient) AddFulfillmentPlacesOperation
func(c*ProductClient)AddFulfillmentPlacesOperation(namestring)*AddFulfillmentPlacesOperationAddFulfillmentPlacesOperation returns a new AddFulfillmentPlacesOperation from a given name.The name must be that of a previously created AddFulfillmentPlacesOperation, possibly from a different process.
func (*ProductClient) AddLocalInventories
func(c*ProductClient)AddLocalInventories(ctxcontext.Context,req*retailpb.AddLocalInventoriesRequest,opts...gax.CallOption)(*AddLocalInventoriesOperation,error)AddLocalInventories updates local inventory information for aProduct at a list of places, whilerespecting the last update timestamps of each inventory field.
This process is asynchronous and does not require theProduct to exist before updatinginventory information. If the request is valid, the update will be enqueuedand processed downstream. As a consequence, when a response is returned,updates are not immediately manifested in theProduct queried byProductService.GetProductorProductService.ListProducts.
Local inventory information can only be modified using this method.ProductService.CreateProductandProductService.UpdateProducthas no effect on local inventories.
The returned Operations will be obsoleteafter 1 day, and GetOperationAPI will return NOT_FOUND afterwards.
If conflicting updates are issued, theOperations associated with the staleupdates will not be marked as doneuntil being obsolete.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.AddLocalInventoriesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#AddLocalInventoriesRequest.}op,err:=c.AddLocalInventories(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ProductClient) AddLocalInventoriesOperation
func(c*ProductClient)AddLocalInventoriesOperation(namestring)*AddLocalInventoriesOperationAddLocalInventoriesOperation returns a new AddLocalInventoriesOperation from a given name.The name must be that of a previously created AddLocalInventoriesOperation, possibly from a different process.
func (*ProductClient) Close
func(c*ProductClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*ProductClient) Connection (deprecated)
func(c*ProductClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*ProductClient) CreateProduct
func(c*ProductClient)CreateProduct(ctxcontext.Context,req*retailpb.CreateProductRequest,opts...gax.CallOption)(*retailpb.Product,error)CreateProduct creates a Product.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.CreateProductRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#CreateProductRequest.}resp,err:=c.CreateProduct(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ProductClient) DeleteProduct
func(c*ProductClient)DeleteProduct(ctxcontext.Context,req*retailpb.DeleteProductRequest,opts...gax.CallOption)errorDeleteProduct deletes a Product.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.DeleteProductRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#DeleteProductRequest.}err=c.DeleteProduct(ctx,req)iferr!=nil{// TODO: Handle error.}}func (*ProductClient) GetOperation
func(c*ProductClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewProductClient(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 (*ProductClient) GetProduct
func(c*ProductClient)GetProduct(ctxcontext.Context,req*retailpb.GetProductRequest,opts...gax.CallOption)(*retailpb.Product,error)GetProduct gets a Product.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.GetProductRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#GetProductRequest.}resp,err:=c.GetProduct(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ProductClient) ImportProducts
func(c*ProductClient)ImportProducts(ctxcontext.Context,req*retailpb.ImportProductsRequest,opts...gax.CallOption)(*ImportProductsOperation,error)ImportProducts bulk import of multiple Products.
Request processing may be synchronous.Non-existing items are created.
Note that it is possible for a subset of theProducts to be successfully updated.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ImportProductsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ImportProductsRequest.}op,err:=c.ImportProducts(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ProductClient) ImportProductsOperation
func(c*ProductClient)ImportProductsOperation(namestring)*ImportProductsOperationImportProductsOperation returns a new ImportProductsOperation from a given name.The name must be that of a previously created ImportProductsOperation, possibly from a different process.
func (*ProductClient) ListOperations
func(c*ProductClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*ProductClient) ListProducts
func(c*ProductClient)ListProducts(ctxcontext.Context,req*retailpb.ListProductsRequest,opts...gax.CallOption)*ProductIteratorListProducts gets a list of Products.
Examples
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb""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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListProductsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#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.(*retailpb.ListProductsResponse)}}all
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListProductsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#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 (*ProductClient) PurgeProducts
func(c*ProductClient)PurgeProducts(ctxcontext.Context,req*retailpb.PurgeProductsRequest,opts...gax.CallOption)(*PurgeProductsOperation,error)PurgeProducts permanently deletes all selected Productsunder a branch.
This process is asynchronous. If the request is valid, the removal will beenqueued and processed offline. Depending on the number ofProducts, this operation could take hoursto complete. Before the operation completes, someProducts may still be returned byProductService.GetProductorProductService.ListProducts.
Depending on the number of Products, thisoperation could take hours to complete. To get a sample ofProducts that would be deleted, setPurgeProductsRequest.forceto false.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.PurgeProductsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#PurgeProductsRequest.}op,err:=c.PurgeProducts(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ProductClient) PurgeProductsOperation
func(c*ProductClient)PurgeProductsOperation(namestring)*PurgeProductsOperationPurgeProductsOperation returns a new PurgeProductsOperation from a given name.The name must be that of a previously created PurgeProductsOperation, possibly from a different process.
func (*ProductClient) RemoveFulfillmentPlaces
func(c*ProductClient)RemoveFulfillmentPlaces(ctxcontext.Context,req*retailpb.RemoveFulfillmentPlacesRequest,opts...gax.CallOption)(*RemoveFulfillmentPlacesOperation,error)RemoveFulfillmentPlaces we recommend that you use theProductService.RemoveLocalInventoriesmethod instead of theProductService.RemoveFulfillmentPlacesmethod.ProductService.RemoveLocalInventoriesachieves the same results but provides more fine-grained control overingesting local inventory data.
Incrementally removes place IDs from aProduct.fulfillment_info.place_ids.
This process is asynchronous and does not require theProduct to exist before updatingfulfillment information. If the request is valid, the update will beenqueued and processed downstream. As a consequence, when a response isreturned, the removed place IDs are not immediately manifested in theProduct queried byProductService.GetProductorProductService.ListProducts.
The returned Operations will be obsoleteafter 1 day, and GetOperationAPI will return NOT_FOUND afterwards.
If conflicting updates are issued, theOperations associated with the staleupdates will not be marked as doneuntil being obsolete.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.RemoveFulfillmentPlacesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#RemoveFulfillmentPlacesRequest.}op,err:=c.RemoveFulfillmentPlaces(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ProductClient) RemoveFulfillmentPlacesOperation
func(c*ProductClient)RemoveFulfillmentPlacesOperation(namestring)*RemoveFulfillmentPlacesOperationRemoveFulfillmentPlacesOperation returns a new RemoveFulfillmentPlacesOperation from a given name.The name must be that of a previously created RemoveFulfillmentPlacesOperation, possibly from a different process.
func (*ProductClient) RemoveLocalInventories
func(c*ProductClient)RemoveLocalInventories(ctxcontext.Context,req*retailpb.RemoveLocalInventoriesRequest,opts...gax.CallOption)(*RemoveLocalInventoriesOperation,error)RemoveLocalInventories remove local inventory information for aProduct at a list of places at a removaltimestamp.
This process is asynchronous. If the request is valid, the removal will beenqueued and processed downstream. As a consequence, when a response isreturned, removals are not immediately manifested in theProduct queried byProductService.GetProductorProductService.ListProducts.
Local inventory information can only be removed using this method.ProductService.CreateProductandProductService.UpdateProducthas no effect on local inventories.
The returned Operations will be obsoleteafter 1 day, and GetOperationAPI will return NOT_FOUND afterwards.
If conflicting updates are issued, theOperations associated with the staleupdates will not be marked as doneuntil being obsolete.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.RemoveLocalInventoriesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#RemoveLocalInventoriesRequest.}op,err:=c.RemoveLocalInventories(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ProductClient) RemoveLocalInventoriesOperation
func(c*ProductClient)RemoveLocalInventoriesOperation(namestring)*RemoveLocalInventoriesOperationRemoveLocalInventoriesOperation returns a new RemoveLocalInventoriesOperation from a given name.The name must be that of a previously created RemoveLocalInventoriesOperation, possibly from a different process.
func (*ProductClient) SetInventory
func(c*ProductClient)SetInventory(ctxcontext.Context,req*retailpb.SetInventoryRequest,opts...gax.CallOption)(*SetInventoryOperation,error)SetInventory updates inventory information for aProduct while respecting the last updatetimestamps of each inventory field.
This process is asynchronous and does not require theProduct to exist before updatingfulfillment information. If the request is valid, the update is enqueuedand processed downstream. As a consequence, when a response is returned,updates are not immediately manifested in theProduct queried byProductService.GetProductorProductService.ListProducts.
When inventory is updated withProductService.CreateProductandProductService.UpdateProduct,the specified inventory field value(s) overwrite any existing value(s)while ignoring the last update time for this field. Furthermore, the lastupdate times for the specified inventory fields are overwritten by thetimes of theProductService.CreateProductorProductService.UpdateProductrequest.
If no inventory fields are set inCreateProductRequest.product,then any pre-existing inventory information for this product is used.
If no inventory fields are set inSetInventoryRequest.set_mask,then any existing inventory information is preserved.
Pre-existing inventory information can only be updated withProductService.SetInventory,ProductService.AddFulfillmentPlaces,andProductService.RemoveFulfillmentPlaces.
The returned Operations is obsolete afterone day, and the GetOperationAPI returns NOT_FOUND afterwards.
If conflicting updates are issued, theOperations associated with the staleupdates are not marked as done untilthey are obsolete.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.SetInventoryRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#SetInventoryRequest.}op,err:=c.SetInventory(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ProductClient) SetInventoryOperation
func(c*ProductClient)SetInventoryOperation(namestring)*SetInventoryOperationSetInventoryOperation returns a new SetInventoryOperation from a given name.The name must be that of a previously created SetInventoryOperation, possibly from a different process.
func (*ProductClient) UpdateProduct
func(c*ProductClient)UpdateProduct(ctxcontext.Context,req*retailpb.UpdateProductRequest,opts...gax.CallOption)(*retailpb.Product,error)UpdateProduct updates a Product.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewProductClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.UpdateProductRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#UpdateProductRequest.}resp,err:=c.UpdateProduct(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}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[]*retailpb.Product,nextPageTokenstring,errerror)// contains filtered or unexported fields}ProductIterator manages a stream of *retailpb.Product.
func (*ProductIterator) All
func(it*ProductIterator)All()iter.Seq2[*retailpb.Product,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*ProductIterator) Next
func(it*ProductIterator)Next()(*retailpb.Product,error)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.PageInfoPageInfo 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
func(op*PurgeProductsOperation)Done()boolDone reports whether the long-running operation has completed.
func (*PurgeProductsOperation) Metadata
func(op*PurgeProductsOperation)Metadata()(*retailpb.PurgeProductsMetadata,error)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
func(op*PurgeProductsOperation)Name()stringName 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
func(op*PurgeProductsOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.PurgeProductsResponse,error)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
func(op*PurgeProductsOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.PurgeProductsResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
PurgeUserEventsOperation
typePurgeUserEventsOperationstruct{// contains filtered or unexported fields}PurgeUserEventsOperation manages a long-running operation from PurgeUserEvents.
func (*PurgeUserEventsOperation) Done
func(op*PurgeUserEventsOperation)Done()boolDone reports whether the long-running operation has completed.
func (*PurgeUserEventsOperation) Metadata
func(op*PurgeUserEventsOperation)Metadata()(*retailpb.PurgeMetadata,error)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 (*PurgeUserEventsOperation) Name
func(op*PurgeUserEventsOperation)Name()stringName 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 (*PurgeUserEventsOperation) Poll
func(op*PurgeUserEventsOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.PurgeUserEventsResponse,error)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 (*PurgeUserEventsOperation) Wait
func(op*PurgeUserEventsOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.PurgeUserEventsResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
RejoinUserEventsOperation
typeRejoinUserEventsOperationstruct{// contains filtered or unexported fields}RejoinUserEventsOperation manages a long-running operation from RejoinUserEvents.
func (*RejoinUserEventsOperation) Done
func(op*RejoinUserEventsOperation)Done()boolDone reports whether the long-running operation has completed.
func (*RejoinUserEventsOperation) Metadata
func(op*RejoinUserEventsOperation)Metadata()(*retailpb.RejoinUserEventsMetadata,error)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 (*RejoinUserEventsOperation) Name
func(op*RejoinUserEventsOperation)Name()stringName 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 (*RejoinUserEventsOperation) Poll
func(op*RejoinUserEventsOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.RejoinUserEventsResponse,error)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 (*RejoinUserEventsOperation) Wait
func(op*RejoinUserEventsOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.RejoinUserEventsResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
RemoveFulfillmentPlacesOperation
typeRemoveFulfillmentPlacesOperationstruct{// contains filtered or unexported fields}RemoveFulfillmentPlacesOperation manages a long-running operation from RemoveFulfillmentPlaces.
func (*RemoveFulfillmentPlacesOperation) Done
func(op*RemoveFulfillmentPlacesOperation)Done()boolDone reports whether the long-running operation has completed.
func (*RemoveFulfillmentPlacesOperation) Metadata
func(op*RemoveFulfillmentPlacesOperation)Metadata()(*retailpb.RemoveFulfillmentPlacesMetadata,error)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 (*RemoveFulfillmentPlacesOperation) Name
func(op*RemoveFulfillmentPlacesOperation)Name()stringName 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 (*RemoveFulfillmentPlacesOperation) Poll
func(op*RemoveFulfillmentPlacesOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.RemoveFulfillmentPlacesResponse,error)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 (*RemoveFulfillmentPlacesOperation) Wait
func(op*RemoveFulfillmentPlacesOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.RemoveFulfillmentPlacesResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
RemoveLocalInventoriesOperation
typeRemoveLocalInventoriesOperationstruct{// contains filtered or unexported fields}RemoveLocalInventoriesOperation manages a long-running operation from RemoveLocalInventories.
func (*RemoveLocalInventoriesOperation) Done
func(op*RemoveLocalInventoriesOperation)Done()boolDone reports whether the long-running operation has completed.
func (*RemoveLocalInventoriesOperation) Metadata
func(op*RemoveLocalInventoriesOperation)Metadata()(*retailpb.RemoveLocalInventoriesMetadata,error)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 (*RemoveLocalInventoriesOperation) Name
func(op*RemoveLocalInventoriesOperation)Name()stringName 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 (*RemoveLocalInventoriesOperation) Poll
func(op*RemoveLocalInventoriesOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.RemoveLocalInventoriesResponse,error)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 (*RemoveLocalInventoriesOperation) Wait
func(op*RemoveLocalInventoriesOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.RemoveLocalInventoriesResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
SearchCallOptions
typeSearchCallOptionsstruct{Search[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}SearchCallOptions contains the retry settings for each method of SearchClient.
SearchClient
typeSearchClientstruct{// The call options for this service.CallOptions*SearchCallOptions// contains filtered or unexported fields}SearchClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for search.
This feature is only available for users who have Retail Search enabled.Enable Retail Search on Cloud Console before using this feature.
func NewSearchClient
funcNewSearchClient(ctxcontext.Context,opts...option.ClientOption)(*SearchClient,error)NewSearchClient creates a new search service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for search.
This feature is only available for users who have Retail Search enabled.Enable Retail Search on Cloud Console before using this feature.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewSearchRESTClient
funcNewSearchRESTClient(ctxcontext.Context,opts...option.ClientOption)(*SearchClient,error)NewSearchRESTClient creates a new search service rest client.
Service for search.
This feature is only available for users who have Retail Search enabled.Enable Retail Search on Cloud Console before using this feature.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewSearchRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*SearchClient) Close
func(c*SearchClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*SearchClient) Connection (deprecated)
func(c*SearchClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*SearchClient) GetOperation
func(c*SearchClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewSearchClient(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 (*SearchClient) ListOperations
func(c*SearchClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*SearchClient) Search
func(c*SearchClient)Search(ctxcontext.Context,req*retailpb.SearchRequest,opts...gax.CallOption)*SearchResponse_SearchResultIteratorSearch performs a search.
This feature is only available for users who have Retail Search enabled.Enable Retail Search on Cloud Console before using this feature.
Examples
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb""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:=retail.NewSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.SearchRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#SearchRequest.}it:=c.Search(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.(*retailpb.SearchResponse)}}all
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewSearchClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.SearchRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#SearchRequest.}forresp,err:=rangec.Search(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}SearchResponse_SearchResultIterator
typeSearchResponse_SearchResultIteratorstruct{// 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[]*retailpb.SearchResponse_SearchResult,nextPageTokenstring,errerror)// contains filtered or unexported fields}SearchResponse_SearchResultIterator manages a stream of *retailpb.SearchResponse_SearchResult.
func (*SearchResponse_SearchResultIterator) All
func(it*SearchResponse_SearchResultIterator)All()iter.Seq2[*retailpb.SearchResponse_SearchResult,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*SearchResponse_SearchResultIterator) Next
func(it*SearchResponse_SearchResultIterator)Next()(*retailpb.SearchResponse_SearchResult,error)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 (*SearchResponse_SearchResultIterator) PageInfo
func(it*SearchResponse_SearchResultIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ServingConfigCallOptions
typeServingConfigCallOptionsstruct{CreateServingConfig[]gax.CallOptionDeleteServingConfig[]gax.CallOptionUpdateServingConfig[]gax.CallOptionGetServingConfig[]gax.CallOptionListServingConfigs[]gax.CallOptionAddControl[]gax.CallOptionRemoveControl[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}ServingConfigCallOptions contains the retry settings for each method of ServingConfigClient.
ServingConfigClient
typeServingConfigClientstruct{// The call options for this service.CallOptions*ServingConfigCallOptions// contains filtered or unexported fields}ServingConfigClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for modifying ServingConfig.
func NewServingConfigClient
funcNewServingConfigClient(ctxcontext.Context,opts...option.ClientOption)(*ServingConfigClient,error)NewServingConfigClient creates a new serving config service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for modifying ServingConfig.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewServingConfigRESTClient
funcNewServingConfigRESTClient(ctxcontext.Context,opts...option.ClientOption)(*ServingConfigClient,error)NewServingConfigRESTClient creates a new serving config service rest client.
Service for modifying ServingConfig.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewServingConfigRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*ServingConfigClient) AddControl
func(c*ServingConfigClient)AddControl(ctxcontext.Context,req*retailpb.AddControlRequest,opts...gax.CallOption)(*retailpb.ServingConfig,error)AddControl enables a Control on the specified ServingConfig.The control is added in the last position of the list of controlsit belongs to (e.g. if it’s a facet spec control it will be appliedin the last position of servingConfig.facetSpecIds)Returns a ALREADY_EXISTS error if the control has already been applied.Returns a FAILED_PRECONDITION error if the addition could exceed maximumnumber of control allowed for that type of control.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.AddControlRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#AddControlRequest.}resp,err:=c.AddControl(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ServingConfigClient) Close
func(c*ServingConfigClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*ServingConfigClient) Connection (deprecated)
func(c*ServingConfigClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*ServingConfigClient) CreateServingConfig
func(c*ServingConfigClient)CreateServingConfig(ctxcontext.Context,req*retailpb.CreateServingConfigRequest,opts...gax.CallOption)(*retailpb.ServingConfig,error)CreateServingConfig creates a ServingConfig.
A maximum of 100 ServingConfigs areallowed in a Catalog, otherwise aFAILED_PRECONDITION error is returned.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.CreateServingConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#CreateServingConfigRequest.}resp,err:=c.CreateServingConfig(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ServingConfigClient) DeleteServingConfig
func(c*ServingConfigClient)DeleteServingConfig(ctxcontext.Context,req*retailpb.DeleteServingConfigRequest,opts...gax.CallOption)errorDeleteServingConfig deletes a ServingConfig.
Returns a NotFound error if the ServingConfig does not exist.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.DeleteServingConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#DeleteServingConfigRequest.}err=c.DeleteServingConfig(ctx,req)iferr!=nil{// TODO: Handle error.}}func (*ServingConfigClient) GetOperation
func(c*ServingConfigClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewServingConfigClient(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 (*ServingConfigClient) GetServingConfig
func(c*ServingConfigClient)GetServingConfig(ctxcontext.Context,req*retailpb.GetServingConfigRequest,opts...gax.CallOption)(*retailpb.ServingConfig,error)GetServingConfig gets a ServingConfig.
Returns a NotFound error if the ServingConfig does not exist.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.GetServingConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#GetServingConfigRequest.}resp,err:=c.GetServingConfig(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ServingConfigClient) ListOperations
func(c*ServingConfigClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*ServingConfigClient) ListServingConfigs
func(c*ServingConfigClient)ListServingConfigs(ctxcontext.Context,req*retailpb.ListServingConfigsRequest,opts...gax.CallOption)*ServingConfigIteratorListServingConfigs lists all ServingConfigs linked to this catalog.
Examples
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb""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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListServingConfigsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ListServingConfigsRequest.}it:=c.ListServingConfigs(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.(*retailpb.ListServingConfigsResponse)}}all
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ListServingConfigsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ListServingConfigsRequest.}forresp,err:=rangec.ListServingConfigs(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*ServingConfigClient) RemoveControl
func(c*ServingConfigClient)RemoveControl(ctxcontext.Context,req*retailpb.RemoveControlRequest,opts...gax.CallOption)(*retailpb.ServingConfig,error)RemoveControl disables a Control on the specified ServingConfig.The control is removed from the ServingConfig.Returns a NOT_FOUND error if the Control is not enabled for theServingConfig.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.RemoveControlRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#RemoveControlRequest.}resp,err:=c.RemoveControl(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ServingConfigClient) UpdateServingConfig
func(c*ServingConfigClient)UpdateServingConfig(ctxcontext.Context,req*retailpb.UpdateServingConfigRequest,opts...gax.CallOption)(*retailpb.ServingConfig,error)UpdateServingConfig updates a ServingConfig.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewServingConfigClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.UpdateServingConfigRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#UpdateServingConfigRequest.}resp,err:=c.UpdateServingConfig(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}ServingConfigIterator
typeServingConfigIteratorstruct{// 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[]*retailpb.ServingConfig,nextPageTokenstring,errerror)// contains filtered or unexported fields}ServingConfigIterator manages a stream of *retailpb.ServingConfig.
func (*ServingConfigIterator) All
func(it*ServingConfigIterator)All()iter.Seq2[*retailpb.ServingConfig,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*ServingConfigIterator) Next
func(it*ServingConfigIterator)Next()(*retailpb.ServingConfig,error)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 (*ServingConfigIterator) PageInfo
func(it*ServingConfigIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
SetInventoryOperation
typeSetInventoryOperationstruct{// contains filtered or unexported fields}SetInventoryOperation manages a long-running operation from SetInventory.
func (*SetInventoryOperation) Done
func(op*SetInventoryOperation)Done()boolDone reports whether the long-running operation has completed.
func (*SetInventoryOperation) Metadata
func(op*SetInventoryOperation)Metadata()(*retailpb.SetInventoryMetadata,error)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 (*SetInventoryOperation) Name
func(op*SetInventoryOperation)Name()stringName 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 (*SetInventoryOperation) Poll
func(op*SetInventoryOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.SetInventoryResponse,error)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 (*SetInventoryOperation) Wait
func(op*SetInventoryOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.SetInventoryResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
TuneModelOperation
typeTuneModelOperationstruct{// contains filtered or unexported fields}TuneModelOperation manages a long-running operation from TuneModel.
func (*TuneModelOperation) Done
func(op*TuneModelOperation)Done()boolDone reports whether the long-running operation has completed.
func (*TuneModelOperation) Metadata
func(op*TuneModelOperation)Metadata()(*retailpb.TuneModelMetadata,error)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 (*TuneModelOperation) Name
func(op*TuneModelOperation)Name()stringName 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 (*TuneModelOperation) Poll
func(op*TuneModelOperation)Poll(ctxcontext.Context,opts...gax.CallOption)(*retailpb.TuneModelResponse,error)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 (*TuneModelOperation) Wait
func(op*TuneModelOperation)Wait(ctxcontext.Context,opts...gax.CallOption)(*retailpb.TuneModelResponse,error)Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
UserEventCallOptions
typeUserEventCallOptionsstruct{WriteUserEvent[]gax.CallOptionCollectUserEvent[]gax.CallOptionPurgeUserEvents[]gax.CallOptionImportUserEvents[]gax.CallOptionRejoinUserEvents[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}UserEventCallOptions contains the retry settings for each method of UserEventClient.
UserEventClient
typeUserEventClientstruct{// The call options for this service.CallOptions*UserEventCallOptions// 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}UserEventClient is a client for interacting with Vertex AI Search for commerce API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for ingesting end user actions on the customer website.
func NewUserEventClient
funcNewUserEventClient(ctxcontext.Context,opts...option.ClientOption)(*UserEventClient,error)NewUserEventClient creates a new user event service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for ingesting end user actions on the customer website.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewUserEventClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewUserEventRESTClient
funcNewUserEventRESTClient(ctxcontext.Context,opts...option.ClientOption)(*UserEventClient,error)NewUserEventRESTClient creates a new user event service rest client.
Service for ingesting end user actions on the customer website.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewUserEventRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*UserEventClient) Close
func(c*UserEventClient)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*UserEventClient) CollectUserEvent
func(c*UserEventClient)CollectUserEvent(ctxcontext.Context,req*retailpb.CollectUserEventRequest,opts...gax.CallOption)(*httpbodypb.HttpBody,error)CollectUserEvent writes a single user event from the browser.
For larger user event payload over 16 KB, the POST method should be usedinstead, otherwise a 400 Bad Request error is returned.
This method is used only by the Retail API JavaScript pixel and Google TagManager. Users should not call this method directly.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewUserEventClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.CollectUserEventRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#CollectUserEventRequest.}resp,err:=c.CollectUserEvent(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*UserEventClient) Connection (deprecated)
func(c*UserEventClient)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*UserEventClient) GetOperation
func(c*UserEventClient)GetOperation(ctxcontext.Context,req*longrunningpb.GetOperationRequest,opts...gax.CallOption)(*longrunningpb.Operation,error)GetOperation is a utility method from google.longrunning.Operations.
Example
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewUserEventClient(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 (*UserEventClient) ImportUserEvents
func(c*UserEventClient)ImportUserEvents(ctxcontext.Context,req*retailpb.ImportUserEventsRequest,opts...gax.CallOption)(*ImportUserEventsOperation,error)ImportUserEvents bulk import of User events. Request processing might besynchronous. Events that already exist are skipped.Use this method for backfilling historical user events.
Operation.response is of type ImportResponse. Note that it ispossible for a subset of the items to be successfully inserted.Operation.metadata is of type ImportMetadata.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewUserEventClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.ImportUserEventsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#ImportUserEventsRequest.}op,err:=c.ImportUserEvents(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*UserEventClient) ImportUserEventsOperation
func(c*UserEventClient)ImportUserEventsOperation(namestring)*ImportUserEventsOperationImportUserEventsOperation returns a new ImportUserEventsOperation from a given name.The name must be that of a previously created ImportUserEventsOperation, possibly from a different process.
func (*UserEventClient) ListOperations
func(c*UserEventClient)ListOperations(ctxcontext.Context,req*longrunningpb.ListOperationsRequest,opts...gax.CallOption)*OperationIteratorListOperations is a utility method from google.longrunning.Operations.
Examples
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2""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:=retail.NewUserEventClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(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.(*longrunningpb.ListOperationsResponse)}}all
packagemainimport("context"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb"retail"cloud.google.com/go/retail/apiv2")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:=retail.NewUserEventClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*UserEventClient) PurgeUserEvents
func(c*UserEventClient)PurgeUserEvents(ctxcontext.Context,req*retailpb.PurgeUserEventsRequest,opts...gax.CallOption)(*PurgeUserEventsOperation,error)PurgeUserEvents deletes permanently all user events specified by the filter provided.Depending on the number of events specified by the filter, this operationcould take hours or days to complete. To test a filter, use the listcommand first.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewUserEventClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.PurgeUserEventsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#PurgeUserEventsRequest.}op,err:=c.PurgeUserEvents(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*UserEventClient) PurgeUserEventsOperation
func(c*UserEventClient)PurgeUserEventsOperation(namestring)*PurgeUserEventsOperationPurgeUserEventsOperation returns a new PurgeUserEventsOperation from a given name.The name must be that of a previously created PurgeUserEventsOperation, possibly from a different process.
func (*UserEventClient) RejoinUserEvents
func(c*UserEventClient)RejoinUserEvents(ctxcontext.Context,req*retailpb.RejoinUserEventsRequest,opts...gax.CallOption)(*RejoinUserEventsOperation,error)RejoinUserEvents starts a user-event rejoin operation with latest product catalog. Eventsare not annotated with detailed product information for products that aremissing from the catalog when the user event is ingested. Theseevents are stored as unjoined events with limited usage on training andserving. You can use this method to start a join operation on specifiedevents with the latest version of product catalog. You can also use thismethod to correct events joined with the wrong product catalog. A rejoinoperation can take hours or days to complete.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewUserEventClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.RejoinUserEventsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#RejoinUserEventsRequest.}op,err:=c.RejoinUserEvents(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*UserEventClient) RejoinUserEventsOperation
func(c*UserEventClient)RejoinUserEventsOperation(namestring)*RejoinUserEventsOperationRejoinUserEventsOperation returns a new RejoinUserEventsOperation from a given name.The name must be that of a previously created RejoinUserEventsOperation, possibly from a different process.
func (*UserEventClient) WriteUserEvent
func(c*UserEventClient)WriteUserEvent(ctxcontext.Context,req*retailpb.WriteUserEventRequest,opts...gax.CallOption)(*retailpb.UserEvent,error)WriteUserEvent writes a single user event.
Example
packagemainimport("context"retail"cloud.google.com/go/retail/apiv2"retailpb"cloud.google.com/go/retail/apiv2/retailpb")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:=retail.NewUserEventClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&retailpb.WriteUserEventRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/retail/apiv2/retailpb#WriteUserEventRequest.}resp,err:=c.WriteUserEvent(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}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.