Class: Google::Cloud::Retail::V2::ProductService::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/retail/v2/product_service/client.rb

Overview

Client for the ProductService service.

Service for ingesting Product information of the customer's website.

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#branch_path, #product_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new ProductService client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::Retail::V2::ProductService::Client.new

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

Yields:

  • (config)

    Configure the ProductService client.

Yield Parameters:



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 136

def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/cloud/retail/v2/product_service_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @operations_client = Operations.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @config.endpoint
    config.universe_domain = @config.universe_domain
  end

  @product_service_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::Retail::V2::ProductService::Stub,
    credentials: credentials,
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors,
    channel_pool_config: @config.channel_pool,
    logger: @config.logger
  )

  @product_service_stub.stub_logger&.info do |entry|
    entry.set_system_name
    entry.set_service
    entry.message = "Created client for #{entry.service}"
    entry.set_credentials_fields credentials
    entry.set "customEndpoint", @config.endpoint if @config.endpoint
    entry.set "defaultTimeout", @config.timeout if @config.timeout
    entry.set "quotaProject", @quota_project_id if @quota_project_id
  end

  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @product_service_stub.endpoint
    config.universe_domain = @product_service_stub.universe_domain
    config.logger = @product_service_stub.logger if config.respond_to? :logger=
  end
end

Instance Attribute Details

#location_clientGoogle::Cloud::Location::Locations::Client (readonly)

Get the associated client for mix-in of the Locations.

Returns:

  • (Google::Cloud::Location::Locations::Client)


214
215
216
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 214

def location_client
  @location_client
end

#operations_client::Google::Cloud::Retail::V2::ProductService::Operations (readonly)

Get the associated client for long-running operations.



207
208
209
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 207

