Retail V2 API - Class Google::Cloud::Retail::V2::CatalogService::Client (v0.7.0)

Reference documentation and code samples for the Retail V2 API class Google::Cloud::Retail::V2::CatalogService::Client.

Client for the CatalogService service.

Service for managing catalog configuration.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the CatalogService Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all CatalogService clients
::Google::Cloud::Retail::V2::CatalogService::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the CatalogService Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#get_default_branch

def get_default_branch(request, options = nil) -> ::Google::Cloud::Retail::V2::GetDefaultBranchResponse
def get_default_branch(catalog: nil) -> ::Google::Cloud::Retail::V2::GetDefaultBranchResponse

Get which branch is currently default branch set by CatalogService.SetDefaultBranch method under a specified parent catalog.

Overloads
def get_default_branch(request, options = nil) -> ::Google::Cloud::Retail::V2::GetDefaultBranchResponse
Pass arguments to get_default_branch via a request object, either of type GetDefaultBranchRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Retail::V2::GetDefaultBranchRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_default_branch(catalog: nil) -> ::Google::Cloud::Retail::V2::GetDefaultBranchResponse
Pass arguments to get_default_branch via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • catalog (::String) — The parent catalog resource name, such as projects/*/locations/global/catalogs/default_catalog.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/retail/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Retail::V2::CatalogService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Retail::V2::GetDefaultBranchRequest.new

# Call the get_default_branch method.
result = client.get_default_branch request

# The returned object is of type Google::Cloud::Retail::V2::GetDefaultBranchResponse.
p result

#initialize

def initialize() { |config| ... } -> Client

Create a new CatalogService client object.

Yields
  • (config) — Configure the CatalogService client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Retail::V2::CatalogService::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Retail::V2::CatalogService::Client.new do |config|
  config.timeout = 10.0
end

#list_catalogs

def list_catalogs(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Catalog>
def list_catalogs(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Catalog>

Lists all the {::Google::Cloud::Retail::V2::Catalog Catalog}s associated with the project.

Overloads
def list_catalogs(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Catalog>
Pass arguments to list_catalogs via a request object, either of type ListCatalogsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Retail::V2::ListCatalogsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_catalogs(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Catalog>
Pass arguments to list_catalogs via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The account resource name with an associated location.

    If the caller does not have permission to list {::Google::Cloud::Retail::V2::Catalog Catalog}s under this location, regardless of whether or not this location exists, a PERMISSION_DENIED error is returned.

  • page_size (::Integer) — Maximum number of Catalogs to return. If unspecified, defaults to 50. The maximum allowed value is 1000. Values above 1000 will be coerced to 1000.

    If this field is negative, an INVALID_ARGUMENT is returned.

  • page_token (::String) — A page token ListCatalogsResponse.next_page_token, received from a previous CatalogService.ListCatalogs call. Provide this to retrieve the subsequent page.

    When paginating, all other parameters provided to CatalogService.ListCatalogs must match the call that provided the page token. Otherwise, an INVALID_ARGUMENT error is returned.

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/retail/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Retail::V2::CatalogService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Retail::V2::ListCatalogsRequest.new

# Call the list_catalogs method.
result = client.list_catalogs request

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Retail::V2::Catalog.
  p response
end

#set_default_branch

def set_default_branch(request, options = nil) -> ::Google::Protobuf::Empty
def set_default_branch(catalog: nil, branch_id: nil, note: nil, force: nil) -> ::Google::Protobuf::Empty

Set a specified branch id as default branch. API methods such as SearchService.Search, ProductService.GetProduct, ProductService.ListProducts will treat requests using "default_branch" to the actual branch id set as default.

For example, if projects//locations//catalogs//branches/1 is set as default, setting SearchRequest.branch to projects//locations//catalogs//branches/default_branch is equivalent to setting SearchRequest.branch to projects//locations//catalogs/*/branches/1.

Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using projects//locations//catalogs/*/branches/default_branch as SearchRequest.branch to route the traffic to this staging branch.

CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one.

More specifically:

  • PredictionService will only return product IDs from branch {newBranch}.
  • SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set).
  • UserEventService will only join events with products from branch {newBranch}.
Overloads
def set_default_branch(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to set_default_branch via a request object, either of type SetDefaultBranchRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Retail::V2::SetDefaultBranchRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def set_default_branch(catalog: nil, branch_id: nil, note: nil, force: nil) -> ::Google::Protobuf::Empty
Pass arguments to set_default_branch via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • catalog (::String) — Full resource name of the catalog, such as projects/*/locations/global/catalogs/default_catalog.
  • branch_id (::String) — The final component of the resource name of a branch.

    This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT error is returned.

    If there are no sufficient active products in the targeted branch and force is not set, a FAILED_PRECONDITION error is returned.

  • note (::String) — Some note on this request, this can be retrieved by CatalogService.GetDefaultBranch before next valid default branch set occurs.

    This field must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an INVALID_ARGUMENT error is returned.

  • force (::Boolean) — If set to true, it permits switching to a branch with branch_id even if it has no sufficient active products.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/retail/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Retail::V2::CatalogService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Retail::V2::SetDefaultBranchRequest.new

# Call the set_default_branch method.
result = client.set_default_branch request

# The returned object is of type Google::Protobuf::Empty.
p result

#update_catalog

def update_catalog(request, options = nil) -> ::Google::Cloud::Retail::V2::Catalog
def update_catalog(catalog: nil, update_mask: nil) -> ::Google::Cloud::Retail::V2::Catalog

Updates the {::Google::Cloud::Retail::V2::Catalog Catalog}s.

Overloads
def update_catalog(request, options = nil) -> ::Google::Cloud::Retail::V2::Catalog
Pass arguments to update_catalog via a request object, either of type UpdateCatalogRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Retail::V2::UpdateCatalogRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def update_catalog(catalog: nil, update_mask: nil) -> ::Google::Cloud::Retail::V2::Catalog
Pass arguments to update_catalog via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • catalog (::Google::Cloud::Retail::V2::Catalog, ::Hash) — Required. The Catalog to update.

    If the caller does not have permission to update the Catalog, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.

    If the Catalog to update does not exist, a NOT_FOUND error is returned.

  • update_mask (::Google::Protobuf::FieldMask, ::Hash) — Indicates which fields in the provided Catalog to update.

    If an unsupported or unknown field is provided, an INVALID_ARGUMENT error is returned.

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/retail/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Retail::V2::CatalogService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Retail::V2::UpdateCatalogRequest.new

# Call the update_catalog method.
result = client.update_catalog request

# The returned object is of type Google::Cloud::Retail::V2::Catalog.
p result