Documentation ¶
Overview ¶
Package recommendationengine is an auto-generated package for the Recommendations AI.
Recommendations AI 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.
NOTE: This package is in beta. It is not stable, and may be subject to changes.
General documentation ¶
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage ¶
To get started with this package, create a client.
ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.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() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.CreateCatalogItemRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#CreateCatalogItemRequest. } resp, err := c.CreateCatalogItem(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context ¶
The ctx passed to NewCatalogClient 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.
Index ¶
- func DefaultAuthScopes() []string
- type CatalogCallOptions
- type CatalogClient
- func (c *CatalogClient) Close() error
- func (c *CatalogClient) Connection() *grpc.ClientConndeprecated
- func (c *CatalogClient) CreateCatalogItem(ctx context.Context, req *recommendationenginepb.CreateCatalogItemRequest, ...) (*recommendationenginepb.CatalogItem, error)
- func (c *CatalogClient) DeleteCatalogItem(ctx context.Context, req *recommendationenginepb.DeleteCatalogItemRequest, ...) error
- func (c *CatalogClient) GetCatalogItem(ctx context.Context, req *recommendationenginepb.GetCatalogItemRequest, ...) (*recommendationenginepb.CatalogItem, error)
- func (c *CatalogClient) ImportCatalogItems(ctx context.Context, req *recommendationenginepb.ImportCatalogItemsRequest, ...) (*ImportCatalogItemsOperation, error)
- func (c *CatalogClient) ImportCatalogItemsOperation(name string) *ImportCatalogItemsOperation
- func (c *CatalogClient) ListCatalogItems(ctx context.Context, req *recommendationenginepb.ListCatalogItemsRequest, ...) *CatalogItemIterator
- func (c *CatalogClient) UpdateCatalogItem(ctx context.Context, req *recommendationenginepb.UpdateCatalogItemRequest, ...) (*recommendationenginepb.CatalogItem, error)
- type CatalogItemIterator
- type ImportCatalogItemsOperation
- func (op *ImportCatalogItemsOperation) Done() bool
- func (op *ImportCatalogItemsOperation) Metadata() (*recommendationenginepb.ImportMetadata, error)
- func (op *ImportCatalogItemsOperation) Name() string
- func (op *ImportCatalogItemsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*recommendationenginepb.ImportCatalogItemsResponse, error)
- func (op *ImportCatalogItemsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*recommendationenginepb.ImportCatalogItemsResponse, error)
- type ImportUserEventsOperation
- func (op *ImportUserEventsOperation) Done() bool
- func (op *ImportUserEventsOperation) Metadata() (*recommendationenginepb.ImportMetadata, error)
- func (op *ImportUserEventsOperation) Name() string
- func (op *ImportUserEventsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*recommendationenginepb.ImportUserEventsResponse, error)
- func (op *ImportUserEventsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*recommendationenginepb.ImportUserEventsResponse, error)
- type PredictResponse_PredictionResultIterator
- func (it *PredictResponse_PredictionResultIterator) All() iter.Seq2[*recommendationenginepb.PredictResponse_PredictionResult, error]
- func (it *PredictResponse_PredictionResultIterator) Next() (*recommendationenginepb.PredictResponse_PredictionResult, error)
- func (it *PredictResponse_PredictionResultIterator) PageInfo() *iterator.PageInfo
- type PredictionApiKeyRegistrationIterator
- func (it *PredictionApiKeyRegistrationIterator) All() iter.Seq2[*recommendationenginepb.PredictionApiKeyRegistration, error]
- func (it *PredictionApiKeyRegistrationIterator) Next() (*recommendationenginepb.PredictionApiKeyRegistration, error)
- func (it *PredictionApiKeyRegistrationIterator) PageInfo() *iterator.PageInfo
- type PredictionApiKeyRegistryCallOptions
- type PredictionApiKeyRegistryClient
- func (c *PredictionApiKeyRegistryClient) Close() error
- func (c *PredictionApiKeyRegistryClient) Connection() *grpc.ClientConndeprecated
- func (c *PredictionApiKeyRegistryClient) CreatePredictionApiKeyRegistration(ctx context.Context, ...) (*recommendationenginepb.PredictionApiKeyRegistration, error)
- func (c *PredictionApiKeyRegistryClient) DeletePredictionApiKeyRegistration(ctx context.Context, ...) error
- func (c *PredictionApiKeyRegistryClient) ListPredictionApiKeyRegistrations(ctx context.Context, ...) *PredictionApiKeyRegistrationIterator
- type PredictionCallOptions
- type PredictionClient
- type PurgeUserEventsOperation
- func (op *PurgeUserEventsOperation) Done() bool
- func (op *PurgeUserEventsOperation) Metadata() (*recommendationenginepb.PurgeUserEventsMetadata, error)
- func (op *PurgeUserEventsOperation) Name() string
- func (op *PurgeUserEventsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*recommendationenginepb.PurgeUserEventsResponse, error)
- func (op *PurgeUserEventsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*recommendationenginepb.PurgeUserEventsResponse, error)
- type UserEventCallOptions
- type UserEventClient
- func (c *UserEventClient) Close() error
- func (c *UserEventClient) CollectUserEvent(ctx context.Context, req *recommendationenginepb.CollectUserEventRequest, ...) (*httpbodypb.HttpBody, error)
- func (c *UserEventClient) Connection() *grpc.ClientConndeprecated
- func (c *UserEventClient) ImportUserEvents(ctx context.Context, req *recommendationenginepb.ImportUserEventsRequest, ...) (*ImportUserEventsOperation, error)
- func (c *UserEventClient) ImportUserEventsOperation(name string) *ImportUserEventsOperation
- func (c *UserEventClient) ListUserEvents(ctx context.Context, req *recommendationenginepb.ListUserEventsRequest, ...) *UserEventIterator
- func (c *UserEventClient) PurgeUserEvents(ctx context.Context, req *recommendationenginepb.PurgeUserEventsRequest, ...) (*PurgeUserEventsOperation, error)
- func (c *UserEventClient) PurgeUserEventsOperation(name string) *PurgeUserEventsOperation
- func (c *UserEventClient) WriteUserEvent(ctx context.Context, req *recommendationenginepb.WriteUserEventRequest, ...) (*recommendationenginepb.UserEvent, error)
- type UserEventIterator
Examples ¶
- CatalogClient.CreateCatalogItem
- CatalogClient.DeleteCatalogItem
- CatalogClient.GetCatalogItem
- CatalogClient.ImportCatalogItems
- CatalogClient.ListCatalogItems
- CatalogClient.ListCatalogItems (All)
- CatalogClient.UpdateCatalogItem
- NewCatalogClient
- NewCatalogRESTClient
- NewPredictionApiKeyRegistryClient
- NewPredictionApiKeyRegistryRESTClient
- NewPredictionClient
- NewPredictionRESTClient
- NewUserEventClient
- NewUserEventRESTClient
- PredictionApiKeyRegistryClient.CreatePredictionApiKeyRegistration
- PredictionApiKeyRegistryClient.DeletePredictionApiKeyRegistration
- PredictionApiKeyRegistryClient.ListPredictionApiKeyRegistrations
- PredictionApiKeyRegistryClient.ListPredictionApiKeyRegistrations (All)
- PredictionClient.Predict
- PredictionClient.Predict (All)
- UserEventClient.CollectUserEvent
- UserEventClient.ImportUserEvents
- UserEventClient.ListUserEvents
- UserEventClient.ListUserEvents (All)
- UserEventClient.PurgeUserEvents
- 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 CatalogCallOptions ¶
type CatalogCallOptions struct { CreateCatalogItem []gax.CallOption GetCatalogItem []gax.CallOption ListCatalogItems []gax.CallOption UpdateCatalogItem []gax.CallOption DeleteCatalogItem []gax.CallOption ImportCatalogItems []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 // 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 }
CatalogClient is a client for interacting with Recommendations AI. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for ingesting catalog information of the customer’s website.
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 ingesting catalog information of the customer’s website.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewCatalogRESTClient ¶ added in v0.4.0
func NewCatalogRESTClient(ctx context.Context, opts ...option.ClientOption) (*CatalogClient, error)
NewCatalogRESTClient creates a new catalog service rest client.
Service for ingesting catalog information of the customer’s website.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewCatalogRESTClient(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
deprecated
func (c *CatalogClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*CatalogClient) CreateCatalogItem ¶
func (c *CatalogClient) CreateCatalogItem(ctx context.Context, req *recommendationenginepb.CreateCatalogItemRequest, opts ...gax.CallOption) (*recommendationenginepb.CatalogItem, error)
CreateCatalogItem creates a catalog item.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.CreateCatalogItemRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#CreateCatalogItemRequest. } resp, err := c.CreateCatalogItem(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*CatalogClient) DeleteCatalogItem ¶
func (c *CatalogClient) DeleteCatalogItem(ctx context.Context, req *recommendationenginepb.DeleteCatalogItemRequest, opts ...gax.CallOption) error
DeleteCatalogItem deletes a catalog item.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.DeleteCatalogItemRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#DeleteCatalogItemRequest. } err = c.DeleteCatalogItem(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*CatalogClient) GetCatalogItem ¶
func (c *CatalogClient) GetCatalogItem(ctx context.Context, req *recommendationenginepb.GetCatalogItemRequest, opts ...gax.CallOption) (*recommendationenginepb.CatalogItem, error)
GetCatalogItem gets a specific catalog item.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.GetCatalogItemRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#GetCatalogItemRequest. } resp, err := c.GetCatalogItem(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*CatalogClient) ImportCatalogItems ¶
func (c *CatalogClient) ImportCatalogItems(ctx context.Context, req *recommendationenginepb.ImportCatalogItemsRequest, opts ...gax.CallOption) (*ImportCatalogItemsOperation, error)
ImportCatalogItems bulk import of multiple catalog items. Request processing may be synchronous. No partial updating supported. Non-existing items will be created.
Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully updated.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.ImportCatalogItemsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#ImportCatalogItemsRequest. } op, err := c.ImportCatalogItems(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 (*CatalogClient) ImportCatalogItemsOperation ¶
func (c *CatalogClient) ImportCatalogItemsOperation(name string) *ImportCatalogItemsOperation
ImportCatalogItemsOperation returns a new ImportCatalogItemsOperation from a given name. The name must be that of a previously created ImportCatalogItemsOperation, possibly from a different process.
func (*CatalogClient) ListCatalogItems ¶
func (c *CatalogClient) ListCatalogItems(ctx context.Context, req *recommendationenginepb.ListCatalogItemsRequest, opts ...gax.CallOption) *CatalogItemIterator
ListCatalogItems gets a list of catalog items.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.ListCatalogItemsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#ListCatalogItemsRequest. } it := c.ListCatalogItems(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*recommendationenginepb.ListCatalogItemsResponse) } }
Output:
Example (All) ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.ListCatalogItemsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#ListCatalogItemsRequest. } for resp, err := range c.ListCatalogItems(ctx, req).All() { if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*CatalogClient) UpdateCatalogItem ¶
func (c *CatalogClient) UpdateCatalogItem(ctx context.Context, req *recommendationenginepb.UpdateCatalogItemRequest, opts ...gax.CallOption) (*recommendationenginepb.CatalogItem, error)
UpdateCatalogItem updates a catalog item. Partial updating is supported. Non-existing items will be created.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewCatalogClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.UpdateCatalogItemRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#UpdateCatalogItemRequest. } resp, err := c.UpdateCatalogItem(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type CatalogItemIterator ¶
type CatalogItemIterator 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 []*recommendationenginepb.CatalogItem, nextPageToken string, err error) // contains filtered or unexported fields }
CatalogItemIterator manages a stream of *recommendationenginepb.CatalogItem.
func (*CatalogItemIterator) All ¶ added in v0.9.1
func (it *CatalogItemIterator) All() iter.Seq2[*recommendationenginepb.CatalogItem, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*CatalogItemIterator) Next ¶
func (it *CatalogItemIterator) Next() (*recommendationenginepb.CatalogItem, 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 (*CatalogItemIterator) PageInfo ¶
func (it *CatalogItemIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type ImportCatalogItemsOperation ¶
type ImportCatalogItemsOperation struct {
// contains filtered or unexported fields
}
ImportCatalogItemsOperation manages a long-running operation from ImportCatalogItems.
func (*ImportCatalogItemsOperation) Done ¶
func (op *ImportCatalogItemsOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*ImportCatalogItemsOperation) Metadata ¶
func (op *ImportCatalogItemsOperation) Metadata() (*recommendationenginepb.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 (*ImportCatalogItemsOperation) Name ¶
func (op *ImportCatalogItemsOperation) 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 (*ImportCatalogItemsOperation) Poll ¶
func (op *ImportCatalogItemsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*recommendationenginepb.ImportCatalogItemsResponse, 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 (*ImportCatalogItemsOperation) Wait ¶
func (op *ImportCatalogItemsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*recommendationenginepb.ImportCatalogItemsResponse, 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() (*recommendationenginepb.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) (*recommendationenginepb.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) (*recommendationenginepb.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 PredictResponse_PredictionResultIterator ¶
type PredictResponse_PredictionResultIterator 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 []*recommendationenginepb.PredictResponse_PredictionResult, nextPageToken string, err error) // contains filtered or unexported fields }
PredictResponse_PredictionResultIterator manages a stream of *recommendationenginepb.PredictResponse_PredictionResult.
func (*PredictResponse_PredictionResultIterator) All ¶ added in v0.9.1
func (it *PredictResponse_PredictionResultIterator) All() iter.Seq2[*recommendationenginepb.PredictResponse_PredictionResult, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*PredictResponse_PredictionResultIterator) Next ¶
func (it *PredictResponse_PredictionResultIterator) Next() (*recommendationenginepb.PredictResponse_PredictionResult, 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 (*PredictResponse_PredictionResultIterator) PageInfo ¶
func (it *PredictResponse_PredictionResultIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type PredictionApiKeyRegistrationIterator ¶
type PredictionApiKeyRegistrationIterator 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 []*recommendationenginepb.PredictionApiKeyRegistration, nextPageToken string, err error) // contains filtered or unexported fields }
PredictionApiKeyRegistrationIterator manages a stream of *recommendationenginepb.PredictionApiKeyRegistration.
func (*PredictionApiKeyRegistrationIterator) All ¶ added in v0.9.1
func (it *PredictionApiKeyRegistrationIterator) All() iter.Seq2[*recommendationenginepb.PredictionApiKeyRegistration, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*PredictionApiKeyRegistrationIterator) Next ¶
func (it *PredictionApiKeyRegistrationIterator) Next() (*recommendationenginepb.PredictionApiKeyRegistration, 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 (*PredictionApiKeyRegistrationIterator) PageInfo ¶
func (it *PredictionApiKeyRegistrationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type PredictionApiKeyRegistryCallOptions ¶
type PredictionApiKeyRegistryCallOptions struct { CreatePredictionApiKeyRegistration []gax.CallOption ListPredictionApiKeyRegistrations []gax.CallOption DeletePredictionApiKeyRegistration []gax.CallOption }
PredictionApiKeyRegistryCallOptions contains the retry settings for each method of PredictionApiKeyRegistryClient.
type PredictionApiKeyRegistryClient ¶
type PredictionApiKeyRegistryClient struct { // The call options for this service. CallOptions *PredictionApiKeyRegistryCallOptions // contains filtered or unexported fields }
PredictionApiKeyRegistryClient is a client for interacting with Recommendations AI. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service for registering API keys for use with the predict method. If you use an API key to request predictions, you must first register the API key. Otherwise, your prediction request is rejected. If you use OAuth to authenticate your predict method call, you do not need to register an API key. You can register up to 20 API keys per project.
func NewPredictionApiKeyRegistryClient ¶
func NewPredictionApiKeyRegistryClient(ctx context.Context, opts ...option.ClientOption) (*PredictionApiKeyRegistryClient, error)
NewPredictionApiKeyRegistryClient creates a new prediction api key registry client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Service for registering API keys for use with the predict method. If you use an API key to request predictions, you must first register the API key. Otherwise, your prediction request is rejected. If you use OAuth to authenticate your predict method call, you do not need to register an API key. You can register up to 20 API keys per project.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewPredictionApiKeyRegistryClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewPredictionApiKeyRegistryRESTClient ¶ added in v0.4.0
func NewPredictionApiKeyRegistryRESTClient(ctx context.Context, opts ...option.ClientOption) (*PredictionApiKeyRegistryClient, error)
NewPredictionApiKeyRegistryRESTClient creates a new prediction api key registry rest client.
Service for registering API keys for use with the predict method. If you use an API key to request predictions, you must first register the API key. Otherwise, your prediction request is rejected. If you use OAuth to authenticate your predict method call, you do not need to register an API key. You can register up to 20 API keys per project.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewPredictionApiKeyRegistryRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*PredictionApiKeyRegistryClient) Close ¶
func (c *PredictionApiKeyRegistryClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*PredictionApiKeyRegistryClient) Connection
deprecated
func (c *PredictionApiKeyRegistryClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*PredictionApiKeyRegistryClient) CreatePredictionApiKeyRegistration ¶
func (c *PredictionApiKeyRegistryClient) CreatePredictionApiKeyRegistration(ctx context.Context, req *recommendationenginepb.CreatePredictionApiKeyRegistrationRequest, opts ...gax.CallOption) (*recommendationenginepb.PredictionApiKeyRegistration, error)
CreatePredictionApiKeyRegistration register an API key for use with predict method.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewPredictionApiKeyRegistryClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.CreatePredictionApiKeyRegistrationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#CreatePredictionApiKeyRegistrationRequest. } resp, err := c.CreatePredictionApiKeyRegistration(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*PredictionApiKeyRegistryClient) DeletePredictionApiKeyRegistration ¶
func (c *PredictionApiKeyRegistryClient) DeletePredictionApiKeyRegistration(ctx context.Context, req *recommendationenginepb.DeletePredictionApiKeyRegistrationRequest, opts ...gax.CallOption) error
DeletePredictionApiKeyRegistration unregister an apiKey from using for predict method.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewPredictionApiKeyRegistryClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.DeletePredictionApiKeyRegistrationRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#DeletePredictionApiKeyRegistrationRequest. } err = c.DeletePredictionApiKeyRegistration(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*PredictionApiKeyRegistryClient) ListPredictionApiKeyRegistrations ¶
func (c *PredictionApiKeyRegistryClient) ListPredictionApiKeyRegistrations(ctx context.Context, req *recommendationenginepb.ListPredictionApiKeyRegistrationsRequest, opts ...gax.CallOption) *PredictionApiKeyRegistrationIterator
ListPredictionApiKeyRegistrations list the registered apiKeys for use with predict method.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewPredictionApiKeyRegistryClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.ListPredictionApiKeyRegistrationsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#ListPredictionApiKeyRegistrationsRequest. } it := c.ListPredictionApiKeyRegistrations(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*recommendationenginepb.ListPredictionApiKeyRegistrationsResponse) } }
Output:
Example (All) ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewPredictionApiKeyRegistryClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.ListPredictionApiKeyRegistrationsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#ListPredictionApiKeyRegistrationsRequest. } for resp, err := range c.ListPredictionApiKeyRegistrations(ctx, req).All() { if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
type PredictionCallOptions ¶
type PredictionCallOptions struct {
Predict []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 Recommendations AI. 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" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewPredictionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewPredictionRESTClient ¶ added in v0.4.0
func NewPredictionRESTClient(ctx context.Context, opts ...option.ClientOption) (*PredictionClient, error)
NewPredictionRESTClient creates a new prediction service rest client.
Service for making recommendation prediction.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewPredictionRESTClient(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
deprecated
func (c *PredictionClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*PredictionClient) Predict ¶
func (c *PredictionClient) Predict(ctx context.Context, req *recommendationenginepb.PredictRequest, opts ...gax.CallOption) *PredictResponse_PredictionResultIterator
Predict makes a recommendation prediction. If using API Key based authentication, the API Key must be registered using the PredictionApiKeyRegistry service. Learn more (at /recommendations-ai/docs/setting-up#register-key).
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewPredictionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.PredictRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#PredictRequest. } it := c.Predict(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*recommendationenginepb.PredictResponse) } }
Output:
Example (All) ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewPredictionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.PredictRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#PredictRequest. } for resp, err := range c.Predict(ctx, req).All() { if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
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() (*recommendationenginepb.PurgeUserEventsMetadata, 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) (*recommendationenginepb.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) (*recommendationenginepb.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 UserEventCallOptions ¶
type UserEventCallOptions struct { WriteUserEvent []gax.CallOption CollectUserEvent []gax.CallOption ListUserEvents []gax.CallOption PurgeUserEvents []gax.CallOption ImportUserEvents []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 Recommendations AI. 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" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewUserEventClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewUserEventRESTClient ¶ added in v0.4.0
func NewUserEventRESTClient(ctx context.Context, opts ...option.ClientOption) (*UserEventClient, error)
NewUserEventRESTClient creates a new user event service rest client.
Service for ingesting end user actions on the customer website.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewUserEventRESTClient(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 *recommendationenginepb.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 Recommendations AI JavaScript pixel. Users should not call this method directly.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewUserEventClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.CollectUserEventRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#CollectUserEventRequest. } resp, err := c.CollectUserEvent(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*UserEventClient) Connection
deprecated
func (c *UserEventClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*UserEventClient) ImportUserEvents ¶
func (c *UserEventClient) ImportUserEvents(ctx context.Context, req *recommendationenginepb.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" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewUserEventClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.ImportUserEventsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#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) ListUserEvents ¶
func (c *UserEventClient) ListUserEvents(ctx context.Context, req *recommendationenginepb.ListUserEventsRequest, opts ...gax.CallOption) *UserEventIterator
ListUserEvents gets a list of user events within a time range, with potential filtering.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewUserEventClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.ListUserEventsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#ListUserEventsRequest. } it := c.ListUserEvents(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*recommendationenginepb.ListUserEventsResponse) } }
Output:
Example (All) ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewUserEventClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.ListUserEventsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#ListUserEventsRequest. } for resp, err := range c.ListUserEvents(ctx, req).All() { if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*UserEventClient) PurgeUserEvents ¶
func (c *UserEventClient) PurgeUserEvents(ctx context.Context, req *recommendationenginepb.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" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewUserEventClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.PurgeUserEventsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#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) WriteUserEvent ¶
func (c *UserEventClient) WriteUserEvent(ctx context.Context, req *recommendationenginepb.WriteUserEventRequest, opts ...gax.CallOption) (*recommendationenginepb.UserEvent, error)
WriteUserEvent writes a single user event.
Example ¶
package main import ( "context" recommendationengine "cloud.google.com/go/recommendationengine/apiv1beta1" recommendationenginepb "cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := recommendationengine.NewUserEventClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &recommendationenginepb.WriteUserEventRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/recommendationengine/apiv1beta1/recommendationenginepb#WriteUserEventRequest. } resp, err := c.WriteUserEvent(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type UserEventIterator ¶
type UserEventIterator 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 []*recommendationenginepb.UserEvent, nextPageToken string, err error) // contains filtered or unexported fields }
UserEventIterator manages a stream of *recommendationenginepb.UserEvent.
func (*UserEventIterator) All ¶ added in v0.9.1
func (it *UserEventIterator) All() iter.Seq2[*recommendationenginepb.UserEvent, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*UserEventIterator) Next ¶
func (it *UserEventIterator) Next() (*recommendationenginepb.UserEvent, 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 (*UserEventIterator) PageInfo ¶
func (it *UserEventIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.