google-cloud-retail-v2 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/AUTHENTICATION.md +169 -0
- data/LICENSE.md +203 -0
- data/README.md +75 -0
- data/lib/google-cloud-retail-v2.rb +21 -0
- data/lib/google/cloud/retail/v2.rb +41 -0
- data/lib/google/cloud/retail/v2/catalog_pb.rb +32 -0
- data/lib/google/cloud/retail/v2/catalog_service.rb +49 -0
- data/lib/google/cloud/retail/v2/catalog_service/client.rb +490 -0
- data/lib/google/cloud/retail/v2/catalog_service/credentials.rb +51 -0
- data/lib/google/cloud/retail/v2/catalog_service/paths.rb +69 -0
- data/lib/google/cloud/retail/v2/catalog_service_pb.rb +42 -0
- data/lib/google/cloud/retail/v2/catalog_service_services_pb.rb +48 -0
- data/lib/google/cloud/retail/v2/common_pb.rb +46 -0
- data/lib/google/cloud/retail/v2/import_config_pb.rb +104 -0
- data/lib/google/cloud/retail/v2/prediction_service.rb +49 -0
- data/lib/google/cloud/retail/v2/prediction_service/client.rb +472 -0
- data/lib/google/cloud/retail/v2/prediction_service/credentials.rb +51 -0
- data/lib/google/cloud/retail/v2/prediction_service/paths.rb +56 -0
- data/lib/google/cloud/retail/v2/prediction_service_pb.rb +46 -0
- data/lib/google/cloud/retail/v2/prediction_service_services_pb.rb +45 -0
- data/lib/google/cloud/retail/v2/product_pb.rb +58 -0
- data/lib/google/cloud/retail/v2/product_service.rb +51 -0
- data/lib/google/cloud/retail/v2/product_service/client.rb +752 -0
- data/lib/google/cloud/retail/v2/product_service/credentials.rb +51 -0
- data/lib/google/cloud/retail/v2/product_service/operations.rb +570 -0
- data/lib/google/cloud/retail/v2/product_service/paths.rb +77 -0
- data/lib/google/cloud/retail/v2/product_service_pb.rb +47 -0
- data/lib/google/cloud/retail/v2/product_service_services_pb.rb +60 -0
- data/lib/google/cloud/retail/v2/purge_config_pb.rb +33 -0
- data/lib/google/cloud/retail/v2/user_event_pb.rb +55 -0
- data/lib/google/cloud/retail/v2/user_event_service.rb +50 -0
- data/lib/google/cloud/retail/v2/user_event_service/client.rb +760 -0
- data/lib/google/cloud/retail/v2/user_event_service/credentials.rb +51 -0
- data/lib/google/cloud/retail/v2/user_event_service/operations.rb +570 -0
- data/lib/google/cloud/retail/v2/user_event_service/paths.rb +56 -0
- data/lib/google/cloud/retail/v2/user_event_service_pb.rb +56 -0
- data/lib/google/cloud/retail/v2/user_event_service_services_pb.rb +72 -0
- data/lib/google/cloud/retail/v2/version.rb +28 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/field_behavior.rb +59 -0
- data/proto_docs/google/api/httpbody.rb +75 -0
- data/proto_docs/google/api/resource.rb +283 -0
- data/proto_docs/google/cloud/retail/v2/catalog.rb +101 -0
- data/proto_docs/google/cloud/retail/v2/catalog_service.rb +106 -0
- data/proto_docs/google/cloud/retail/v2/common.rb +169 -0
- data/proto_docs/google/cloud/retail/v2/import_config.rb +270 -0
- data/proto_docs/google/cloud/retail/v2/prediction_service.rb +205 -0
- data/proto_docs/google/cloud/retail/v2/product.rb +278 -0
- data/proto_docs/google/cloud/retail/v2/product_service.rb +117 -0
- data/proto_docs/google/cloud/retail/v2/purge_config.rb +85 -0
- data/proto_docs/google/cloud/retail/v2/user_event.rb +238 -0
- data/proto_docs/google/cloud/retail/v2/user_event_service.rb +114 -0
- data/proto_docs/google/longrunning/operations.rb +150 -0
- data/proto_docs/google/protobuf/any.rb +138 -0
- data/proto_docs/google/protobuf/empty.rb +36 -0
- data/proto_docs/google/protobuf/field_mask.rb +229 -0
- data/proto_docs/google/protobuf/struct.rb +96 -0
- data/proto_docs/google/protobuf/timestamp.rb +120 -0
- data/proto_docs/google/protobuf/wrappers.rb +121 -0
- data/proto_docs/google/rpc/status.rb +46 -0
- metadata +245 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2021 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "googleauth"
|
20
|
+
|
21
|
+
module Google
|
22
|
+
module Cloud
|
23
|
+
module Retail
|
24
|
+
module V2
|
25
|
+
module PredictionService
|
26
|
+
# Credentials for the PredictionService API.
|
27
|
+
class Credentials < ::Google::Auth::Credentials
|
28
|
+
self.scope = [
|
29
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
30
|
+
]
|
31
|
+
self.env_vars = [
|
32
|
+
"RETAIL_CREDENTIALS",
|
33
|
+
"RETAIL_KEYFILE",
|
34
|
+
"GOOGLE_CLOUD_CREDENTIALS",
|
35
|
+
"GOOGLE_CLOUD_KEYFILE",
|
36
|
+
"GCLOUD_KEYFILE",
|
37
|
+
"RETAIL_CREDENTIALS_JSON",
|
38
|
+
"RETAIL_KEYFILE_JSON",
|
39
|
+
"GOOGLE_CLOUD_CREDENTIALS_JSON",
|
40
|
+
"GOOGLE_CLOUD_KEYFILE_JSON",
|
41
|
+
"GCLOUD_KEYFILE_JSON"
|
42
|
+
]
|
43
|
+
self.paths = [
|
44
|
+
"~/.config/google_cloud/application_default_credentials.json"
|
45
|
+
]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2021 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Cloud
|
22
|
+
module Retail
|
23
|
+
module V2
|
24
|
+
module PredictionService
|
25
|
+
# Path helper methods for the PredictionService API.
|
26
|
+
module Paths
|
27
|
+
##
|
28
|
+
# Create a fully-qualified Product resource string.
|
29
|
+
#
|
30
|
+
# The resource will be in the following format:
|
31
|
+
#
|
32
|
+
# `projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}`
|
33
|
+
#
|
34
|
+
# @param project [String]
|
35
|
+
# @param location [String]
|
36
|
+
# @param catalog [String]
|
37
|
+
# @param branch [String]
|
38
|
+
# @param product [String]
|
39
|
+
#
|
40
|
+
# @return [::String]
|
41
|
+
def product_path project:, location:, catalog:, branch:, product:
|
42
|
+
raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
|
43
|
+
raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
|
44
|
+
raise ::ArgumentError, "catalog cannot contain /" if catalog.to_s.include? "/"
|
45
|
+
raise ::ArgumentError, "branch cannot contain /" if branch.to_s.include? "/"
|
46
|
+
|
47
|
+
"projects/#{project}/locations/#{location}/catalogs/#{catalog}/branches/#{branch}/products/#{product}"
|
48
|
+
end
|
49
|
+
|
50
|
+
extend self
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: google/cloud/retail/v2/prediction_service.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'google/api/annotations_pb'
|
7
|
+
require 'google/api/client_pb'
|
8
|
+
require 'google/api/field_behavior_pb'
|
9
|
+
require 'google/cloud/retail/v2/user_event_pb'
|
10
|
+
require 'google/protobuf/struct_pb'
|
11
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
12
|
+
add_file("google/cloud/retail/v2/prediction_service.proto", :syntax => :proto3) do
|
13
|
+
add_message "google.cloud.retail.v2.PredictRequest" do
|
14
|
+
optional :placement, :string, 1
|
15
|
+
optional :user_event, :message, 2, "google.cloud.retail.v2.UserEvent"
|
16
|
+
optional :page_size, :int32, 3
|
17
|
+
optional :page_token, :string, 4
|
18
|
+
optional :filter, :string, 5
|
19
|
+
optional :validate_only, :bool, 6
|
20
|
+
map :params, :string, :message, 7, "google.protobuf.Value"
|
21
|
+
map :labels, :string, :string, 8
|
22
|
+
end
|
23
|
+
add_message "google.cloud.retail.v2.PredictResponse" do
|
24
|
+
repeated :results, :message, 1, "google.cloud.retail.v2.PredictResponse.PredictionResult"
|
25
|
+
optional :attribution_token, :string, 2
|
26
|
+
repeated :missing_ids, :string, 3
|
27
|
+
optional :validate_only, :bool, 4
|
28
|
+
end
|
29
|
+
add_message "google.cloud.retail.v2.PredictResponse.PredictionResult" do
|
30
|
+
optional :id, :string, 1
|
31
|
+
map :metadata, :string, :message, 2, "google.protobuf.Value"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module Google
|
37
|
+
module Cloud
|
38
|
+
module Retail
|
39
|
+
module V2
|
40
|
+
PredictRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.PredictRequest").msgclass
|
41
|
+
PredictResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.PredictResponse").msgclass
|
42
|
+
PredictResponse::PredictionResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.PredictResponse.PredictionResult").msgclass
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: google/cloud/retail/v2/prediction_service.proto for package 'Google.Cloud.Retail.V2'
|
3
|
+
# Original file comments:
|
4
|
+
# Copyright 2020 Google LLC
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'grpc'
|
20
|
+
require 'google/cloud/retail/v2/prediction_service_pb'
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module Retail
|
25
|
+
module V2
|
26
|
+
module PredictionService
|
27
|
+
# Service for making recommendation prediction.
|
28
|
+
class Service
|
29
|
+
|
30
|
+
include GRPC::GenericService
|
31
|
+
|
32
|
+
self.marshal_class_method = :encode
|
33
|
+
self.unmarshal_class_method = :decode
|
34
|
+
self.service_name = 'google.cloud.retail.v2.PredictionService'
|
35
|
+
|
36
|
+
# Makes a recommendation prediction.
|
37
|
+
rpc :Predict, ::Google::Cloud::Retail::V2::PredictRequest, ::Google::Cloud::Retail::V2::PredictResponse
|
38
|
+
end
|
39
|
+
|
40
|
+
Stub = Service.rpc_stub_class
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: google/cloud/retail/v2/product.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'google/api/annotations_pb'
|
7
|
+
require 'google/api/field_behavior_pb'
|
8
|
+
require 'google/api/resource_pb'
|
9
|
+
require 'google/cloud/retail/v2/common_pb'
|
10
|
+
require 'google/protobuf/field_mask_pb'
|
11
|
+
require 'google/protobuf/timestamp_pb'
|
12
|
+
require 'google/protobuf/wrappers_pb'
|
13
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
14
|
+
add_file("google/cloud/retail/v2/product.proto", :syntax => :proto3) do
|
15
|
+
add_message "google.cloud.retail.v2.Product" do
|
16
|
+
optional :name, :string, 1
|
17
|
+
optional :id, :string, 2
|
18
|
+
optional :type, :enum, 3, "google.cloud.retail.v2.Product.Type"
|
19
|
+
optional :primary_product_id, :string, 4
|
20
|
+
repeated :categories, :string, 7
|
21
|
+
optional :title, :string, 8
|
22
|
+
optional :description, :string, 10
|
23
|
+
map :attributes, :string, :message, 12, "google.cloud.retail.v2.CustomAttribute"
|
24
|
+
repeated :tags, :string, 13
|
25
|
+
optional :price_info, :message, 14, "google.cloud.retail.v2.PriceInfo"
|
26
|
+
optional :available_time, :message, 18, "google.protobuf.Timestamp"
|
27
|
+
optional :availability, :enum, 19, "google.cloud.retail.v2.Product.Availability"
|
28
|
+
optional :available_quantity, :message, 20, "google.protobuf.Int32Value"
|
29
|
+
optional :uri, :string, 22
|
30
|
+
repeated :images, :message, 23, "google.cloud.retail.v2.Image"
|
31
|
+
end
|
32
|
+
add_enum "google.cloud.retail.v2.Product.Type" do
|
33
|
+
value :TYPE_UNSPECIFIED, 0
|
34
|
+
value :PRIMARY, 1
|
35
|
+
value :VARIANT, 2
|
36
|
+
value :COLLECTION, 3
|
37
|
+
end
|
38
|
+
add_enum "google.cloud.retail.v2.Product.Availability" do
|
39
|
+
value :AVAILABILITY_UNSPECIFIED, 0
|
40
|
+
value :IN_STOCK, 1
|
41
|
+
value :OUT_OF_STOCK, 2
|
42
|
+
value :PREORDER, 3
|
43
|
+
value :BACKORDER, 4
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module Google
|
49
|
+
module Cloud
|
50
|
+
module Retail
|
51
|
+
module V2
|
52
|
+
Product = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Product").msgclass
|
53
|
+
Product::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Product.Type").enummodule
|
54
|
+
Product::Availability = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Product.Availability").enummodule
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2021 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "gapic/common"
|
20
|
+
require "gapic/config"
|
21
|
+
require "gapic/config/method"
|
22
|
+
|
23
|
+
require "google/cloud/retail/v2/version"
|
24
|
+
|
25
|
+
require "google/cloud/retail/v2/product_service/credentials"
|
26
|
+
require "google/cloud/retail/v2/product_service/paths"
|
27
|
+
require "google/cloud/retail/v2/product_service/operations"
|
28
|
+
require "google/cloud/retail/v2/product_service/client"
|
29
|
+
|
30
|
+
module Google
|
31
|
+
module Cloud
|
32
|
+
module Retail
|
33
|
+
module V2
|
34
|
+
##
|
35
|
+
# Service for ingesting {::Google::Cloud::Retail::V2::Product Product} information
|
36
|
+
# of the customer's website.
|
37
|
+
#
|
38
|
+
# To load this service and instantiate a client:
|
39
|
+
#
|
40
|
+
# require "google/cloud/retail/v2/product_service"
|
41
|
+
# client = ::Google::Cloud::Retail::V2::ProductService::Client.new
|
42
|
+
#
|
43
|
+
module ProductService
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
helper_path = ::File.join __dir__, "product_service", "helpers.rb"
|
51
|
+
require "google/cloud/retail/v2/product_service/helpers" if ::File.file? helper_path
|
@@ -0,0 +1,752 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2021 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/errors"
|
20
|
+
require "google/cloud/retail/v2/product_service_pb"
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module Retail
|
25
|
+
module V2
|
26
|
+
module ProductService
|
27
|
+
##
|
28
|
+
# Client for the ProductService service.
|
29
|
+
#
|
30
|
+
# Service for ingesting {::Google::Cloud::Retail::V2::Product Product} information
|
31
|
+
# of the customer's website.
|
32
|
+
#
|
33
|
+
class Client
|
34
|
+
include Paths
|
35
|
+
|
36
|
+
# @private
|
37
|
+
attr_reader :product_service_stub
|
38
|
+
|
39
|
+
##
|
40
|
+
# Configure the ProductService Client class.
|
41
|
+
#
|
42
|
+
# See {::Google::Cloud::Retail::V2::ProductService::Client::Configuration}
|
43
|
+
# for a description of the configuration fields.
|
44
|
+
#
|
45
|
+
# ## Example
|
46
|
+
#
|
47
|
+
# To modify the configuration for all ProductService clients:
|
48
|
+
#
|
49
|
+
# ::Google::Cloud::Retail::V2::ProductService::Client.configure do |config|
|
50
|
+
# config.timeout = 10.0
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# @yield [config] Configure the Client client.
|
54
|
+
# @yieldparam config [Client::Configuration]
|
55
|
+
#
|
56
|
+
# @return [Client::Configuration]
|
57
|
+
#
|
58
|
+
def self.configure
|
59
|
+
@configure ||= begin
|
60
|
+
namespace = ["Google", "Cloud", "Retail", "V2"]
|
61
|
+
parent_config = while namespace.any?
|
62
|
+
parent_name = namespace.join "::"
|
63
|
+
parent_const = const_get parent_name
|
64
|
+
break parent_const.configure if parent_const&.respond_to? :configure
|
65
|
+
namespace.pop
|
66
|
+
end
|
67
|
+
default_config = Client::Configuration.new parent_config
|
68
|
+
|
69
|
+
default_config.timeout = 60.0
|
70
|
+
default_config.retry_policy = {
|
71
|
+
initial_delay: 0.1,
|
72
|
+
max_delay: 60.0,
|
73
|
+
multiplier: 1.3,
|
74
|
+
retry_codes: [14, 4]
|
75
|
+
}
|
76
|
+
|
77
|
+
default_config
|
78
|
+
end
|
79
|
+
yield @configure if block_given?
|
80
|
+
@configure
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Configure the ProductService Client instance.
|
85
|
+
#
|
86
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
87
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
88
|
+
# should be made on {Client.configure}.
|
89
|
+
#
|
90
|
+
# See {::Google::Cloud::Retail::V2::ProductService::Client::Configuration}
|
91
|
+
# for a description of the configuration fields.
|
92
|
+
#
|
93
|
+
# @yield [config] Configure the Client client.
|
94
|
+
# @yieldparam config [Client::Configuration]
|
95
|
+
#
|
96
|
+
# @return [Client::Configuration]
|
97
|
+
#
|
98
|
+
def configure
|
99
|
+
yield @config if block_given?
|
100
|
+
@config
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Create a new ProductService client object.
|
105
|
+
#
|
106
|
+
# ## Examples
|
107
|
+
#
|
108
|
+
# To create a new ProductService client with the default
|
109
|
+
# configuration:
|
110
|
+
#
|
111
|
+
# client = ::Google::Cloud::Retail::V2::ProductService::Client.new
|
112
|
+
#
|
113
|
+
# To create a new ProductService client with a custom
|
114
|
+
# configuration:
|
115
|
+
#
|
116
|
+
# client = ::Google::Cloud::Retail::V2::ProductService::Client.new do |config|
|
117
|
+
# config.timeout = 10.0
|
118
|
+
# end
|
119
|
+
#
|
120
|
+
# @yield [config] Configure the ProductService client.
|
121
|
+
# @yieldparam config [Client::Configuration]
|
122
|
+
#
|
123
|
+
def initialize
|
124
|
+
# These require statements are intentionally placed here to initialize
|
125
|
+
# the gRPC module only when it's required.
|
126
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
127
|
+
require "gapic/grpc"
|
128
|
+
require "google/cloud/retail/v2/product_service_services_pb"
|
129
|
+
|
130
|
+
# Create the configuration object
|
131
|
+
@config = Configuration.new Client.configure
|
132
|
+
|
133
|
+
# Yield the configuration if needed
|
134
|
+
yield @config if block_given?
|
135
|
+
|
136
|
+
# Create credentials
|
137
|
+
credentials = @config.credentials
|
138
|
+
credentials ||= Credentials.default scope: @config.scope
|
139
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
140
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
141
|
+
end
|
142
|
+
@quota_project_id = @config.quota_project
|
143
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
144
|
+
|
145
|
+
@operations_client = Operations.new do |config|
|
146
|
+
config.credentials = credentials
|
147
|
+
config.endpoint = @config.endpoint
|
148
|
+
end
|
149
|
+
|
150
|
+
@product_service_stub = ::Gapic::ServiceStub.new(
|
151
|
+
::Google::Cloud::Retail::V2::ProductService::Stub,
|
152
|
+
credentials: credentials,
|
153
|
+
endpoint: @config.endpoint,
|
154
|
+
channel_args: @config.channel_args,
|
155
|
+
interceptors: @config.interceptors
|
156
|
+
)
|
157
|
+
end
|
158
|
+
|
159
|
+
##
|
160
|
+
# Get the associated client for long-running operations.
|
161
|
+
#
|
162
|
+
# @return [::Google::Cloud::Retail::V2::ProductService::Operations]
|
163
|
+
#
|
164
|
+
attr_reader :operations_client
|
165
|
+
|
166
|
+
# Service calls
|
167
|
+
|
168
|
+
##
|
169
|
+
# Creates a {::Google::Cloud::Retail::V2::Product Product}.
|
170
|
+
#
|
171
|
+
# @overload create_product(request, options = nil)
|
172
|
+
# Pass arguments to `create_product` via a request object, either of type
|
173
|
+
# {::Google::Cloud::Retail::V2::CreateProductRequest} or an equivalent Hash.
|
174
|
+
#
|
175
|
+
# @param request [::Google::Cloud::Retail::V2::CreateProductRequest, ::Hash]
|
176
|
+
# A request object representing the call parameters. Required. To specify no
|
177
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
178
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
179
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
180
|
+
#
|
181
|
+
# @overload create_product(parent: nil, product: nil, product_id: nil)
|
182
|
+
# Pass arguments to `create_product` via keyword arguments. Note that at
|
183
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
184
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
185
|
+
#
|
186
|
+
# @param parent [::String]
|
187
|
+
# Required. The parent catalog resource name, such as
|
188
|
+
# "projects/*/locations/global/catalogs/default_catalog/branches/default_branch".
|
189
|
+
# @param product [::Google::Cloud::Retail::V2::Product, ::Hash]
|
190
|
+
# Required. The {::Google::Cloud::Retail::V2::Product Product} to create.
|
191
|
+
# @param product_id [::String]
|
192
|
+
# Required. The ID to use for the {::Google::Cloud::Retail::V2::Product Product},
|
193
|
+
# which will become the final component of the
|
194
|
+
# {::Google::Cloud::Retail::V2::Product#name Product.name}.
|
195
|
+
#
|
196
|
+
# If the caller does not have permission to create the
|
197
|
+
# {::Google::Cloud::Retail::V2::Product Product}, regardless of whether or not it
|
198
|
+
# exists, a PERMISSION_DENIED error is returned.
|
199
|
+
#
|
200
|
+
# This field must be unique among all
|
201
|
+
# {::Google::Cloud::Retail::V2::Product Product}s with the same
|
202
|
+
# {::Google::Cloud::Retail::V2::CreateProductRequest#parent parent}. Otherwise, an
|
203
|
+
# ALREADY_EXISTS error is returned.
|
204
|
+
#
|
205
|
+
# This field must be a UTF-8 encoded string with a length limit of 128
|
206
|
+
# characters. Otherwise, an INVALID_ARGUMENT error is returned.
|
207
|
+
#
|
208
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
209
|
+
# @yieldparam response [::Google::Cloud::Retail::V2::Product]
|
210
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
211
|
+
#
|
212
|
+
# @return [::Google::Cloud::Retail::V2::Product]
|
213
|
+
#
|
214
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
215
|
+
#
|
216
|
+
def create_product request, options = nil
|
217
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
218
|
+
|
219
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::CreateProductRequest
|
220
|
+
|
221
|
+
# Converts hash and nil to an options object
|
222
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
223
|
+
|
224
|
+
# Customize the options with defaults
|
225
|
+
metadata = @config.rpcs.create_product.metadata.to_h
|
226
|
+
|
227
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
228
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
229
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
230
|
+
gapic_version: ::Google::Cloud::Retail::V2::VERSION
|
231
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
232
|
+
|
233
|
+
header_params = {
|
234
|
+
"parent" => request.parent
|
235
|
+
}
|
236
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
237
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
238
|
+
|
239
|
+
options.apply_defaults timeout: @config.rpcs.create_product.timeout,
|
240
|
+
metadata: metadata,
|
241
|
+
retry_policy: @config.rpcs.create_product.retry_policy
|
242
|
+
options.apply_defaults metadata: @config.metadata,
|
243
|
+
retry_policy: @config.retry_policy
|
244
|
+
|
245
|
+
@product_service_stub.call_rpc :create_product, request, options: options do |response, operation|
|
246
|
+
yield response, operation if block_given?
|
247
|
+
return response
|
248
|
+
end
|
249
|
+
rescue ::GRPC::BadStatus => e
|
250
|
+
raise ::Google::Cloud::Error.from_error(e)
|
251
|
+
end
|
252
|
+
|
253
|
+
##
|
254
|
+
# Gets a {::Google::Cloud::Retail::V2::Product Product}.
|
255
|
+
#
|
256
|
+
# @overload get_product(request, options = nil)
|
257
|
+
# Pass arguments to `get_product` via a request object, either of type
|
258
|
+
# {::Google::Cloud::Retail::V2::GetProductRequest} or an equivalent Hash.
|
259
|
+
#
|
260
|
+
# @param request [::Google::Cloud::Retail::V2::GetProductRequest, ::Hash]
|
261
|
+
# A request object representing the call parameters. Required. To specify no
|
262
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
263
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
264
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
265
|
+
#
|
266
|
+
# @overload get_product(name: nil)
|
267
|
+
# Pass arguments to `get_product` via keyword arguments. Note that at
|
268
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
269
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
270
|
+
#
|
271
|
+
# @param name [::String]
|
272
|
+
# Required. Full resource name of {::Google::Cloud::Retail::V2::Product Product},
|
273
|
+
# such as
|
274
|
+
# "projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id".
|
275
|
+
#
|
276
|
+
# If the caller does not have permission to access the
|
277
|
+
# {::Google::Cloud::Retail::V2::Product Product}, regardless of whether or not it
|
278
|
+
# exists, a PERMISSION_DENIED error is returned.
|
279
|
+
#
|
280
|
+
# If the requested {::Google::Cloud::Retail::V2::Product Product} does not exist,
|
281
|
+
# a NOT_FOUND error is returned.
|
282
|
+
#
|
283
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
284
|
+
# @yieldparam response [::Google::Cloud::Retail::V2::Product]
|
285
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
286
|
+
#
|
287
|
+
# @return [::Google::Cloud::Retail::V2::Product]
|
288
|
+
#
|
289
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
290
|
+
#
|
291
|
+
def get_product request, options = nil
|
292
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
293
|
+
|
294
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::GetProductRequest
|
295
|
+
|
296
|
+
# Converts hash and nil to an options object
|
297
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
298
|
+
|
299
|
+
# Customize the options with defaults
|
300
|
+
metadata = @config.rpcs.get_product.metadata.to_h
|
301
|
+
|
302
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
303
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
304
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
305
|
+
gapic_version: ::Google::Cloud::Retail::V2::VERSION
|
306
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
307
|
+
|
308
|
+
header_params = {
|
309
|
+
"name" => request.name
|
310
|
+
}
|
311
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
312
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
313
|
+
|
314
|
+
options.apply_defaults timeout: @config.rpcs.get_product.timeout,
|
315
|
+
metadata: metadata,
|
316
|
+
retry_policy: @config.rpcs.get_product.retry_policy
|
317
|
+
options.apply_defaults metadata: @config.metadata,
|
318
|
+
retry_policy: @config.retry_policy
|
319
|
+
|
320
|
+
@product_service_stub.call_rpc :get_product, request, options: options do |response, operation|
|
321
|
+
yield response, operation if block_given?
|
322
|
+
return response
|
323
|
+
end
|
324
|
+
rescue ::GRPC::BadStatus => e
|
325
|
+
raise ::Google::Cloud::Error.from_error(e)
|
326
|
+
end
|
327
|
+
|
328
|
+
##
|
329
|
+
# Updates a {::Google::Cloud::Retail::V2::Product Product}.
|
330
|
+
#
|
331
|
+
# @overload update_product(request, options = nil)
|
332
|
+
# Pass arguments to `update_product` via a request object, either of type
|
333
|
+
# {::Google::Cloud::Retail::V2::UpdateProductRequest} or an equivalent Hash.
|
334
|
+
#
|
335
|
+
# @param request [::Google::Cloud::Retail::V2::UpdateProductRequest, ::Hash]
|
336
|
+
# A request object representing the call parameters. Required. To specify no
|
337
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
338
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
339
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
340
|
+
#
|
341
|
+
# @overload update_product(product: nil, update_mask: nil)
|
342
|
+
# Pass arguments to `update_product` via keyword arguments. Note that at
|
343
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
344
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
345
|
+
#
|
346
|
+
# @param product [::Google::Cloud::Retail::V2::Product, ::Hash]
|
347
|
+
# Required. The product to update/create.
|
348
|
+
#
|
349
|
+
# If the caller does not have permission to update the
|
350
|
+
# {::Google::Cloud::Retail::V2::Product Product}, regardless of whether or not it
|
351
|
+
# exists, a PERMISSION_DENIED error is returned.
|
352
|
+
#
|
353
|
+
# If the {::Google::Cloud::Retail::V2::Product Product} to update does not exist,
|
354
|
+
# a NOT_FOUND error is returned.
|
355
|
+
# @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
|
356
|
+
# Indicates which fields in the provided
|
357
|
+
# {::Google::Cloud::Retail::V2::Product Product} to update. The immutable and
|
358
|
+
# output only fields are NOT supported. If not set, all supported fields (the
|
359
|
+
# fields that are neither immutable nor output only) are updated.
|
360
|
+
#
|
361
|
+
# If an unsupported or unknown field is provided, an INVALID_ARGUMENT error
|
362
|
+
# is returned.
|
363
|
+
#
|
364
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
365
|
+
# @yieldparam response [::Google::Cloud::Retail::V2::Product]
|
366
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
367
|
+
#
|
368
|
+
# @return [::Google::Cloud::Retail::V2::Product]
|
369
|
+
#
|
370
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
371
|
+
#
|
372
|
+
def update_product request, options = nil
|
373
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
374
|
+
|
375
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::UpdateProductRequest
|
376
|
+
|
377
|
+
# Converts hash and nil to an options object
|
378
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
379
|
+
|
380
|
+
# Customize the options with defaults
|
381
|
+
metadata = @config.rpcs.update_product.metadata.to_h
|
382
|
+
|
383
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
384
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
385
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
386
|
+
gapic_version: ::Google::Cloud::Retail::V2::VERSION
|
387
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
388
|
+
|
389
|
+
header_params = {
|
390
|
+
"product.name" => request.product.name
|
391
|
+
}
|
392
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
393
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
394
|
+
|
395
|
+
options.apply_defaults timeout: @config.rpcs.update_product.timeout,
|
396
|
+
metadata: metadata,
|
397
|
+
retry_policy: @config.rpcs.update_product.retry_policy
|
398
|
+
options.apply_defaults metadata: @config.metadata,
|
399
|
+
retry_policy: @config.retry_policy
|
400
|
+
|
401
|
+
@product_service_stub.call_rpc :update_product, request, options: options do |response, operation|
|
402
|
+
yield response, operation if block_given?
|
403
|
+
return response
|
404
|
+
end
|
405
|
+
rescue ::GRPC::BadStatus => e
|
406
|
+
raise ::Google::Cloud::Error.from_error(e)
|
407
|
+
end
|
408
|
+
|
409
|
+
##
|
410
|
+
# Deletes a {::Google::Cloud::Retail::V2::Product Product}.
|
411
|
+
#
|
412
|
+
# @overload delete_product(request, options = nil)
|
413
|
+
# Pass arguments to `delete_product` via a request object, either of type
|
414
|
+
# {::Google::Cloud::Retail::V2::DeleteProductRequest} or an equivalent Hash.
|
415
|
+
#
|
416
|
+
# @param request [::Google::Cloud::Retail::V2::DeleteProductRequest, ::Hash]
|
417
|
+
# A request object representing the call parameters. Required. To specify no
|
418
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
419
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
420
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
421
|
+
#
|
422
|
+
# @overload delete_product(name: nil)
|
423
|
+
# Pass arguments to `delete_product` via keyword arguments. Note that at
|
424
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
425
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
426
|
+
#
|
427
|
+
# @param name [::String]
|
428
|
+
# Required. Full resource name of {::Google::Cloud::Retail::V2::Product Product},
|
429
|
+
# such as
|
430
|
+
# "projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id".
|
431
|
+
#
|
432
|
+
# If the caller does not have permission to delete the
|
433
|
+
# {::Google::Cloud::Retail::V2::Product Product}, regardless of whether or not it
|
434
|
+
# exists, a PERMISSION_DENIED error is returned.
|
435
|
+
#
|
436
|
+
# If the {::Google::Cloud::Retail::V2::Product Product} to delete does not exist,
|
437
|
+
# a NOT_FOUND error is returned.
|
438
|
+
#
|
439
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
440
|
+
# @yieldparam response [::Google::Protobuf::Empty]
|
441
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
442
|
+
#
|
443
|
+
# @return [::Google::Protobuf::Empty]
|
444
|
+
#
|
445
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
446
|
+
#
|
447
|
+
def delete_product request, options = nil
|
448
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
449
|
+
|
450
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::DeleteProductRequest
|
451
|
+
|
452
|
+
# Converts hash and nil to an options object
|
453
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
454
|
+
|
455
|
+
# Customize the options with defaults
|
456
|
+
metadata = @config.rpcs.delete_product.metadata.to_h
|
457
|
+
|
458
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
459
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
460
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
461
|
+
gapic_version: ::Google::Cloud::Retail::V2::VERSION
|
462
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
463
|
+
|
464
|
+
header_params = {
|
465
|
+
"name" => request.name
|
466
|
+
}
|
467
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
468
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
469
|
+
|
470
|
+
options.apply_defaults timeout: @config.rpcs.delete_product.timeout,
|
471
|
+
metadata: metadata,
|
472
|
+
retry_policy: @config.rpcs.delete_product.retry_policy
|
473
|
+
options.apply_defaults metadata: @config.metadata,
|
474
|
+
retry_policy: @config.retry_policy
|
475
|
+
|
476
|
+
@product_service_stub.call_rpc :delete_product, request, options: options do |response, operation|
|
477
|
+
yield response, operation if block_given?
|
478
|
+
return response
|
479
|
+
end
|
480
|
+
rescue ::GRPC::BadStatus => e
|
481
|
+
raise ::Google::Cloud::Error.from_error(e)
|
482
|
+
end
|
483
|
+
|
484
|
+
##
|
485
|
+
# Bulk import of multiple {::Google::Cloud::Retail::V2::Product Product}s.
|
486
|
+
#
|
487
|
+
# Request processing may be synchronous. No partial updating is supported.
|
488
|
+
# Non-existing items are created.
|
489
|
+
#
|
490
|
+
# Note that it is possible for a subset of the
|
491
|
+
# {::Google::Cloud::Retail::V2::Product Product}s to be successfully updated.
|
492
|
+
#
|
493
|
+
# @overload import_products(request, options = nil)
|
494
|
+
# Pass arguments to `import_products` via a request object, either of type
|
495
|
+
# {::Google::Cloud::Retail::V2::ImportProductsRequest} or an equivalent Hash.
|
496
|
+
#
|
497
|
+
# @param request [::Google::Cloud::Retail::V2::ImportProductsRequest, ::Hash]
|
498
|
+
# A request object representing the call parameters. Required. To specify no
|
499
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
500
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
501
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
502
|
+
#
|
503
|
+
# @overload import_products(parent: nil, input_config: nil, errors_config: nil, update_mask: nil)
|
504
|
+
# Pass arguments to `import_products` via keyword arguments. Note that at
|
505
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
506
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
507
|
+
#
|
508
|
+
# @param parent [::String]
|
509
|
+
# Required.
|
510
|
+
# "projects/1234/locations/global/catalogs/default_catalog/branches/default_branch"
|
511
|
+
#
|
512
|
+
# If no updateMask is specified, requires products.create permission.
|
513
|
+
# If updateMask is specified, requires products.update permission.
|
514
|
+
# @param input_config [::Google::Cloud::Retail::V2::ProductInputConfig, ::Hash]
|
515
|
+
# Required. The desired input location of the data.
|
516
|
+
# @param errors_config [::Google::Cloud::Retail::V2::ImportErrorsConfig, ::Hash]
|
517
|
+
# The desired location of errors incurred during the Import.
|
518
|
+
# @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
|
519
|
+
# Indicates which fields in the provided imported 'products' to update. If
|
520
|
+
# not set, will by default update all fields.
|
521
|
+
#
|
522
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
523
|
+
# @yieldparam response [::Gapic::Operation]
|
524
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
525
|
+
#
|
526
|
+
# @return [::Gapic::Operation]
|
527
|
+
#
|
528
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
529
|
+
#
|
530
|
+
def import_products request, options = nil
|
531
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
532
|
+
|
533
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::ImportProductsRequest
|
534
|
+
|
535
|
+
# Converts hash and nil to an options object
|
536
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
537
|
+
|
538
|
+
# Customize the options with defaults
|
539
|
+
metadata = @config.rpcs.import_products.metadata.to_h
|
540
|
+
|
541
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
542
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
543
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
544
|
+
gapic_version: ::Google::Cloud::Retail::V2::VERSION
|
545
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
546
|
+
|
547
|
+
header_params = {
|
548
|
+
"parent" => request.parent
|
549
|
+
}
|
550
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
551
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
552
|
+
|
553
|
+
options.apply_defaults timeout: @config.rpcs.import_products.timeout,
|
554
|
+
metadata: metadata,
|
555
|
+
retry_policy: @config.rpcs.import_products.retry_policy
|
556
|
+
options.apply_defaults metadata: @config.metadata,
|
557
|
+
retry_policy: @config.retry_policy
|
558
|
+
|
559
|
+
@product_service_stub.call_rpc :import_products, request, options: options do |response, operation|
|
560
|
+
response = ::Gapic::Operation.new response, @operations_client, options: options
|
561
|
+
yield response, operation if block_given?
|
562
|
+
return response
|
563
|
+
end
|
564
|
+
rescue ::GRPC::BadStatus => e
|
565
|
+
raise ::Google::Cloud::Error.from_error(e)
|
566
|
+
end
|
567
|
+
|
568
|
+
##
|
569
|
+
# Configuration class for the ProductService API.
|
570
|
+
#
|
571
|
+
# This class represents the configuration for ProductService,
|
572
|
+
# providing control over timeouts, retry behavior, logging, transport
|
573
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
574
|
+
# applied individually to specific RPCs. See
|
575
|
+
# {::Google::Cloud::Retail::V2::ProductService::Client::Configuration::Rpcs}
|
576
|
+
# for a list of RPCs that can be configured independently.
|
577
|
+
#
|
578
|
+
# Configuration can be applied globally to all clients, or to a single client
|
579
|
+
# on construction.
|
580
|
+
#
|
581
|
+
# # Examples
|
582
|
+
#
|
583
|
+
# To modify the global config, setting the timeout for create_product
|
584
|
+
# to 20 seconds, and all remaining timeouts to 10 seconds:
|
585
|
+
#
|
586
|
+
# ::Google::Cloud::Retail::V2::ProductService::Client.configure do |config|
|
587
|
+
# config.timeout = 10.0
|
588
|
+
# config.rpcs.create_product.timeout = 20.0
|
589
|
+
# end
|
590
|
+
#
|
591
|
+
# To apply the above configuration only to a new client:
|
592
|
+
#
|
593
|
+
# client = ::Google::Cloud::Retail::V2::ProductService::Client.new do |config|
|
594
|
+
# config.timeout = 10.0
|
595
|
+
# config.rpcs.create_product.timeout = 20.0
|
596
|
+
# end
|
597
|
+
#
|
598
|
+
# @!attribute [rw] endpoint
|
599
|
+
# The hostname or hostname:port of the service endpoint.
|
600
|
+
# Defaults to `"retail.googleapis.com"`.
|
601
|
+
# @return [::String]
|
602
|
+
# @!attribute [rw] credentials
|
603
|
+
# Credentials to send with calls. You may provide any of the following types:
|
604
|
+
# * (`String`) The path to a service account key file in JSON format
|
605
|
+
# * (`Hash`) A service account key as a Hash
|
606
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
607
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
608
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
609
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
610
|
+
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
611
|
+
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
612
|
+
# * (`nil`) indicating no credentials
|
613
|
+
# @return [::Object]
|
614
|
+
# @!attribute [rw] scope
|
615
|
+
# The OAuth scopes
|
616
|
+
# @return [::Array<::String>]
|
617
|
+
# @!attribute [rw] lib_name
|
618
|
+
# The library name as recorded in instrumentation and logging
|
619
|
+
# @return [::String]
|
620
|
+
# @!attribute [rw] lib_version
|
621
|
+
# The library version as recorded in instrumentation and logging
|
622
|
+
# @return [::String]
|
623
|
+
# @!attribute [rw] channel_args
|
624
|
+
# Extra parameters passed to the gRPC channel. Note: this is ignored if a
|
625
|
+
# `GRPC::Core::Channel` object is provided as the credential.
|
626
|
+
# @return [::Hash]
|
627
|
+
# @!attribute [rw] interceptors
|
628
|
+
# An array of interceptors that are run before calls are executed.
|
629
|
+
# @return [::Array<::GRPC::ClientInterceptor>]
|
630
|
+
# @!attribute [rw] timeout
|
631
|
+
# The call timeout in seconds.
|
632
|
+
# @return [::Numeric]
|
633
|
+
# @!attribute [rw] metadata
|
634
|
+
# Additional gRPC headers to be sent with the call.
|
635
|
+
# @return [::Hash{::Symbol=>::String}]
|
636
|
+
# @!attribute [rw] retry_policy
|
637
|
+
# The retry policy. The value is a hash with the following keys:
|
638
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
639
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
640
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
641
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
642
|
+
# trigger a retry.
|
643
|
+
# @return [::Hash]
|
644
|
+
# @!attribute [rw] quota_project
|
645
|
+
# A separate project against which to charge quota.
|
646
|
+
# @return [::String]
|
647
|
+
#
|
648
|
+
class Configuration
|
649
|
+
extend ::Gapic::Config
|
650
|
+
|
651
|
+
config_attr :endpoint, "retail.googleapis.com", ::String
|
652
|
+
config_attr :credentials, nil do |value|
|
653
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
654
|
+
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
655
|
+
allowed.any? { |klass| klass === value }
|
656
|
+
end
|
657
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
658
|
+
config_attr :lib_name, nil, ::String, nil
|
659
|
+
config_attr :lib_version, nil, ::String, nil
|
660
|
+
config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
|
661
|
+
config_attr :interceptors, nil, ::Array, nil
|
662
|
+
config_attr :timeout, nil, ::Numeric, nil
|
663
|
+
config_attr :metadata, nil, ::Hash, nil
|
664
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
665
|
+
config_attr :quota_project, nil, ::String, nil
|
666
|
+
|
667
|
+
# @private
|
668
|
+
def initialize parent_config = nil
|
669
|
+
@parent_config = parent_config unless parent_config.nil?
|
670
|
+
|
671
|
+
yield self if block_given?
|
672
|
+
end
|
673
|
+
|
674
|
+
##
|
675
|
+
# Configurations for individual RPCs
|
676
|
+
# @return [Rpcs]
|
677
|
+
#
|
678
|
+
def rpcs
|
679
|
+
@rpcs ||= begin
|
680
|
+
parent_rpcs = nil
|
681
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
|
682
|
+
Rpcs.new parent_rpcs
|
683
|
+
end
|
684
|
+
end
|
685
|
+
|
686
|
+
##
|
687
|
+
# Configuration RPC class for the ProductService API.
|
688
|
+
#
|
689
|
+
# Includes fields providing the configuration for each RPC in this service.
|
690
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
691
|
+
# the following configuration fields:
|
692
|
+
#
|
693
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
|
694
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
|
695
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
696
|
+
# include the following keys:
|
697
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
698
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
699
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
700
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
701
|
+
# trigger a retry.
|
702
|
+
#
|
703
|
+
class Rpcs
|
704
|
+
##
|
705
|
+
# RPC-specific configuration for `create_product`
|
706
|
+
# @return [::Gapic::Config::Method]
|
707
|
+
#
|
708
|
+
attr_reader :create_product
|
709
|
+
##
|
710
|
+
# RPC-specific configuration for `get_product`
|
711
|
+
# @return [::Gapic::Config::Method]
|
712
|
+
#
|
713
|
+
attr_reader :get_product
|
714
|
+
##
|
715
|
+
# RPC-specific configuration for `update_product`
|
716
|
+
# @return [::Gapic::Config::Method]
|
717
|
+
#
|
718
|
+
attr_reader :update_product
|
719
|
+
##
|
720
|
+
# RPC-specific configuration for `delete_product`
|
721
|
+
# @return [::Gapic::Config::Method]
|
722
|
+
#
|
723
|
+
attr_reader :delete_product
|
724
|
+
##
|
725
|
+
# RPC-specific configuration for `import_products`
|
726
|
+
# @return [::Gapic::Config::Method]
|
727
|
+
#
|
728
|
+
attr_reader :import_products
|
729
|
+
|
730
|
+
# @private
|
731
|
+
def initialize parent_rpcs = nil
|
732
|
+
create_product_config = parent_rpcs&.create_product if parent_rpcs&.respond_to? :create_product
|
733
|
+
@create_product = ::Gapic::Config::Method.new create_product_config
|
734
|
+
get_product_config = parent_rpcs&.get_product if parent_rpcs&.respond_to? :get_product
|
735
|
+
@get_product = ::Gapic::Config::Method.new get_product_config
|
736
|
+
update_product_config = parent_rpcs&.update_product if parent_rpcs&.respond_to? :update_product
|
737
|
+
@update_product = ::Gapic::Config::Method.new update_product_config
|
738
|
+
delete_product_config = parent_rpcs&.delete_product if parent_rpcs&.respond_to? :delete_product
|
739
|
+
@delete_product = ::Gapic::Config::Method.new delete_product_config
|
740
|
+
import_products_config = parent_rpcs&.import_products if parent_rpcs&.respond_to? :import_products
|
741
|
+
@import_products = ::Gapic::Config::Method.new import_products_config
|
742
|
+
|
743
|
+
yield self if block_given?
|
744
|
+
end
|
745
|
+
end
|
746
|
+
end
|
747
|
+
end
|
748
|
+
end
|
749
|
+
end
|
750
|
+
end
|
751
|
+
end
|
752
|
+
end
|