Package css is an auto-generated package for the CSS API.
Programmatically manage your Comparison Shopping Service (CSS) account data at scale.
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 := css.NewAccountsClient(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 := css.NewAccountsClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &csspb.GetAccountRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/shopping/css/apiv1/csspb#GetAccountRequest. } resp, err := c.GetAccount(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewAccountsClient 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.
AccountIterator
type AccountIterator 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 []*csspb.Account, nextPageToken string, err error)
// contains filtered or unexported fields
}
AccountIterator manages a stream of *csspb.Account.
func (*AccountIterator) Next
func (it *AccountIterator) Next() (*csspb.Account, 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 (*AccountIterator) PageInfo
func (it *AccountIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
AccountLabelIterator
type AccountLabelIterator 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 []*csspb.AccountLabel, nextPageToken string, err error)
// contains filtered or unexported fields
}
AccountLabelIterator manages a stream of *csspb.AccountLabel.
func (*AccountLabelIterator) Next
func (it *AccountLabelIterator) Next() (*csspb.AccountLabel, 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 (*AccountLabelIterator) PageInfo
func (it *AccountLabelIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
AccountLabelsCallOptions
type AccountLabelsCallOptions struct {
ListAccountLabels []gax.CallOption
CreateAccountLabel []gax.CallOption
UpdateAccountLabel []gax.CallOption
DeleteAccountLabel []gax.CallOption
}
AccountLabelsCallOptions contains the retry settings for each method of AccountLabelsClient.
AccountLabelsClient
type AccountLabelsClient struct {
// The call options for this service.
CallOptions *AccountLabelsCallOptions
// contains filtered or unexported fields
}
AccountLabelsClient is a client for interacting with CSS API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Manages Merchant Center and CSS accounts labels.
func NewAccountLabelsClient
func NewAccountLabelsClient(ctx context.Context, opts ...option.ClientOption) (*AccountLabelsClient, error)
NewAccountLabelsClient creates a new account labels service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Manages Merchant Center and CSS accounts labels.
Example
package main
import (
"context"
css "cloud.google.com/go/shopping/css/apiv1"
)
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 := css.NewAccountLabelsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewAccountLabelsRESTClient
func NewAccountLabelsRESTClient(ctx context.Context, opts ...option.ClientOption) (*AccountLabelsClient, error)
NewAccountLabelsRESTClient creates a new account labels service rest client.
Manages Merchant Center and CSS accounts labels.
Example
package main
import (
"context"
css "cloud.google.com/go/shopping/css/apiv1"
)
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 := css.NewAccountLabelsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*AccountLabelsClient) Close
func (c *AccountLabelsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*AccountLabelsClient) Connection (deprecated)
func (c *AccountLabelsClient) 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 (*AccountLabelsClient) CreateAccountLabel
func (c *AccountLabelsClient) CreateAccountLabel(ctx context.Context, req *csspb.CreateAccountLabelRequest, opts ...gax.CallOption) (*csspb.AccountLabel, error)
CreateAccountLabel creates a new label, not assigned to any account.
Example
package main
import (
"context"
css "cloud.google.com/go/shopping/css/apiv1"
csspb "cloud.google.com/go/shopping/css/apiv1/csspb"
)
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 := css.NewAccountLabelsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &csspb.CreateAccountLabelRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/css/apiv1/csspb#CreateAccountLabelRequest.
}
resp, err := c.CreateAccountLabel(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*AccountLabelsClient) DeleteAccountLabel
func (c *AccountLabelsClient) DeleteAccountLabel(ctx context.Context, req *csspb.DeleteAccountLabelRequest, opts ...gax.CallOption) error
DeleteAccountLabel deletes a label and removes it from all accounts to which it was assigned.
Example
package main
import (
"context"
css "cloud.google.com/go/shopping/css/apiv1"
csspb "cloud.google.com/go/shopping/css/apiv1/csspb"
)
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 := css.NewAccountLabelsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &csspb.DeleteAccountLabelRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/css/apiv1/csspb#DeleteAccountLabelRequest.
}
err = c.DeleteAccountLabel(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*AccountLabelsClient) ListAccountLabels
func (c *AccountLabelsClient) ListAccountLabels(ctx context.Context, req *csspb.ListAccountLabelsRequest, opts ...gax.CallOption) *AccountLabelIterator
ListAccountLabels lists the labels assigned to an account.
Example
package main
import (
"context"
css "cloud.google.com/go/shopping/css/apiv1"
csspb "cloud.google.com/go/shopping/css/apiv1/csspb"
"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 := css.NewAccountLabelsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &csspb.ListAccountLabelsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/shopping/css/apiv1/csspb#ListAccountLabelsRequest.
}
it := c.ListAccountLabels(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func (*AccountLabelsClient) UpdateAccountLabel
func (c *AccountLabelsClient) UpdateAccountLabel(ctx