Retail API v2 - Package cloud.google.com/go/retail/apiv2 (v0.86.0)

Package retail is an auto-generated package for the Retail API.

Cloud Retail service enables customers to build end-to-end personalized recommendation systems without requiring a high level of expertise in machine learning, recommendation system, or Google Cloud.

Use of Context

The ctx passed to NewClient is used for authentication requests and for 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.

For information about setting deadlines, reusing contexts, and more please visit https://pkg.go.dev/cloud.google.com/go .

Functions

func DefaultAuthScopes

  func 
  
 DefaultAuthScopes 
 () 
  
 [] 
  string 
 
 

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

CatalogCallOptions

  type 
  
 CatalogCallOptions 
  
 struct 
  
 { 
  
 ListCatalogs 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateCatalog 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

CatalogCallOptions contains the retry settings for each method of CatalogClient.

CatalogClient

  type 
  
 CatalogClient 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  CatalogCallOptions 
 
  
 // contains filtered or unexported fields 
 } 
 

CatalogClient is a client for interacting with Retail 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

  func 
  
 NewCatalogClient 
 ( 
 ctx 
  
  context 
 
 . 
  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

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewCatalogClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*CatalogClient) Close

  func 
  
 ( 
 c 
  
 * 
  CatalogClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

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

func (*CatalogClient) Connection

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

Connection returns a connection to the API service.

Deprecated.

func (*CatalogClient) ListCatalogs

ListCatalogs lists all the Catalogs associated with the project.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 "google.golang.org/api/iterator" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewCatalogClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  ListCatalogsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListCatalogs 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 

func (*CatalogClient) UpdateCatalog

UpdateCatalog updates the Catalogs.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewCatalogClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  UpdateCatalogRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UpdateCatalog 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

CatalogIterator

  type 
  
 CatalogIterator 
  
 struct 
  
 { 
  
 // 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. 
  
 Response 
  
 interface 
 {} 
  
 // 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. 
  
 InternalFetch 
  
 func 
 ( 
 pageSize 
  
  int 
 
 , 
  
 pageToken 
  
  string 
 
 ) 
  
 ( 
 results 
  
 [] 
 * 
  retailpb 
 
 . 
  Catalog 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 

CatalogIterator manages a stream of *retailpb.Catalog.

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 more results. Once Next returns Done, all subsequent calls will return Done.

func (*CatalogIterator) PageInfo

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

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

ImportProductsOperation

  type 
  
 ImportProductsOperation 
  
 struct 
  
 { 
  
 // contains filtered or unexported fields 
 } 
 

ImportProductsOperation manages a long-running operation from ImportProducts.

func (*ImportProductsOperation) Done

  func 
  
 ( 
 op 
  
 * 
  ImportProductsOperation 
 
 ) 
  
 Done 
 () 
  
  bool 
 
 

Done reports whether the long-running operation has completed.

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

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

func (*ImportProductsOperation) Poll

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

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

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the 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

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

  type 
  
 ImportUserEventsOperation 
  
 struct 
  
 { 
  
 // contains filtered or unexported fields 
 } 
 

ImportUserEventsOperation manages a long-running operation from ImportUserEvents.

func (*ImportUserEventsOperation) Done

Done reports whether the long-running operation has completed.

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

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

func (*ImportUserEventsOperation) Poll

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

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

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the 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

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

See documentation of Poll for error-handling information.

PredictionCallOptions

  type 
  
 PredictionCallOptions 
  
 struct 
  
 { 
  
 Predict 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

PredictionCallOptions contains the retry settings for each method of PredictionClient.

PredictionClient

  type 
  
 PredictionClient 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  PredictionCallOptions 
 
  
 // contains filtered or unexported fields 
 } 
 

PredictionClient is a client for interacting with Retail 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

  func 
  
 NewPredictionClient 
 ( 
 ctx 
  
  context 
 
 . 
  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

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewPredictionClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*PredictionClient) Close

  func 
  
 ( 
 c 
  
 * 
  PredictionClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

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

func (*PredictionClient) Connection

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

Connection returns a connection to the API service.

Deprecated.

func (*PredictionClient) Predict

Predict makes a recommendation prediction.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewPredictionClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  PredictRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 Predict 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

ProductCallOptions

  type 
  
 ProductCallOptions 
  
 struct 
  
 { 
  
 CreateProduct 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetProduct 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateProduct 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 DeleteProduct 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ImportProducts 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

ProductCallOptions contains the retry settings for each method of ProductClient.

ProductClient

  type 
  
 ProductClient 
  
 struct 
  
 { 
  
 // 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 Retail API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Service for ingesting Product information of the customer’s website.

func NewProductClient

  func 
  
 NewProductClient 
 ( 
 ctx 
  
  context 
 
 . 
  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 information of the customer’s website.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewProductClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*ProductClient) Close

  func 
  
 ( 
 c 
  
 * 
  ProductClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

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

func (*ProductClient) Connection

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

Connection returns a connection to the API service.

Deprecated.

func (*ProductClient) CreateProduct

CreateProduct creates a Product.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewProductClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  CreateProductRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateProduct 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*ProductClient) DeleteProduct

DeleteProduct deletes a Product.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewProductClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  DeleteProductRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 err 
  
 = 
  
 c 
 . 
 DeleteProduct 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
 } 
 

func (*ProductClient) GetProduct

GetProduct gets a Product.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewProductClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  GetProductRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetProduct 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*ProductClient) ImportProducts

ImportProducts bulk import of multiple Products.

Request processing may be synchronous. No partial updating is supported. Non-existing items are created.

Note that it is possible for a subset of the Products to be successfully updated.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewProductClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  ImportProductsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 ImportProducts 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*ProductClient) ImportProductsOperation

  func 
  
 ( 
 c 
  
 * 
  ProductClient 
 
 ) 
  
 ImportProductsOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  ImportProductsOperation 
 
 

ImportProductsOperation 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) UpdateProduct

UpdateProduct updates a Product.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewProductClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  UpdateProductRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UpdateProduct 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

PurgeUserEventsOperation

  type 
  
 PurgeUserEventsOperation 
  
 struct 
  
 { 
  
 // contains filtered or unexported fields 
 } 
 

PurgeUserEventsOperation manages a long-running operation from PurgeUserEvents.

func (*PurgeUserEventsOperation) Done

Done reports whether the long-running operation has completed.

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

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

func (*PurgeUserEventsOperation) Poll

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

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

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the 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

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

  type 
  
 RejoinUserEventsOperation 
  
 struct 
  
 { 
  
 // contains filtered or unexported fields 
 } 
 

RejoinUserEventsOperation manages a long-running operation from RejoinUserEvents.

func (*RejoinUserEventsOperation) Done

Done reports whether the long-running operation has completed.

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

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

func (*RejoinUserEventsOperation) Poll

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

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

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the 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

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

  type 
  
 UserEventCallOptions 
  
 struct 
  
 { 
  
 WriteUserEvent 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 CollectUserEvent 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 PurgeUserEvents 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ImportUserEvents 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 RejoinUserEvents 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

UserEventCallOptions contains the retry settings for each method of UserEventClient.

UserEventClient

  type 
  
 UserEventClient 
  
 struct 
  
 { 
  
 // 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 Retail 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

  func 
  
 NewUserEventClient 
 ( 
 ctx 
  
  context 
 
 . 
  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

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewUserEventClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*UserEventClient) Close

  func 
  
 ( 
 c 
  
 * 
  UserEventClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

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

func (*UserEventClient) CollectUserEvent

CollectUserEvent writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain.

This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewUserEventClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  CollectUserEventRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CollectUserEvent 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*UserEventClient) Connection

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

Connection returns a connection to the API service.

Deprecated.

func (*UserEventClient) ImportUserEvents

ImportUserEvents bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events.

Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewUserEventClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  ImportUserEventsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 ImportUserEvents 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*UserEventClient) ImportUserEventsOperation

  func 
  
 ( 
 c 
  
 * 
  UserEventClient 
 
 ) 
  
 ImportUserEventsOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  ImportUserEventsOperation 
 
 

ImportUserEventsOperation 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) PurgeUserEvents

PurgeUserEvents deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewUserEventClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  PurgeUserEventsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 PurgeUserEvents 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*UserEventClient) PurgeUserEventsOperation

  func 
  
 ( 
 c 
  
 * 
  UserEventClient 
 
 ) 
  
 PurgeUserEventsOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  PurgeUserEventsOperation 
 
 

PurgeUserEventsOperation 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

RejoinUserEvents triggers a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This API can be used to trigger a ‘join’ operation on specified events with latest version of product catalog. It can also be used to correct events joined with wrong product catalog.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewUserEventClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  RejoinUserEventsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 RejoinUserEvents 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*UserEventClient) RejoinUserEventsOperation

  func 
  
 ( 
 c 
  
 * 
  UserEventClient 
 
 ) 
  
 RejoinUserEventsOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  RejoinUserEventsOperation 
 
 

RejoinUserEventsOperation 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

WriteUserEvent writes a single user event.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 retail 
  
 "cloud.google.com/go/retail/apiv2" 
  
 retailpb 
  
 "google.golang.org/genproto/googleapis/cloud/retail/v2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 retail 
 . 
  NewUserEventClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& retailpb 
 . 
  WriteUserEventRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 WriteUserEvent 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 
Create a Mobile Website
View Site in Mobile | Classic
Share by: