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

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

Overview

REST 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 REST client object.

Examples:


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

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

Yields:

  • (config)

    Configure the ProductService client.

Yield Parameters:



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
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 138

def initialize
  # 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 = ::Google::Cloud::Retail::V2::ProductService::Rest::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 = ::Google::Cloud::Retail::V2::ProductService::Rest::ServiceStub.new(
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    credentials: credentials
  )

  @location_client = Google::Cloud::Location::Locations::Rest::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
  end
end

Instance Attribute Details

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

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

Returns:

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


195
196
197
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 195

def location_client
  @location_client
end

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

Get the associated client for long-running operations.



188
189
190
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 188

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::Rest::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



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

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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 1365

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.add_fulfillment_places request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 1680

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.add_local_inventories request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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:



108
109
110
111
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 108

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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 261

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.create_product request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 708

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.delete_product request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 349

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.get_product request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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 cloud-retail-customer-data-access@system.gserviceaccount.com 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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 984

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.import_products request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_products(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Retail::V2::Product> #list_products(parent: nil, page_size: nil, page_token: nil, filter: nil, read_mask: nil) ⇒ ::Gapic::Rest::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::Rest::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::Rest::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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 503

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.list_products request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @product_service_stub, :list_products, "products", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 856

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.purge_products request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 1530

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.remove_fulfillment_places request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 1812

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.remove_local_inventories request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 1195

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.set_inventory request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


118
119
120
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 118

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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
# File 'lib/google/cloud/retail/v2/product_service/rest/client.rb', line 609

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.update_product request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end