Merchant API v1beta - Package cloud.google.com/go/shopping/merchant/conversions/apiv1beta (v0.14.0)

Package conversions 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:

Example usage

To get started with this package, create a client.

// go get cloud.google.com/go/shopping/merchant/conversions/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 := conversions.NewConversionSourcesClient(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 := &conversionspb.CreateConversionSourceRequest{
    // TODO: Fill request struct fields.
    // See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb#CreateConversionSourceRequest.
}
resp, err := c.CreateConversionSource(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

Use of Context

The ctx passed to NewConversionSourcesClient 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.

ConversionSourceIterator

type ConversionSourceIterator 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 []*conversionspb.ConversionSource, nextPageToken string, err error)
	// contains filtered or unexported fields
}

ConversionSourceIterator manages a stream of *conversionspb.ConversionSource.

func (*ConversionSourceIterator) All

func (it *ConversionSourceIterator) All() iter.Seq2[*conversionspb.ConversionSource, error]

All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.

func (*ConversionSourceIterator) Next

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 (*ConversionSourceIterator) PageInfo

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

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

ConversionSourcesCallOptions

type ConversionSourcesCallOptions struct {
	CreateConversionSource   []gax.CallOption
	UpdateConversionSource   []gax.CallOption
	DeleteConversionSource   []gax.CallOption
	UndeleteConversionSource []gax.CallOption
	GetConversionSource      []gax.CallOption
	ListConversionSources    []gax.CallOption
}

ConversionSourcesCallOptions contains the retry settings for each method of ConversionSourcesClient.

ConversionSourcesClient

type ConversionSourcesClient struct {

	// The call options for this service.
	CallOptions *ConversionSourcesCallOptions
	// contains filtered or unexported fields
}

ConversionSourcesClient 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 for managing conversion sources for a merchant account.

func NewConversionSourcesClient

func NewConversionSourcesClient(ctx context.Context, opts ...option.ClientOption) (*ConversionSourcesClient, error)

NewConversionSourcesClient creates a new conversion sources 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 conversion sources for a merchant account.

Example

package main

import (
	"context"

	conversions "cloud.google.com/go/shopping/merchant/conversions/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 := conversions.NewConversionSourcesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func NewConversionSourcesRESTClient

func NewConversionSourcesRESTClient(ctx context.Context, opts ...option.ClientOption) (*ConversionSourcesClient, error)

NewConversionSourcesRESTClient creates a new conversion sources service rest client.

Service for managing conversion sources for a merchant account.

Example

package main

import (
	"context"

	conversions "cloud.google.com/go/shopping/merchant/conversions/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 := conversions.NewConversionSourcesRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func (*ConversionSourcesClient) Close

func (c *ConversionSourcesClient) Close() error

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

func (*ConversionSourcesClient) Connection (deprecated)

func (c *ConversionSourcesClient) 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 (*ConversionSourcesClient) CreateConversionSource

CreateConversionSource creates a new conversion source.

Example

package main

import (
	"context"

	conversions "cloud.google.com/go/shopping/merchant/conversions/apiv1beta"
	conversionspb "cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb"
)

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 := conversions.NewConversionSourcesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &conversionspb.CreateConversionSourceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb#CreateConversionSourceRequest.
	}
	resp, err := c.CreateConversionSource(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*ConversionSourcesClient) DeleteConversionSource

DeleteConversionSource archives an existing conversion source. If the conversion source is a Merchant Center Destination, it will be recoverable for 30 days. If the conversion source is a Google Analytics Link, it will be deleted immediately and can be restored by creating a new one.

Example

package main

import (
	"context"

	conversions "cloud.google.com/go/shopping/merchant/conversions/apiv1beta"
	conversionspb "cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb"
)

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 := conversions.NewConversionSourcesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &conversionspb.DeleteConversionSourceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb#DeleteConversionSourceRequest.
	}
	err = c.DeleteConversionSource(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*ConversionSourcesClient) GetConversionSource

GetConversionSource fetches a conversion source.

Example

package main

import (
	"context"

	conversions "cloud.google.com/go/shopping/merchant/conversions/apiv1beta"
	conversionspb "cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb"
)

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 := conversions.NewConversionSourcesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &conversionspb.GetConversionSourceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb#GetConversionSourceRequest.
	}
	resp, err := c.GetConversionSource(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*ConversionSourcesClient) ListConversionSources

ListConversionSources retrieves the list of conversion sources the caller has access to.

Examples

package main

import (
	"context"

	conversions "cloud.google.com/go/shopping/merchant/conversions/apiv1beta"
	conversionspb "cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb"
	"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 := conversions.NewConversionSourcesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &conversionspb.ListConversionSourcesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb#ListConversionSourcesRequest.
	}
	it := c.ListConversionSources(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.(*conversionspb.ListConversionSourcesResponse)
	}
}
all
package main

import (
	"context"

	conversions "cloud.google.com/go/shopping/merchant/conversions/apiv1beta"
	conversionspb "cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb"
)

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 := conversions.NewConversionSourcesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &conversionspb.ListConversionSourcesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb#ListConversionSourcesRequest.
	}
	for resp, err := range c.ListConversionSources(ctx, req).All() {
		if err != nil {
			// TODO: Handle error and break/return/continue. Iteration will stop after any error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*ConversionSourcesClient) UndeleteConversionSource

UndeleteConversionSource re-enables an archived conversion source. Only Available for Merchant Center Destination conversion sources.

Example

package main

import (
	"context"

	conversions "cloud.google.com/go/shopping/merchant/conversions/apiv1beta"
	conversionspb "cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb"
)

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 := conversions.NewConversionSourcesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &conversionspb.UndeleteConversionSourceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb#UndeleteConversionSourceRequest.
	}
	resp, err := c.UndeleteConversionSource(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*ConversionSourcesClient) UpdateConversionSource

UpdateConversionSource updates information of an existing conversion source. Available only for Merchant Center Destination conversion sources.

Example

package main

import (
	"context"

	conversions "cloud.google.com/go/shopping/merchant/conversions/apiv1beta"
	conversionspb "cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb"
)

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 := conversions.NewConversionSourcesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &conversionspb.UpdateConversionSourceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/conversions/apiv1beta/conversionspb#UpdateConversionSourceRequest.
	}
	resp, err := c.UpdateConversionSource(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}