Package reviews is an auto-generated package for the Merchant API.
Programmatically manage your Merchant Center Accounts.
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.
// go get cloud.google.com/go/shopping/merchant/reviews/apiv1beta@latest 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 := reviews.NewMerchantReviewsClient(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, mentioned above.
req := &reviewspb.DeleteMerchantReviewRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#DeleteMerchantReviewRequest. } err = c.DeleteMerchantReview(ctx, req) if err != nil { // TODO: Handle error. }
Use of Context
The ctx passed to NewMerchantReviewsClient 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.
Functions
func DefaultAuthScopes
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
MerchantReviewIterator
type MerchantReviewIterator 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 []*reviewspb.MerchantReview, nextPageToken string, err error)
// contains filtered or unexported fields
}
MerchantReviewIterator manages a stream of *reviewspb.MerchantReview.
func (*MerchantReviewIterator) All
func (it *MerchantReviewIterator) All() iter.Seq2[*reviewspb.MerchantReview, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*MerchantReviewIterator) Next
func (it *MerchantReviewIterator) Next() (*reviewspb.MerchantReview, 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 (*MerchantReviewIterator) PageInfo
func (it *MerchantReviewIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
MerchantReviewsCallOptions
type MerchantReviewsCallOptions struct {
GetMerchantReview []gax.CallOption
ListMerchantReviews []gax.CallOption
InsertMerchantReview []gax.CallOption
DeleteMerchantReview []gax.CallOption
}
MerchantReviewsCallOptions contains the retry settings for each method of MerchantReviewsClient.
MerchantReviewsClient
type MerchantReviewsClient struct {
// The call options for this service.
CallOptions *MerchantReviewsCallOptions
// contains filtered or unexported fields
}
MerchantReviewsClient is a client for interacting with Merchant API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service to manage merchant reviews.
func NewMerchantReviewsClient
func NewMerchantReviewsClient(ctx context.Context, opts ...option.ClientOption) (*MerchantReviewsClient, error)
NewMerchantReviewsClient creates a new merchant reviews service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Service to manage merchant reviews.
Example
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
)
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 := reviews.NewMerchantReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewMerchantReviewsRESTClient
func NewMerchantReviewsRESTClient(ctx context.Context, opts ...option.ClientOption) (*MerchantReviewsClient, error)
NewMerchantReviewsRESTClient creates a new merchant reviews service rest client.
Service to manage merchant reviews.
Example
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
)
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 := reviews.NewMerchantReviewsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*MerchantReviewsClient) Close
func (c *MerchantReviewsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*MerchantReviewsClient) Connection (deprecated)
func (c *MerchantReviewsClient) 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 (*MerchantReviewsClient) DeleteMerchantReview
func (c *MerchantReviewsClient) DeleteMerchantReview(ctx context.Context, req *reviewspb.DeleteMerchantReviewRequest, opts ...gax.CallOption) error
DeleteMerchantReview deletes merchant review.
Example
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
reviewspb "cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb"
)
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 := reviews.NewMerchantReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reviewspb.DeleteMerchantReviewRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#DeleteMerchantReviewRequest.
}
err = c.DeleteMerchantReview(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*MerchantReviewsClient) GetMerchantReview
func (c *MerchantReviewsClient) GetMerchantReview(ctx context.Context, req *reviewspb.GetMerchantReviewRequest, opts ...gax.CallOption) (*reviewspb.MerchantReview, error)
GetMerchantReview gets a merchant review.
Example
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
reviewspb "cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb"
)
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 := reviews.NewMerchantReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reviewspb.GetMerchantReviewRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#GetMerchantReviewRequest.
}
resp, err := c.GetMerchantReview(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*MerchantReviewsClient) InsertMerchantReview
func (c *MerchantReviewsClient) InsertMerchantReview(ctx context.Context, req *reviewspb.InsertMerchantReviewRequest, opts ...gax.CallOption) (*reviewspb.MerchantReview, error)
InsertMerchantReview inserts a review for your Merchant Center account. If the review already exists, then the review is replaced with the new instance.
Example
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
reviewspb "cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb"
)
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 := reviews.NewMerchantReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reviewspb.InsertMerchantReviewRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#InsertMerchantReviewRequest.
}
resp, err := c.InsertMerchantReview(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*MerchantReviewsClient) ListMerchantReviews
func (c *MerchantReviewsClient) ListMerchantReviews(ctx context.Context, req *reviewspb.ListMerchantReviewsRequest, opts ...gax.CallOption) *MerchantReviewIterator
ListMerchantReviews lists merchant reviews.
Examples
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
reviewspb "cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb"
"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 := reviews.NewMerchantReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reviewspb.ListMerchantReviewsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#ListMerchantReviewsRequest.
}
it := c.ListMerchantReviews(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.(*reviewspb.ListMerchantReviewsResponse)
}
}
all
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
reviewspb "cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb"
)
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 := reviews.NewMerchantReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reviewspb.ListMerchantReviewsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#ListMerchantReviewsRequest.
}
for resp, err := range c.ListMerchantReviews(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
ProductReviewIterator
type ProductReviewIterator 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 []*reviewspb.ProductReview, nextPageToken string, err error)
// contains filtered or unexported fields
}
ProductReviewIterator manages a stream of *reviewspb.ProductReview.
func (*ProductReviewIterator) All
func (it *ProductReviewIterator) All() iter.Seq2[*reviewspb.ProductReview, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ProductReviewIterator) Next
func (it *ProductReviewIterator) Next() (*reviewspb.ProductReview, 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 (*ProductReviewIterator) PageInfo
func (it *ProductReviewIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ProductReviewsCallOptions
type ProductReviewsCallOptions struct {
GetProductReview []gax.CallOption
ListProductReviews []gax.CallOption
InsertProductReview []gax.CallOption
DeleteProductReview []gax.CallOption
}
ProductReviewsCallOptions contains the retry settings for each method of ProductReviewsClient.
ProductReviewsClient
type ProductReviewsClient struct {
// The call options for this service.
CallOptions *ProductReviewsCallOptions
// contains filtered or unexported fields
}
ProductReviewsClient is a client for interacting with Merchant API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service to manage product reviews.
func NewProductReviewsClient
func NewProductReviewsClient(ctx context.Context, opts ...option.ClientOption) (*ProductReviewsClient, error)
NewProductReviewsClient creates a new product reviews service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Service to manage product reviews.
Example
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
)
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 := reviews.NewProductReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewProductReviewsRESTClient
func NewProductReviewsRESTClient(ctx context.Context, opts ...option.ClientOption) (*ProductReviewsClient, error)
NewProductReviewsRESTClient creates a new product reviews service rest client.
Service to manage product reviews.
Example
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
)
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 := reviews.NewProductReviewsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*ProductReviewsClient) Close
func (c *ProductReviewsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*ProductReviewsClient) Connection (deprecated)
func (c *ProductReviewsClient) 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 (*ProductReviewsClient) DeleteProductReview
func (c *ProductReviewsClient) DeleteProductReview(ctx context.Context, req *reviewspb.DeleteProductReviewRequest, opts ...gax.CallOption) error
DeleteProductReview deletes a product review.
Example
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
reviewspb "cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb"
)
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 := reviews.NewProductReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reviewspb.DeleteProductReviewRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#DeleteProductReviewRequest.
}
err = c.DeleteProductReview(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*ProductReviewsClient) GetProductReview
func (c *ProductReviewsClient) GetProductReview(ctx context.Context, req *reviewspb.GetProductReviewRequest, opts ...gax.CallOption) (*reviewspb.ProductReview, error)
GetProductReview gets a product review.
Example
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
reviewspb "cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb"
)
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 := reviews.NewProductReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reviewspb.GetProductReviewRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#GetProductReviewRequest.
}
resp, err := c.GetProductReview(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*ProductReviewsClient) InsertProductReview
func (c *ProductReviewsClient) InsertProductReview(ctx context.Context, req *reviewspb.InsertProductReviewRequest, opts ...gax.CallOption) (*reviewspb.ProductReview, error)
InsertProductReview inserts a product review.
Example
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
reviewspb "cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb"
)
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 := reviews.NewProductReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reviewspb.InsertProductReviewRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#InsertProductReviewRequest.
}
resp, err := c.InsertProductReview(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*ProductReviewsClient) ListProductReviews
func (c *ProductReviewsClient) ListProductReviews(ctx context.Context, req *reviewspb.ListProductReviewsRequest, opts ...gax.CallOption) *ProductReviewIterator
ListProductReviews lists product reviews.
Examples
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
reviewspb "cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb"
"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 := reviews.NewProductReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reviewspb.ListProductReviewsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#ListProductReviewsRequest.
}
it := c.ListProductReviews(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.(*reviewspb.ListProductReviewsResponse)
}
}
all
package main
import (
"context"
reviews "cloud.google.com/go/shopping/merchant/reviews/apiv1beta"
reviewspb "cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb"
)
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 := reviews.NewProductReviewsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reviewspb.ListProductReviewsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/reviews/apiv1beta/reviewspb#ListProductReviewsRequest.
}
for resp, err := range c.ListProductReviews(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}