def operations_client
  @operations_client
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the ProductService Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all ProductService clients
::Google::Cloud::Retail::V2::ProductService::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 64

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Retail", "V2"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.timeout = 30.0
    default_config.retry_policy = {
      initial_delay: 0.1, max_delay: 30.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.import_products.timeout = 300.0
    default_config.rpcs.import_products.retry_policy = {
      initial_delay: 0.1, max_delay: 300.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#add_fulfillment_places(request, options = nil) ⇒ ::Gapic::Operation #add_fulfillment_places(product: nil, type: nil, place_ids: nil, add_time: nil, allow_missing: nil) ⇒ ::Gapic::Operation

We recommend that you use the ProductService.AddLocalInventories method instead of the ProductService.AddFulfillmentPlaces method. ProductService.AddLocalInventories achieves the same results but provides more fine-grained control over ingesting local inventory data.

Incrementally adds place IDs to Product.fulfillment_info.place_ids.

This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts.

The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards.

If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #add_fulfillment_places(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to add_fulfillment_places via a request object, either of type AddFulfillmentPlacesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::AddFulfillmentPlacesRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #add_fulfillment_places(product: nil, type: nil, place_ids: nil, add_time: nil, allow_missing: nil) ⇒ ::Gapic::Operation

    Pass arguments to add_fulfillment_places 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:

    • product (::String) (defaults to: nil)

      Required. Full resource name of Product, such as projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id.

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

    • type (::String) (defaults to: nil)

      Required. The fulfillment type, including commonly used types (such as pickup in store and same day delivery), and custom types.

      Supported values:

      • "pickup-in-store"
      • "ship-to-store"
      • "same-day-delivery"
      • "next-day-delivery"
      • "custom-type-1"
      • "custom-type-2"
      • "custom-type-3"
      • "custom-type-4"
      • "custom-type-5"

      If this field is set to an invalid value other than these, an INVALID_ARGUMENT error is returned.

      This field directly corresponds to Product.fulfillment_info.type.

    • place_ids (::Array<::String>) (defaults to: nil)

      Required. The IDs for this type, such as the store IDs for "pickup-in-store" or the region IDs for "same-day-delivery" to be added for this type. Duplicate IDs will be automatically ignored.

      At least 1 value is required, and a maximum of 2000 values are allowed. Each value must be a string with a length limit of 10 characters, matching the pattern [a-zA-Z0-9_-]+, such as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is returned.

      If the total number of place IDs exceeds 2000 for this type after adding, then the update will be rejected.

    • add_time (::Google::Protobuf::Timestamp, ::Hash) (defaults to: nil)

      The time when the fulfillment updates are issued, used to prevent out-of-order updates on fulfillment information. If not provided, the internal system time will be used.

    • allow_missing (::Boolean) (defaults to: nil)

      If set to true, and the Product is not found, the fulfillment information will still be processed and retained for at most 1 day and processed once the Product is created. If set to false, a NOT_FOUND error is returned if the Product is not found.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 1446

def add_fulfillment_places request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::AddFulfillmentPlacesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.add_fulfillment_places..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.product
    header_params["product"] = request.product
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.add_fulfillment_places.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.add_fulfillment_places.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :add_fulfillment_places, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#add_local_inventories(request, options = nil) ⇒ ::Gapic::Operation #add_local_inventories(product: nil, local_inventories: nil, add_mask: nil, add_time: nil, allow_missing: nil) ⇒ ::Gapic::Operation

Updates local inventory information for a Product at a list of places, while respecting the last update timestamps of each inventory field.

This process is asynchronous and does not require the Product to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts.

Local inventory information can only be modified using this method. ProductService.CreateProduct and ProductService.UpdateProduct has no effect on local inventories.

The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards.

If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #add_local_inventories(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to add_local_inventories via a request object, either of type AddLocalInventoriesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::AddLocalInventoriesRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #add_local_inventories(product: nil, local_inventories: nil, add_mask: nil, add_time: nil, allow_missing: nil) ⇒ ::Gapic::Operation

    Pass arguments to add_local_inventories 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:

    • product (::String) (defaults to: nil)

      Required. Full resource name of Product, such as projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id.

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

    • local_inventories (::Array<::Google::Cloud::Retail::V2::LocalInventory, ::Hash>) (defaults to: nil)

      Required. A list of inventory information at difference places. Each place is identified by its place ID. At most 3000 inventories are allowed per request.

    • add_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      Indicates which inventory fields in the provided list of LocalInventory to update. The field is updated to the provided value.

      If a field is set while the place does not have a previous local inventory, the local inventory at that store is created.

      If a field is set while the value of that field is not provided, the original field value, if it exists, is deleted.

      If the mask is not set or set with empty paths, all inventory fields will be updated.

      If an unsupported or unknown field is provided, an INVALID_ARGUMENT error is returned and the entire update will be ignored.

    • add_time (::Google::Protobuf::Timestamp, ::Hash) (defaults to: nil)

      The time when the inventory updates are issued. Used to prevent out-of-order updates on local inventory fields. If not provided, the internal system time will be used.

    • allow_missing (::Boolean) (defaults to: nil)

      If set to true, and the Product is not found, the local inventory will still be processed and retained for at most 1 day and processed once the Product is created. If set to false, a NOT_FOUND error is returned if the Product is not found.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 1775

def add_local_inventories request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::AddLocalInventoriesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.add_local_inventories..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.product
    header_params["product"] = request.product
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.add_local_inventories.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.add_local_inventories.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :add_local_inventories, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#configure {|config| ... } ⇒ Client::Configuration

Configure the ProductService 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 configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



106
107
108
109
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 106

def configure
  yield @config if block_given?
  @config
end

#create_product(request, options = nil) ⇒ ::Google::Cloud::Retail::V2::Product #create_product(parent: nil, product: nil, product_id: nil) ⇒ ::Google::Cloud::Retail::V2::Product

Creates a Product.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

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

Overloads:

  • #create_product(request, options = nil) ⇒ ::Google::Cloud::Retail::V2::Product

    Pass arguments to create_product via a request object, either of type CreateProductRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::CreateProductRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_product(parent: nil, product: nil, product_id: nil) ⇒ ::Google::Cloud::Retail::V2::Product

    Pass arguments to create_product 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) (defaults to: nil)

      Required. The parent catalog resource name, such as projects/*/locations/global/catalogs/default_catalog/branches/default_branch.

    • product (::Google::Cloud::Retail::V2::Product, ::Hash) (defaults to: nil)

      Required. The Product to create.

    • product_id (::String) (defaults to: nil)

      Required. The ID to use for the Product, which will become the final component of the Product.name.

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

      This field must be unique among all Products with the same parent. Otherwise, an ALREADY_EXISTS error is returned.

      This field must be a UTF-8 encoded string with a length limit of 128 characters. 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.



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 290

def create_product request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::CreateProductRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_product..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_product.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_product.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :create_product, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_product(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_product(name: nil) ⇒ ::Google::Protobuf::Empty

Deletes a Product.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

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

Overloads:

  • #delete_product(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_product via a request object, either of type DeleteProductRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::DeleteProductRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_product(name: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_product 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:

    • name (::String) (defaults to: nil)

      Required. Full resource name of Product, such as projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id.

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

      If the Product to delete does not exist, a NOT_FOUND error is returned.

      The Product to delete can neither be a Product.Type.COLLECTION Product member nor a Product.Type.PRIMARY Product with more than one variants. Otherwise, an INVALID_ARGUMENT error is returned.

      All inventory information for the named Product will be deleted.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 762

def delete_product request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::DeleteProductRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_product..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_product.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_product.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :delete_product, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_product(request, options = nil) ⇒ ::Google::Cloud::Retail::V2::Product #get_product(name: nil) ⇒ ::Google::Cloud::Retail::V2::Product

Gets a Product.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

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

Overloads:

  • #get_product(request, options = nil) ⇒ ::Google::Cloud::Retail::V2::Product

    Pass arguments to get_product via a request object, either of type GetProductRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::GetProductRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_product(name: nil) ⇒ ::Google::Cloud::Retail::V2::Product

    Pass arguments to get_product 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:

    • name (::String) (defaults to: nil)

      Required. Full resource name of Product, such as projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id.

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

      If the requested Product does not exist, a NOT_FOUND 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.



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 384

def get_product request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::GetProductRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_product..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_product.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_product.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :get_product, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#import_products(request, options = nil) ⇒ ::Gapic::Operation #import_products(parent: nil, request_id: nil, input_config: nil, errors_config: nil, update_mask: nil, reconciliation_mode: nil, notification_pubsub_topic: nil) ⇒ ::Gapic::Operation

Bulk import of multiple Products.

Request processing may be synchronous. Non-existing items are created.

Note that it is possible for a subset of the Products to be successfully updated.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #import_products(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to import_products via a request object, either of type ImportProductsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::ImportProductsRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #import_products(parent: nil, request_id: nil, input_config: nil, errors_config: nil, update_mask: nil, reconciliation_mode: nil, notification_pubsub_topic: nil) ⇒ ::Gapic::Operation

    Pass arguments to import_products 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) (defaults to: nil)

      Required. projects/1234/locations/global/catalogs/default_catalog/branches/default_branch

      If no updateMask is specified, requires products.create permission. If updateMask is specified, requires products.update permission.

    • request_id (::String) (defaults to: nil)

      Deprecated. This field has no effect.

    • input_config (::Google::Cloud::Retail::V2::ProductInputConfig, ::Hash) (defaults to: nil)

      Required. The desired input location of the data.

    • errors_config (::Google::Cloud::Retail::V2::ImportErrorsConfig, ::Hash) (defaults to: nil)

      The desired location of errors incurred during the Import.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      Indicates which fields in the provided imported products to update. If not set, all fields are updated. If provided, only the existing product fields are updated. Missing products will not be created.

    • reconciliation_mode (::Google::Cloud::Retail::V2::ImportProductsRequest::ReconciliationMode) (defaults to: nil)

      The mode of reconciliation between existing products and the products to be imported. Defaults to ReconciliationMode.INCREMENTAL.

    • notification_pubsub_topic (::String) (defaults to: nil)

      Full Pub/Sub topic name for receiving notification. If this field is set, when the import is finished, a notification is sent to specified Pub/Sub topic. The message data is JSON string of a Operation.

      Format of the Pub/Sub topic is projects/{project}/topics/{topic}. It has to be within the same project as ImportProductsRequest.parent. Make sure that both [email protected] and service-<project number>@gcp-sa-retail.iam.gserviceaccount.com have the pubsub.topics.publish IAM permission on the topic.

      Only supported when ImportProductsRequest.reconciliation_mode is set to FULL.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 1051

def import_products request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::ImportProductsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.import_products..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.import_products.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.import_products.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :import_products, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_products(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Product> #list_products(parent: nil, page_size: nil, page_token: nil, filter: nil, read_mask: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Product>

Gets a list of Products.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Retail::V2::Product.
  p item
end

Overloads:

  • #list_products(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Product>

    Pass arguments to list_products via a request object, either of type ListProductsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::ListProductsRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_products(parent: nil, page_size: nil, page_token: nil, filter: nil, read_mask: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Retail::V2::Product>

    Pass arguments to list_products 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) (defaults to: nil)

      Required. The parent branch resource name, such as projects/*/locations/global/catalogs/default_catalog/branches/0. Use default_branch as the branch ID, to list products under the default branch.

      If the caller does not have permission to list Products under this branch, regardless of whether or not this branch exists, a PERMISSION_DENIED error is returned.

    • page_size (::Integer) (defaults to: nil)

      Maximum number of Products to return. If unspecified, defaults to 100. The maximum allowed value is 1000. Values above 1000 will be coerced to 1000.

      If this field is negative, an INVALID_ARGUMENT error is returned.

    • page_token (::String) (defaults to: nil)

      A page token ListProductsResponse.next_page_token, received from a previous ProductService.ListProducts call. Provide this to retrieve the subsequent page.

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

    • filter (::String) (defaults to: nil)

      A filter to apply on the list results. Supported features:

      If the field is unrecognizable, an INVALID_ARGUMENT error is returned.

      If the specified Product.Type.PRIMARY Product or Product.Type.COLLECTION Product does not exist, a NOT_FOUND error is returned.

    • read_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      The fields of Product to return in the responses. If not set or empty, the following fields are returned:

      If "*" is provided, all fields are returned. Product.name is always returned no matter what mask is set.

      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:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 544

def list_products request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::ListProductsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_products..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_products.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_products.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :list_products, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @product_service_stub, :list_products, request, response, operation, options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#loggerLogger

The logger used for request/response debug logging.

Returns:

  • (Logger)


221
222
223
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 221

def logger
  @product_service_stub.logger
end

#purge_products(request, options = nil) ⇒ ::Gapic::Operation #purge_products(parent: nil, filter: nil, force: nil) ⇒ ::Gapic::Operation

Permanently deletes all selected Products under a branch.

This process is asynchronous. If the request is valid, the removal will be enqueued and processed offline. Depending on the number of Products, this operation could take hours to complete. Before the operation completes, some Products may still be returned by ProductService.GetProduct or ProductService.ListProducts.

Depending on the number of Products, this operation could take hours to complete. To get a sample of Products that would be deleted, set PurgeProductsRequest.force to false.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #purge_products(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to purge_products via a request object, either of type Google::Cloud::Retail::V2::PurgeProductsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::PurgeProductsRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #purge_products(parent: nil, filter: nil, force: nil) ⇒ ::Gapic::Operation

    Pass arguments to purge_products 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) (defaults to: nil)

      Required. The resource name of the branch under which the products are created. The format is projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}

    • filter (::String) (defaults to: nil)

      Required. The filter string to specify the products to be deleted with a length limit of 5,000 characters.

      Empty string filter is not allowed. "*" implies delete all items in a branch.

      The eligible fields for filtering are:

      Supported syntax:

      • Comparators (">", "<", ">=", "<=", "="). Examples:

        • create_time <= "2015-02-13T17:05:46Z"
        • availability = "IN_STOCK"
      • Conjunctions ("AND") Examples:

        • create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER"
      • Disjunctions ("OR") Examples:

        • create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK"
      • Can support nested queries. Examples:

        • (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK")
      • Filter Limits:

        • Filter should not contain more than 6 conditions.
        • Max nesting depth should not exceed 2 levels.

      Examples queries:

      • Delete back order products created before a timestamp. create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER"
    • force (::Boolean) (defaults to: nil)

      Actually perform the purge. If force is set to false, the method will return the expected purge count without deleting any products.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 916

def purge_products request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::PurgeProductsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.purge_products..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.purge_products.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.purge_products.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :purge_products, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#remove_fulfillment_places(request, options = nil) ⇒ ::Gapic::Operation #remove_fulfillment_places(product: nil, type: nil, place_ids: nil, remove_time: nil, allow_missing: nil) ⇒ ::Gapic::Operation

We recommend that you use the ProductService.RemoveLocalInventories method instead of the ProductService.RemoveFulfillmentPlaces method. ProductService.RemoveLocalInventories achieves the same results but provides more fine-grained control over ingesting local inventory data.

Incrementally removes place IDs from a Product.fulfillment_info.place_ids.

This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts.

The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards.

If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #remove_fulfillment_places(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to remove_fulfillment_places via a request object, either of type RemoveFulfillmentPlacesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::RemoveFulfillmentPlacesRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #remove_fulfillment_places(product: nil, type: nil, place_ids: nil, remove_time: nil, allow_missing: nil) ⇒ ::Gapic::Operation

    Pass arguments to remove_fulfillment_places 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:

    • product (::String) (defaults to: nil)

      Required. Full resource name of Product, such as projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id.

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

    • type (::String) (defaults to: nil)

      Required. The fulfillment type, including commonly used types (such as pickup in store and same day delivery), and custom types.

      Supported values:

      • "pickup-in-store"
      • "ship-to-store"
      • "same-day-delivery"
      • "next-day-delivery"
      • "custom-type-1"
      • "custom-type-2"
      • "custom-type-3"
      • "custom-type-4"
      • "custom-type-5"

      If this field is set to an invalid value other than these, an INVALID_ARGUMENT error is returned.

      This field directly corresponds to Product.fulfillment_info.type.

    • place_ids (::Array<::String>) (defaults to: nil)

      Required. The IDs for this type, such as the store IDs for "pickup-in-store" or the region IDs for "same-day-delivery", to be removed for this type.

      At least 1 value is required, and a maximum of 2000 values are allowed. Each value must be a string with a length limit of 10 characters, matching the pattern [a-zA-Z0-9_-]+, such as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is returned.

    • remove_time (::Google::Protobuf::Timestamp, ::Hash) (defaults to: nil)

      The time when the fulfillment updates are issued, used to prevent out-of-order updates on fulfillment information. If not provided, the internal system time will be used.

    • allow_missing (::Boolean) (defaults to: nil)

      If set to true, and the Product is not found, the fulfillment information will still be processed and retained for at most 1 day and processed once the Product is created. If set to false, a NOT_FOUND error is returned if the Product is not found.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 1618

def remove_fulfillment_places request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::RemoveFulfillmentPlacesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.remove_fulfillment_places..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.product
    header_params["product"] = request.product
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.remove_fulfillment_places.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.remove_fulfillment_places.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :remove_fulfillment_places, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#remove_local_inventories(request, options = nil) ⇒ ::Gapic::Operation #remove_local_inventories(product: nil, place_ids: nil, remove_time: nil, allow_missing: nil) ⇒ ::Gapic::Operation

Remove local inventory information for a Product at a list of places at a removal timestamp.

This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts.

Local inventory information can only be removed using this method. ProductService.CreateProduct and ProductService.UpdateProduct has no effect on local inventories.

The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards.

If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #remove_local_inventories(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to remove_local_inventories via a request object, either of type RemoveLocalInventoriesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::RemoveLocalInventoriesRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #remove_local_inventories(product: nil, place_ids: nil, remove_time: nil, allow_missing: nil) ⇒ ::Gapic::Operation

    Pass arguments to remove_local_inventories 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:

    • product (::String) (defaults to: nil)

      Required. Full resource name of Product, such as projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id.

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

    • place_ids (::Array<::String>) (defaults to: nil)

      Required. A list of place IDs to have their inventory deleted. At most 3000 place IDs are allowed per request.

    • remove_time (::Google::Protobuf::Timestamp, ::Hash) (defaults to: nil)

      The time when the inventory deletions are issued. Used to prevent out-of-order updates and deletions on local inventory fields. If not provided, the internal system time will be used.

    • allow_missing (::Boolean) (defaults to: nil)

      If set to true, and the Product is not found, the local inventory removal request will still be processed and retained for at most 1 day and processed once the Product is created. If set to false, a NOT_FOUND error is returned if the Product is not found.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 1914

def remove_local_inventories request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::RemoveLocalInventoriesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.remove_local_inventories..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.product
    header_params["product"] = request.product
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.remove_local_inventories.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.remove_local_inventories.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :remove_local_inventories, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_inventory(request, options = nil) ⇒ ::Gapic::Operation #set_inventory(inventory: nil, set_mask: nil, set_time: nil, allow_missing: nil) ⇒ ::Gapic::Operation

Updates inventory information for a Product while respecting the last update timestamps of each inventory field.

This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update is enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts.

When inventory is updated with ProductService.CreateProduct and ProductService.UpdateProduct, the specified inventory field value(s) overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update times for the specified inventory fields are overwritten by the times of the ProductService.CreateProduct or ProductService.UpdateProduct request.

If no inventory fields are set in CreateProductRequest.product, then any pre-existing inventory information for this product is used.

If no inventory fields are set in SetInventoryRequest.set_mask, then any existing inventory information is preserved.

Pre-existing inventory information can only be updated with ProductService.SetInventory, ProductService.AddFulfillmentPlaces, and ProductService.RemoveFulfillmentPlaces.

The returned Operations is obsolete after one day, and the GetOperation API returns NOT_FOUND afterwards.

If conflicting updates are issued, the Operations associated with the stale updates are not marked as done until they are obsolete.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #set_inventory(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to set_inventory via a request object, either of type SetInventoryRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::SetInventoryRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #set_inventory(inventory: nil, set_mask: nil, set_time: nil, allow_missing: nil) ⇒ ::Gapic::Operation

    Pass arguments to set_inventory 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:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 1269

def set_inventory request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::SetInventoryRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.set_inventory..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.inventory&.name
    header_params["inventory.name"] = request.inventory.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.set_inventory.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.set_inventory.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :set_inventory, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


116
117
118
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 116

def universe_domain
  @product_service_stub.universe_domain
end

#update_product(request, options = nil) ⇒ ::Google::Cloud::Retail::V2::Product #update_product(product: nil, update_mask: nil, allow_missing: nil) ⇒ ::Google::Cloud::Retail::V2::Product

Updates a Product.

Examples:

Basic example

require "google/cloud/retail/v2"

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

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

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

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

Overloads:

  • #update_product(request, options = nil) ⇒ ::Google::Cloud::Retail::V2::Product

    Pass arguments to update_product via a request object, either of type UpdateProductRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Retail::V2::UpdateProductRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_product(product: nil, update_mask: nil, allow_missing: nil) ⇒ ::Google::Cloud::Retail::V2::Product

    Pass arguments to update_product 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:

    • product (::Google::Cloud::Retail::V2::Product, ::Hash) (defaults to: nil)

      Required. The product to update/create.

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

      If the Product to update does not exist and allow_missing is not set, a NOT_FOUND error is returned.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      Indicates which fields in the provided Product to update. The immutable and output only fields are NOT supported. If not set, all supported fields (the fields that are neither immutable nor output only) are updated.

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

      The attribute key can be updated by setting the mask path as "attributes.${key_name}". If a key name is present in the mask but not in the patching product from the request, this key will be deleted after the update.

    • allow_missing (::Boolean) (defaults to: nil)

      If set to true, and the Product is not found, a new Product will be created. In this situation, update_mask is ignored.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
# File 'lib/google/cloud/retail/v2/product_service/client.rb', line 657

def update_product request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::UpdateProductRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_product..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Retail::V2::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.product&.name
    header_params["product.name"] = request.product.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_product.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_product.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @product_service_stub.call_rpc :update_product, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end