Documentation ¶
Overview ¶
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.
Example usage ¶
To get started with this package, create a client.
ctx := context.Background() c, err := retail.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.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.
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#ListCatalogsRequest. } 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 }
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.
Index ¶
- func DefaultAuthScopes() []string
- type AddFulfillmentPlacesOperation
- func (op *AddFulfillmentPlacesOperation) Done() bool
- func (op *AddFulfillmentPlacesOperation) Metadata() (*retailpb.AddFulfillmentPlacesMetadata, error)
- func (op *AddFulfillmentPlacesOperation) Name() string
- func (op *AddFulfillmentPlacesOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*retailpb.AddFulfillmentPlacesResponse, error)
- func (op *AddFulfillmentPlacesOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*retailpb.AddFulfillmentPlacesResponse, error)
- type AddLocalInventoriesOperation
- func (op *AddLocalInventoriesOperation) Done() bool
- func (op *AddLocalInventoriesOperation) Metadata() (*retailpb.AddLocalInventoriesMetadata, error)
- func (op *AddLocalInventoriesOperation) Name() string
- func (op *AddLocalInventoriesOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*retailpb.AddLocalInventoriesResponse, error)
- func (op *AddLocalInventoriesOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*retailpb.AddLocalInventoriesResponse, error)
- type CatalogCallOptions
- type CatalogClient
- func (c *CatalogClient) Close() error
- func (c *CatalogClient) Connection() *grpc.ClientConn
- func (c *CatalogClient) GetDefaultBranch(ctx context.Context, req *retailpb.GetDefaultBranchRequest, ...) (*retailpb.GetDefaultBranchResponse, error)
- func (c *CatalogClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, ...) (*longrunningpb.Operation, error)
- func (c *CatalogClient) ListCatalogs(ctx context.Context, req *retailpb.ListCatalogsRequest, opts ...gax.CallOption) *CatalogIterator
- func (c *CatalogClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, ...) *OperationIterator
- func (c *CatalogClient) SetDefaultBranch(ctx context.Context, req *retailpb.SetDefaultBranchRequest, ...) error
- func (c *CatalogClient) UpdateCatalog(ctx context.Context, req *retailpb.UpdateCatalogRequest, ...) (*retailpb.Catalog, error)
- type CatalogIterator
- type CompletionCallOptions
- type CompletionClient
- func (c *CompletionClient) Close() error
- func (c *CompletionClient) CompleteQuery(ctx context.Context, req *retailpb.CompleteQueryRequest, ...) (*retailpb.CompleteQueryResponse, error)
- func (c *CompletionClient) Connection() *grpc.ClientConn
- func (c *CompletionClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, ...) (*longrunningpb.Operation, error)
- func (c *CompletionClient) ImportCompletionData(ctx context.Context, req *retailpb.ImportCompletionDataRequest, ...) (*ImportCompletionDataOperation, error)
- func (c *CompletionClient) ImportCompletionDataOperation(name string) *ImportCompletionDataOperation
- func (c *CompletionClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, ...) *OperationIterator
- type ImportCompletionDataOperation
- func (op *ImportCompletionDataOperation) Done() bool
- func (op *ImportCompletionDataOperation) Metadata() (*retailpb.ImportMetadata, error)
- func (op *ImportCompletionDataOperation) Name() string
- func (op *ImportCompletionDataOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*retailpb.ImportCompletionDataResponse, error)
- func (op *ImportCompletionDataOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*retailpb.ImportCompletionDataResponse, error)
- type ImportProductsOperation
- func (op *ImportProductsOperation) Done() bool
- func (op *ImportProductsOperation) Metadata() (*retailpb.ImportMetadata, error)
- func (op *ImportProductsOperation) Name() string
- func (op *ImportProductsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*retailpb.ImportProductsResponse, error)
- func (op *ImportProductsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*retailpb.ImportProductsResponse, error)
- type ImportUserEventsOperation
- func (op *ImportUserEventsOperation) Done() bool
- func (op *ImportUserEventsOperation) Metadata() (*retailpb.ImportMetadata, error)
- func (op *ImportUserEventsOperation) Name() string
- func (op *ImportUserEventsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*retailpb.ImportUserEventsResponse, error)
- func (op *ImportUserEventsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*retailpb.ImportUserEventsResponse, error)
- type OperationIterator
- type PredictionCallOptions
- type PredictionClient
- func (c *PredictionClient) Close() error
- func (c *PredictionClient) Connection() *grpc.ClientConn
- func (c *PredictionClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, ...) (*longrunningpb.Operation, error)
- func (c *PredictionClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, ...) *OperationIterator
- func (c *PredictionClient) Predict(ctx context.Context, req *retailpb.PredictRequest, opts ...gax.CallOption) (*retailpb.PredictResponse, error)
- type ProductCallOptions
- type ProductClient
- func (c *ProductClient) AddFulfillmentPlaces(ctx context.Context, req *retailpb.AddFulfillmentPlacesRequest, ...) (*AddFulfillmentPlacesOperation, error)
- func (c *ProductClient) AddFulfillmentPlacesOperation(name string) *AddFulfillmentPlacesOperation
- func (c *ProductClient) AddLocalInventories(ctx context.Context, req *retailpb.AddLocalInventoriesRequest, ...) (*AddLocalInventoriesOperation, error)
- func (c *ProductClient) AddLocalInventoriesOperation(name string) *AddLocalInventoriesOperation
- func (c *ProductClient) Close() error
- func (c *ProductClient) Connection() *grpc.ClientConn
- func (c *ProductClient) CreateProduct(ctx context.Context, req *retailpb.CreateProductRequest, ...) (*retailpb.Product, error)
- func (c *ProductClient) DeleteProduct(ctx context.Context, req *retailpb.DeleteProductRequest, ...) error
- func (c *ProductClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, ...) (*longrunningpb.Operation, error)
- func (c *ProductClient) GetProduct(ctx context.Context, req *retailpb.GetProductRequest, opts ...gax.CallOption) (*retailpb.Product, error)
- func (c *ProductClient) ImportProducts(ctx context.Context, req *retailpb.ImportProductsRequest, ...) (*ImportProductsOperation, error)
- func (c *ProductClient) ImportProductsOperation(name string) *ImportProductsOperation
- func (c *ProductClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, ...) *OperationIterator
- func (c *ProductClient) ListProducts(ctx context.Context, req *retailpb.ListProductsRequest, opts ...gax.CallOption) *ProductIterator
- func (c *ProductClient) RemoveFulfillmentPlaces(ctx context.Context, req *retailpb.RemoveFulfillmentPlacesRequest, ...) (*RemoveFulfillmentPlacesOperation, error)
- func (c *ProductClient) RemoveFulfillmentPlacesOperation(name string) *RemoveFulfillmentPlacesOperation
- func (c *ProductClient) RemoveLocalInventories(ctx context.Context, req *retailpb.RemoveLocalInventoriesRequest, ...) (*RemoveLocalInventoriesOperation, error)
- func (c *ProductClient) RemoveLocalInventoriesOperation(name string) *RemoveLocalInventoriesOperation
- func (c *ProductClient) SetInventory(ctx context.Context, req *retailpb.SetInventoryRequest, opts ...gax.CallOption) (*SetInventoryOperation, error)
- func (c *ProductClient) SetInventoryOperation(name string) *SetInventoryOperation
- func (c *ProductClient) UpdateProduct(ctx context.Context, req *retailpb.UpdateProductRequest, ...) (*retailpb.Product, error)
- type ProductIterator
- type PurgeUserEventsOperation
- func (op *PurgeUserEventsOperation) Done() bool
- func (op *PurgeUserEventsOperation) Metadata() (*retailpb.PurgeMetadata, error)
- func (op *PurgeUserEventsOperation) Name() string
- func (op *PurgeUserEventsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*retailpb.PurgeUserEventsResponse, error)
- func (op *PurgeUserEventsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*retailpb.PurgeUserEventsResponse, error)
- type RejoinUserEventsOperation
- func (op *RejoinUserEventsOperation) Done() bool
- func (op *RejoinUserEventsOperation) Metadata() (*retailpb.RejoinUserEventsMetadata, error)
- func (op *RejoinUserEventsOperation) Name() string
- func (op *RejoinUserEventsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*retailpb.RejoinUserEventsResponse, error)
- func (op *RejoinUserEventsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*retailpb.RejoinUserEventsResponse, error)
- type RemoveFulfillmentPlacesOperation
- func (op *RemoveFulfillmentPlacesOperation) Done() bool
- func (op *RemoveFulfillmentPlacesOperation) Metadata() (*retailpb.RemoveFulfillmentPlacesMetadata, error)
- func (op *RemoveFulfillmentPlacesOperation) Name() string
- func (op *RemoveFulfillmentPlacesOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*retailpb.RemoveFulfillmentPlacesResponse, error)
- func (op *RemoveFulfillmentPlacesOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*retailpb.RemoveFulfillmentPlacesResponse, error)
- type RemoveLocalInventoriesOperation
- func (op *RemoveLocalInventoriesOperation) Done() bool
- func (op *RemoveLocalInventoriesOperation) Metadata() (*retailpb.RemoveLocalInventoriesMetadata, error)
- func (op *RemoveLocalInventoriesOperation) Name() string
- func (op *RemoveLocalInventoriesOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*retailpb.RemoveLocalInventoriesResponse, error)
- func (op *RemoveLocalInventoriesOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*retailpb.RemoveLocalInventoriesResponse, error)
- type SearchCallOptions
- type SearchClient
- func (c *SearchClient) Close() error
- func (c *SearchClient) Connection() *grpc.ClientConn
- func (c *SearchClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, ...) (*longrunningpb.Operation, error)
- func (c *SearchClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, ...) *OperationIterator
- func (c *SearchClient) Search(ctx context.Context, req *retailpb.SearchRequest, opts ...gax.CallOption) *SearchResponse_SearchResultIterator
- type SearchResponse_SearchResultIterator
- type SetInventoryOperation
- func (op *SetInventoryOperation) Done() bool
- func (op *SetInventoryOperation) Metadata() (*retailpb.SetInventoryMetadata, error)
- func (op *SetInventoryOperation) Name() string
- func (op *SetInventoryOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*retailpb.SetInventoryResponse, error)
- func (op *SetInventoryOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*retailpb.SetInventoryResponse, error)
- type UserEventCallOptions
- type UserEventClient
- func (c *UserEventClient) Close() error
- func (c *UserEventClient) CollectUserEvent(ctx context.Context, req *retailpb.CollectUserEventRequest, ...) (*httpbodypb.HttpBody, error)
- func (c *UserEventClient) Connection() *grpc.ClientConn
- func (c *UserEventClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, ...) (*longrunningpb.Operation, error)
- func (c *UserEventClient) ImportUserEvents(ctx context.Context, req *retailpb.ImportUserEventsRequest, ...) (*ImportUserEventsOperation, error)
- func (c *UserEventClient) ImportUserEventsOperation(name string) *ImportUserEventsOperation
- func (c *UserEventClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, ...) *OperationIterator
- func (c *UserEventClient) PurgeUserEvents(ctx context.Context, req *retailpb.PurgeUserEventsRequest, ...) (*PurgeUserEventsOperation, error)
- func (c *UserEventClient) PurgeUserEventsOperation(name string) *PurgeUserEventsOperation
- func (c *UserEventClient) RejoinUserEvents(ctx context.Context, req *retailpb.RejoinUserEventsRequest, ...) (*RejoinUserEventsOperation, error)
- func (c *UserEventClient) RejoinUserEventsOperation(name string) *RejoinUserEventsOperation
- func (c *UserEventClient) WriteUserEvent(ctx context.Context, req *retailpb.WriteUserEventRequest, ...) (*retailpb.UserEvent, error)
Examples ¶
- CatalogClient.GetDefaultBranch
- CatalogClient.GetOperation
- CatalogClient.ListCatalogs
- CatalogClient.ListOperations
- CatalogClient.SetDefaultBranch
- CatalogClient.UpdateCatalog
- CompletionClient.CompleteQuery
- CompletionClient.GetOperation
- CompletionClient.ImportCompletionData
- CompletionClient.ListOperations
- NewCatalogClient
- NewCompletionClient
- NewPredictionClient
- NewProductClient
- NewSearchClient
- NewUserEventClient
- PredictionClient.GetOperation
- PredictionClient.ListOperations
- PredictionClient.Predict
- ProductClient.AddFulfillmentPlaces
- ProductClient.AddLocalInventories
- ProductClient.CreateProduct
- ProductClient.DeleteProduct
- ProductClient.GetOperation
- ProductClient.GetProduct
- ProductClient.ImportProducts
- ProductClient.ListOperations
- ProductClient.ListProducts
- ProductClient.RemoveFulfillmentPlaces
- ProductClient.RemoveLocalInventories
- ProductClient.SetInventory
- ProductClient.UpdateProduct
- SearchClient.GetOperation
- SearchClient.ListOperations
- SearchClient.Search
- UserEventClient.CollectUserEvent
- UserEventClient.GetOperation
- UserEventClient.ImportUserEvents
- UserEventClient.ListOperations
- UserEventClient.PurgeUserEvents
- UserEventClient.RejoinUserEvents
- UserEventClient.WriteUserEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type AddFulfillmentPlacesOperation ¶
type AddFulfillmentPlacesOperation struct {
// contains filtered or unexported fields
}
AddFulfillmentPlacesOperation manages a long-running operation from AddFulfillmentPlaces.
func (*AddFulfillmentPlacesOperation) Done ¶
func (op *AddFulfillmentPlacesOperation) Done() bool
Done 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() string
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 (*AddFulfillmentPlacesOperation) Poll ¶
func (op *AddFulfillmentPlacesOperation) Poll(ctx context.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 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 (*AddFulfillmentPlacesOperation) Wait ¶
func (op *AddFulfillmentPlacesOperation) Wait(ctx context.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.
type AddLocalInventoriesOperation ¶ added in v1.3.0
type AddLocalInventoriesOperation struct {
// contains filtered or unexported fields
}
AddLocalInventoriesOperation manages a long-running operation from AddLocalInventories.
func (*AddLocalInventoriesOperation) Done ¶ added in v1.3.0
func (op *AddLocalInventoriesOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*AddLocalInventoriesOperation) Metadata ¶ added in v1.3.0
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 ¶ added in v1.3.0
func (op *AddLocalInventoriesOperation) Name() string
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 (*AddLocalInventoriesOperation) Poll ¶ added in v1.3.0
func (op *AddLocalInventoriesOperation) Poll(ctx context.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 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 (*AddLocalInventoriesOperation) Wait ¶ added in v1.3.0
func (op *AddLocalInventoriesOperation) Wait(ctx context.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.
type CatalogCallOptions ¶
type CatalogCallOptions struct { ListCatalogs []gax.CallOption UpdateCatalog []gax.CallOption SetDefaultBranch []gax.CallOption GetDefaultBranch []gax.CallOption GetOperation []gax.CallOption ListOperations []gax.CallOption }
CatalogCallOptions contains the retry settings for each method of CatalogClient.
type 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 }
Output:
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) GetDefaultBranch ¶
func (c *CatalogClient) GetDefaultBranch(ctx context.Context, req *retailpb.GetDefaultBranchRequest, opts ...gax.CallOption) (*retailpb.GetDefaultBranchResponse, error)
GetDefaultBranch get which branch is currently default branch set by CatalogService.SetDefaultBranch method under a specified parent 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.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &retailpb.GetDefaultBranchRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#GetDefaultBranchRequest. } resp, err := c.GetDefaultBranch(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*CatalogClient) GetOperation ¶ added in v1.5.0
func (c *CatalogClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
GetOperation is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.GetOperationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. } resp, err := c.GetOperation(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*CatalogClient) ListCatalogs ¶
func (c *CatalogClient) ListCatalogs(ctx context.Context, req *retailpb.ListCatalogsRequest, opts ...gax.CallOption) *CatalogIterator
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#ListCatalogsRequest. } 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 } }
Output:
func (*CatalogClient) ListOperations ¶ added in v1.5.0
func (c *CatalogClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
ListOperations is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" "google.golang.org/api/iterator" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.ListOperationsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. } it := c.ListOperations(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*CatalogClient) SetDefaultBranch ¶
func (c *CatalogClient) SetDefaultBranch(ctx context.Context, req *retailpb.SetDefaultBranchRequest, opts ...gax.CallOption) error
SetDefaultBranch set a specified branch id as default branch. API methods such as SearchService.Search, ProductService.GetProduct, ProductService.ListProducts will treat requests using “default_branch” to the actual branch id set as default.
For example, if projects/*/locations/*/catalogs/*/branches/1 is set as default, setting SearchRequest.branch to projects/*/locations/*/catalogs/*/branches/default_branch is equivalent to setting SearchRequest.branch to projects/*/locations/*/catalogs/*/branches/1.
Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using projects/*/locations/*/catalogs/*/branches/default_branch as SearchRequest.branch to route the traffic to this staging branch.
CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is 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 ¶
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.SetDefaultBranchRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#SetDefaultBranchRequest. } err = c.SetDefaultBranch(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*CatalogClient) UpdateCatalog ¶
func (c *CatalogClient) UpdateCatalog(ctx context.Context, req *retailpb.UpdateCatalogRequest, opts ...gax.CallOption) (*retailpb.Catalog, error)
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#UpdateCatalogRequest. } resp, err := c.UpdateCatalog(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type 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.
type CompletionCallOptions ¶
type CompletionCallOptions struct { CompleteQuery []gax.CallOption ImportCompletionData []gax.CallOption GetOperation []gax.CallOption ListOperations []gax.CallOption }
CompletionCallOptions contains the retry settings for each method of CompletionClient.
type CompletionClient ¶
type CompletionClient struct { // 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 Retail API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Auto-completion service for retail.
This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.
func NewCompletionClient ¶
func NewCompletionClient(ctx context.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.
Auto-completion service for retail.
This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" ) func main() { ctx := context.Background() c, err := retail.NewCompletionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*CompletionClient) Close ¶
func (c *CompletionClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*CompletionClient) CompleteQuery ¶
func (c *CompletionClient) CompleteQuery(ctx context.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. Please enable Retail Search on Cloud Console before using this feature.
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.NewCompletionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &retailpb.CompleteQueryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#CompleteQueryRequest. } resp, err := c.CompleteQuery(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*CompletionClient) Connection ¶
func (c *CompletionClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated.
func (*CompletionClient) GetOperation ¶ added in v1.5.0
func (c *CompletionClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
GetOperation is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewCompletionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.GetOperationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. } resp, err := c.GetOperation(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*CompletionClient) ImportCompletionData ¶
func (c *CompletionClient) ImportCompletionData(ctx context.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 suggestions are indexed successfully and ready for serving. The process takes hours.
This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.
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.NewCompletionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &retailpb.ImportCompletionDataRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#ImportCompletionDataRequest. } op, err := c.ImportCompletionData(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*CompletionClient) ImportCompletionDataOperation ¶
func (c *CompletionClient) ImportCompletionDataOperation(name string) *ImportCompletionDataOperation
ImportCompletionDataOperation 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 ¶ added in v1.5.0
func (c *CompletionClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
ListOperations is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" "google.golang.org/api/iterator" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewCompletionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.ListOperationsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. } it := c.ListOperations(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
type ImportCompletionDataOperation ¶
type ImportCompletionDataOperation struct {
// contains filtered or unexported fields
}
ImportCompletionDataOperation manages a long-running operation from ImportCompletionData.
func (*ImportCompletionDataOperation) Done ¶
func (op *ImportCompletionDataOperation) Done() bool
Done 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() string
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 (*ImportCompletionDataOperation) Poll ¶
func (op *ImportCompletionDataOperation) Poll(ctx context.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 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 (*ImportCompletionDataOperation) Wait ¶
func (op *ImportCompletionDataOperation) Wait(ctx context.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.
type 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.
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() string
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 ¶
func (op *ImportProductsOperation) Poll(ctx context.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 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 ¶
func (op *ImportProductsOperation) Wait(ctx context.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.
type ImportUserEventsOperation ¶
type ImportUserEventsOperation struct {
// contains filtered or unexported fields
}
ImportUserEventsOperation manages a long-running operation from ImportUserEvents.
func (*ImportUserEventsOperation) Done ¶
func (op *ImportUserEventsOperation) Done() bool
Done 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() string
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 ¶
func (op *ImportUserEventsOperation) Poll(ctx context.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 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 ¶
func (op *ImportUserEventsOperation) Wait(ctx context.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.
type OperationIterator ¶ added in v1.5.0
type OperationIterator 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 []*longrunningpb.Operation, nextPageToken string, err error) // contains filtered or unexported fields }
OperationIterator manages a stream of *longrunningpb.Operation.
func (*OperationIterator) Next ¶ added in v1.5.0
func (it *OperationIterator) Next() (*longrunningpb.Operation, 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 (*OperationIterator) PageInfo ¶ added in v1.5.0
func (it *OperationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type PredictionCallOptions ¶
type PredictionCallOptions struct { Predict []gax.CallOption GetOperation []gax.CallOption ListOperations []gax.CallOption }
PredictionCallOptions contains the retry settings for each method of PredictionClient.
type 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 }
Output:
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) GetOperation ¶ added in v1.5.0
func (c *PredictionClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
GetOperation is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewPredictionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.GetOperationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. } resp, err := c.GetOperation(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*PredictionClient) ListOperations ¶ added in v1.5.0
func (c *PredictionClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
ListOperations is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" "google.golang.org/api/iterator" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewPredictionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.ListOperationsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. } it := c.ListOperations(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*PredictionClient) Predict ¶
func (c *PredictionClient) Predict(ctx context.Context, req *retailpb.PredictRequest, opts ...gax.CallOption) (*retailpb.PredictResponse, error)
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#PredictRequest. } resp, err := c.Predict(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type ProductCallOptions ¶
type ProductCallOptions struct { CreateProduct []gax.CallOption GetProduct []gax.CallOption ListProducts []gax.CallOption UpdateProduct []gax.CallOption DeleteProduct []gax.CallOption ImportProducts []gax.CallOption SetInventory []gax.CallOption AddFulfillmentPlaces []gax.CallOption RemoveFulfillmentPlaces []gax.CallOption AddLocalInventories []gax.CallOption RemoveLocalInventories []gax.CallOption GetOperation []gax.CallOption ListOperations []gax.CallOption }
ProductCallOptions contains the retry settings for each method of ProductClient.
type 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 }
Output:
func (*ProductClient) AddFulfillmentPlaces ¶
func (c *ProductClient) AddFulfillmentPlaces(ctx context.Context, req *retailpb.AddFulfillmentPlacesRequest, opts ...gax.CallOption) (*AddFulfillmentPlacesOperation, error)
AddFulfillmentPlaces incrementally adds place IDs to Product.fulfillment_info.place_ids.
This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts.
This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.
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.AddFulfillmentPlacesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#AddFulfillmentPlacesRequest. } op, err := c.AddFulfillmentPlaces(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ProductClient) AddFulfillmentPlacesOperation ¶
func (c *ProductClient) AddFulfillmentPlacesOperation(name string) *AddFulfillmentPlacesOperation
AddFulfillmentPlacesOperation 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 ¶ added in v1.3.0
func (c *ProductClient) AddLocalInventories(ctx context.Context, req *retailpb.AddLocalInventoriesRequest, opts ...gax.CallOption) (*AddLocalInventoriesOperation, error)
AddLocalInventories updates local inventory information for a Product at a list of places, while respecting the last update timestamps of each inventory field.
This process is asynchronous and does not require the Product to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts.
Local inventory information can only be modified using this method. ProductService.CreateProduct and ProductService.UpdateProduct has no effect on local inventories.
This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.
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.AddLocalInventoriesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#AddLocalInventoriesRequest. } op, err := c.AddLocalInventories(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ProductClient) AddLocalInventoriesOperation ¶ added in v1.3.0
func (c *ProductClient) AddLocalInventoriesOperation(name string) *AddLocalInventoriesOperation
AddLocalInventoriesOperation 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() 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 ¶
func (c *ProductClient) CreateProduct(ctx context.Context, req *retailpb.CreateProductRequest, opts ...gax.CallOption) (*retailpb.Product, error)
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#CreateProductRequest. } resp, err := c.CreateProduct(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ProductClient) DeleteProduct ¶
func (c *ProductClient) DeleteProduct(ctx context.Context, req *retailpb.DeleteProductRequest, opts ...gax.CallOption) error
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#DeleteProductRequest. } err = c.DeleteProduct(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*ProductClient) GetOperation ¶ added in v1.5.0
func (c *ProductClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
GetOperation is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewProductClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.GetOperationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. } resp, err := c.GetOperation(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ProductClient) GetProduct ¶
func (c *ProductClient) GetProduct(ctx context.Context, req *retailpb.GetProductRequest, opts ...gax.CallOption) (*retailpb.Product, error)
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#GetProductRequest. } resp, err := c.GetProduct(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ProductClient) ImportProducts ¶
func (c *ProductClient) ImportProducts(ctx context.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 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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#ImportProductsRequest. } 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 }
Output:
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) ListOperations ¶ added in v1.5.0
func (c *ProductClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
ListOperations is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" "google.golang.org/api/iterator" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewProductClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.ListOperationsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. } it := c.ListOperations(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*ProductClient) ListProducts ¶
func (c *ProductClient) ListProducts(ctx context.Context, req *retailpb.ListProductsRequest, opts ...gax.CallOption) *ProductIterator
ListProducts gets a list of Products.
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.NewProductClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &retailpb.ListProductsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#ListProductsRequest. } it := c.ListProducts(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*ProductClient) RemoveFulfillmentPlaces ¶
func (c *ProductClient) RemoveFulfillmentPlaces(ctx context.Context, req *retailpb.RemoveFulfillmentPlacesRequest, opts ...gax.CallOption) (*RemoveFulfillmentPlacesOperation, error)
RemoveFulfillmentPlaces incrementally removes place IDs from a Product.fulfillment_info.place_ids.
This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts.
This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.
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.RemoveFulfillmentPlacesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#RemoveFulfillmentPlacesRequest. } op, err := c.RemoveFulfillmentPlaces(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ProductClient) RemoveFulfillmentPlacesOperation ¶
func (c *ProductClient) RemoveFulfillmentPlacesOperation(name string) *RemoveFulfillmentPlacesOperation
RemoveFulfillmentPlacesOperation 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 ¶ added in v1.3.0
func (c *ProductClient) RemoveLocalInventories(ctx context.Context, req *retailpb.RemoveLocalInventoriesRequest, opts ...gax.CallOption) (*RemoveLocalInventoriesOperation, error)
RemoveLocalInventories remove local inventory information for a Product at a list of places at a removal timestamp.
This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts.
Local inventory information can only be removed using this method. ProductService.CreateProduct and ProductService.UpdateProduct has no effect on local inventories.
This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.
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.RemoveLocalInventoriesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#RemoveLocalInventoriesRequest. } op, err := c.RemoveLocalInventories(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ProductClient) RemoveLocalInventoriesOperation ¶ added in v1.3.0
func (c *ProductClient) RemoveLocalInventoriesOperation(name string) *RemoveLocalInventoriesOperation
RemoveLocalInventoriesOperation 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(ctx context.Context, req *retailpb.SetInventoryRequest, opts ...gax.CallOption) (*SetInventoryOperation, error)
SetInventory updates inventory information for a Product while respecting the last update timestamps of each inventory field.
This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts.
When inventory is updated with ProductService.CreateProduct and ProductService.UpdateProduct, the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the ProductService.CreateProduct or ProductService.UpdateProduct request.
If no inventory fields are set in CreateProductRequest.product, then any pre-existing inventory information for this product will be used.
If no inventory fields are set in SetInventoryRequest.set_mask, then any existing inventory information will be preserved.
Pre-existing inventory information can only be updated with ProductService.SetInventory, ProductService.AddFulfillmentPlaces, and ProductService.RemoveFulfillmentPlaces.
This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.
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.SetInventoryRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#SetInventoryRequest. } op, err := c.SetInventory(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ProductClient) SetInventoryOperation ¶
func (c *ProductClient) SetInventoryOperation(name string) *SetInventoryOperation
SetInventoryOperation 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(ctx context.Context, req *retailpb.UpdateProductRequest, opts ...gax.CallOption) (*retailpb.Product, error)
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#UpdateProductRequest. } resp, err := c.UpdateProduct(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type ProductIterator ¶
type ProductIterator 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.Product, nextPageToken string, err error) // contains filtered or unexported fields }
ProductIterator manages a stream of *retailpb.Product.
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 more results. Once Next returns Done, all subsequent calls will return Done.
func (*ProductIterator) PageInfo ¶
func (it *ProductIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type PurgeUserEventsOperation ¶
type PurgeUserEventsOperation struct {
// contains filtered or unexported fields
}
PurgeUserEventsOperation manages a long-running operation from PurgeUserEvents.
func (*PurgeUserEventsOperation) Done ¶
func (op *PurgeUserEventsOperation) Done() bool
Done 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() string
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 ¶
func (op *PurgeUserEventsOperation) Poll(ctx context.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 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 ¶
func (op *PurgeUserEventsOperation) Wait(ctx context.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.
type RejoinUserEventsOperation ¶
type RejoinUserEventsOperation struct {
// contains filtered or unexported fields
}
RejoinUserEventsOperation manages a long-running operation from RejoinUserEvents.
func (*RejoinUserEventsOperation) Done ¶
func (op *RejoinUserEventsOperation) Done() bool
Done 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() string
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 ¶
func (op *RejoinUserEventsOperation) Poll(ctx context.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 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 ¶
func (op *RejoinUserEventsOperation) Wait(ctx context.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.
type RemoveFulfillmentPlacesOperation ¶
type RemoveFulfillmentPlacesOperation struct {
// contains filtered or unexported fields
}
RemoveFulfillmentPlacesOperation manages a long-running operation from RemoveFulfillmentPlaces.
func (*RemoveFulfillmentPlacesOperation) Done ¶
func (op *RemoveFulfillmentPlacesOperation) Done() bool
Done 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() string
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 (*RemoveFulfillmentPlacesOperation) Poll ¶
func (op *RemoveFulfillmentPlacesOperation) Poll(ctx context.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 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 (*RemoveFulfillmentPlacesOperation) Wait ¶
func (op *RemoveFulfillmentPlacesOperation) Wait(ctx context.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.
type RemoveLocalInventoriesOperation ¶ added in v1.3.0
type RemoveLocalInventoriesOperation struct {
// contains filtered or unexported fields
}
RemoveLocalInventoriesOperation manages a long-running operation from RemoveLocalInventories.
func (*RemoveLocalInventoriesOperation) Done ¶ added in v1.3.0
func (op *RemoveLocalInventoriesOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*RemoveLocalInventoriesOperation) Metadata ¶ added in v1.3.0
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 ¶ added in v1.3.0
func (op *RemoveLocalInventoriesOperation) Name() string
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 (*RemoveLocalInventoriesOperation) Poll ¶ added in v1.3.0
func (op *RemoveLocalInventoriesOperation) Poll(ctx context.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 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 (*RemoveLocalInventoriesOperation) Wait ¶ added in v1.3.0
func (op *RemoveLocalInventoriesOperation) Wait(ctx context.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.
type SearchCallOptions ¶
type SearchCallOptions struct { Search []gax.CallOption GetOperation []gax.CallOption ListOperations []gax.CallOption }
SearchCallOptions contains the retry settings for each method of SearchClient.
type SearchClient ¶
type SearchClient struct { // The call options for this service. CallOptions *SearchCallOptions // contains filtered or unexported fields }
SearchClient 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 search.
This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.
func NewSearchClient ¶
func NewSearchClient(ctx context.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. Please enable Retail Search on Cloud Console before using this feature.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" ) func main() { ctx := context.Background() c, err := retail.NewSearchClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*SearchClient) Close ¶
func (c *SearchClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*SearchClient) Connection ¶
func (c *SearchClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated.
func (*SearchClient) GetOperation ¶ added in v1.5.0
func (c *SearchClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
GetOperation is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewSearchClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.GetOperationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. } resp, err := c.GetOperation(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*SearchClient) ListOperations ¶ added in v1.5.0
func (c *SearchClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
ListOperations is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" "google.golang.org/api/iterator" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewSearchClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.ListOperationsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. } it := c.ListOperations(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*SearchClient) Search ¶
func (c *SearchClient) Search(ctx context.Context, req *retailpb.SearchRequest, opts ...gax.CallOption) *SearchResponse_SearchResultIterator
Search performs a search.
This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.
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.NewSearchClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &retailpb.SearchRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#SearchRequest. } it := c.Search(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
type SearchResponse_SearchResultIterator ¶
type SearchResponse_SearchResultIterator 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.SearchResponse_SearchResult, nextPageToken string, err error) // contains filtered or unexported fields }
SearchResponse_SearchResultIterator manages a stream of *retailpb.SearchResponse_SearchResult.
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 more results. Once Next returns Done, all subsequent calls will return Done.
func (*SearchResponse_SearchResultIterator) PageInfo ¶
func (it *SearchResponse_SearchResultIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type SetInventoryOperation ¶
type SetInventoryOperation struct {
// contains filtered or unexported fields
}
SetInventoryOperation manages a long-running operation from SetInventory.
func (*SetInventoryOperation) Done ¶
func (op *SetInventoryOperation) Done() bool
Done 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() string
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 (*SetInventoryOperation) Poll ¶
func (op *SetInventoryOperation) Poll(ctx context.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 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 (*SetInventoryOperation) Wait ¶
func (op *SetInventoryOperation) Wait(ctx context.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.
type UserEventCallOptions ¶
type UserEventCallOptions struct { WriteUserEvent []gax.CallOption CollectUserEvent []gax.CallOption PurgeUserEvents []gax.CallOption ImportUserEvents []gax.CallOption RejoinUserEvents []gax.CallOption GetOperation []gax.CallOption ListOperations []gax.CallOption }
UserEventCallOptions contains the retry settings for each method of UserEventClient.
type 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 }
Output:
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 ¶
func (c *UserEventClient) CollectUserEvent(ctx context.Context, req *retailpb.CollectUserEventRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error)
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#CollectUserEventRequest. } resp, err := c.CollectUserEvent(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*UserEventClient) Connection ¶
func (c *UserEventClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated.
func (*UserEventClient) GetOperation ¶ added in v1.5.0
func (c *UserEventClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
GetOperation is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewUserEventClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.GetOperationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. } resp, err := c.GetOperation(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*UserEventClient) ImportUserEvents ¶
func (c *UserEventClient) ImportUserEvents(ctx context.Context, req *retailpb.ImportUserEventsRequest, opts ...gax.CallOption) (*ImportUserEventsOperation, error)
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#ImportUserEventsRequest. } 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 }
Output:
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) ListOperations ¶ added in v1.5.0
func (c *UserEventClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
ListOperations is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" retail "cloud.google.com/go/retail/apiv2" "google.golang.org/api/iterator" longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func main() { ctx := context.Background() c, err := retail.NewUserEventClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &longrunningpb.ListOperationsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. } it := c.ListOperations(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*UserEventClient) PurgeUserEvents ¶
func (c *UserEventClient) PurgeUserEvents(ctx context.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 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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#PurgeUserEventsRequest. } 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 }
Output:
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 ¶
func (c *UserEventClient) RejoinUserEvents(ctx context.Context, req *retailpb.RejoinUserEventsRequest, opts ...gax.CallOption) (*RejoinUserEventsOperation, error)
RejoinUserEvents starts 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 method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#RejoinUserEventsRequest. } 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 }
Output:
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 ¶
func (c *UserEventClient) WriteUserEvent(ctx context.Context, req *retailpb.WriteUserEventRequest, opts ...gax.CallOption) (*retailpb.UserEvent, error)
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. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/retail/v2#WriteUserEventRequest. } resp, err := c.WriteUserEvent(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output: