From 16234fae881130f844fafdb1cede63177ecd99c4 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:23:07 -0700 Subject: [PATCH] feat: Add FileUploads service (#27360) docs: A comment for enum value `PRODUCTS` in enum `Channel` is changed --- .../.owlbot-manifest.json | 15 + .../.repo-metadata.json | 2 +- .../README.md | 3 +- .../gapic_metadata.json | 14 + ...pping-merchant-data_sources-v1beta.gemspec | 4 +- .../shopping/merchant/data_sources/v1beta.rb | 1 + .../v1beta/file_uploads_service.rb | 57 +++ .../v1beta/file_uploads_service/client.rb | 435 ++++++++++++++++++ .../file_uploads_service/credentials.rb | 49 ++ .../v1beta/file_uploads_service/paths.rb | 54 +++ .../v1beta/file_uploads_service/rest.rb | 54 +++ .../file_uploads_service/rest/client.rb | 402 ++++++++++++++++ .../file_uploads_service/rest/service_stub.rb | 130 ++++++ .../merchant/data_sources/v1beta/rest.rb | 1 + .../datasources/v1beta/datasourcetypes_pb.rb | 4 +- .../datasources/v1beta/fileuploads_pb.rb | 55 +++ .../v1beta/fileuploads_services_pb.rb | 48 ++ .../proto_docs/google/protobuf/timestamp.rb | 127 +++++ .../datasources/v1beta/datasourcetypes.rb | 59 +++ .../datasources/v1beta/fileuploads.rb | 131 ++++++ .../file_uploads_service/get_file_upload.rb | 47 ++ ....shopping.merchant.datasources.v1beta.json | 40 ++ .../v1beta/file_uploads_service_paths_test.rb | 47 ++ .../v1beta/file_uploads_service_rest_test.rb | 145 ++++++ .../v1beta/file_uploads_service_test.rb | 134 ++++++ 25 files changed, 2053 insertions(+), 5 deletions(-) create mode 100644 google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/client.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/credentials.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/paths.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/client.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/service_stub.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/fileuploads_pb.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/fileuploads_services_pb.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/proto_docs/google/protobuf/timestamp.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/proto_docs/google/shopping/merchant/datasources/v1beta/fileuploads.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/snippets/file_uploads_service/get_file_upload.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_paths_test.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_rest_test.rb create mode 100644 google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_test.rb diff --git a/google-shopping-merchant-data_sources-v1beta/.owlbot-manifest.json b/google-shopping-merchant-data_sources-v1beta/.owlbot-manifest.json index ba19c00e93c5..507e99c40980 100644 --- a/google-shopping-merchant-data_sources-v1beta/.owlbot-manifest.json +++ b/google-shopping-merchant-data_sources-v1beta/.owlbot-manifest.json @@ -22,12 +22,21 @@ "lib/google/shopping/merchant/data_sources/v1beta/data_sources_service/rest.rb", "lib/google/shopping/merchant/data_sources/v1beta/data_sources_service/rest/client.rb", "lib/google/shopping/merchant/data_sources/v1beta/data_sources_service/rest/service_stub.rb", + "lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service.rb", + "lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/client.rb", + "lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/credentials.rb", + "lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/paths.rb", + "lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest.rb", + "lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/client.rb", + "lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/service_stub.rb", "lib/google/shopping/merchant/data_sources/v1beta/rest.rb", "lib/google/shopping/merchant/data_sources/v1beta/version.rb", "lib/google/shopping/merchant/datasources/v1beta/datasources_pb.rb", "lib/google/shopping/merchant/datasources/v1beta/datasources_services_pb.rb", "lib/google/shopping/merchant/datasources/v1beta/datasourcetypes_pb.rb", "lib/google/shopping/merchant/datasources/v1beta/fileinputs_pb.rb", + "lib/google/shopping/merchant/datasources/v1beta/fileuploads_pb.rb", + "lib/google/shopping/merchant/datasources/v1beta/fileuploads_services_pb.rb", "proto_docs/README.md", "proto_docs/google/api/client.rb", "proto_docs/google/api/field_behavior.rb", @@ -36,9 +45,11 @@ "proto_docs/google/protobuf/duration.rb", "proto_docs/google/protobuf/empty.rb", "proto_docs/google/protobuf/field_mask.rb", + "proto_docs/google/protobuf/timestamp.rb", "proto_docs/google/shopping/merchant/datasources/v1beta/datasources.rb", "proto_docs/google/shopping/merchant/datasources/v1beta/datasourcetypes.rb", "proto_docs/google/shopping/merchant/datasources/v1beta/fileinputs.rb", + "proto_docs/google/shopping/merchant/datasources/v1beta/fileuploads.rb", "proto_docs/google/type/dayofweek.rb", "proto_docs/google/type/timeofday.rb", "snippets/Gemfile", @@ -48,10 +59,14 @@ "snippets/data_sources_service/get_data_source.rb", "snippets/data_sources_service/list_data_sources.rb", "snippets/data_sources_service/update_data_source.rb", + "snippets/file_uploads_service/get_file_upload.rb", "snippets/snippet_metadata_google.shopping.merchant.datasources.v1beta.json", "test/google/shopping/merchant/data_sources/v1beta/data_sources_service_paths_test.rb", "test/google/shopping/merchant/data_sources/v1beta/data_sources_service_rest_test.rb", "test/google/shopping/merchant/data_sources/v1beta/data_sources_service_test.rb", + "test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_paths_test.rb", + "test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_rest_test.rb", + "test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_test.rb", "test/helper.rb" ], "static": [ diff --git a/google-shopping-merchant-data_sources-v1beta/.repo-metadata.json b/google-shopping-merchant-data_sources-v1beta/.repo-metadata.json index 27f0a0f3d9e9..a59fd655ea12 100644 --- a/google-shopping-merchant-data_sources-v1beta/.repo-metadata.json +++ b/google-shopping-merchant-data_sources-v1beta/.repo-metadata.json @@ -11,7 +11,7 @@ "release_level": "preview", "repo": "googleapis/google-cloud-ruby", "requires_billing": true, - "ruby-cloud-description": "Programmatically manage your Merchant Center accounts. Note that google-shopping-merchant-data_sources-v1beta is a version-specific client library. For most uses, we recommend installing the main client library google-shopping-merchant-data_sources instead. See the readme for more details.", + "ruby-cloud-description": "Merchant API consists of multiple Sub-APIs. Accounts Sub-API: Enables you to programmatically manage your accounts. Conversions Sub-API: Enables you to programmatically manage your conversion sources for a merchant account. Datasources Sub-API: Enables you to programmatically manage your datasources. Inventories Sub-API: This bundle enables you to programmatically manage your local and regional inventories. Local Feeds Partnerships Sub-API: This bundle enables LFP partners to submit local inventories for a merchant. Notifications Sub-API: This bundle enables you to programmatically manage your notification subscriptions. Products Sub-API: This bundle enables you to programmatically manage your products. Promotions Sub-API: This bundle enables you to programmatically manage your promotions for products. Quota Sub-API: This bundle enables you to list your quotas for all APIs you are using. Reports Sub-API: This bundle enables you to programmatically retrieve reports and insights about products, their performance and their competitive environment. Note that google-shopping-merchant-data_sources-v1beta is a version-specific client library. For most uses, we recommend installing the main client library google-shopping-merchant-data_sources instead. See the readme for more details.", "ruby-cloud-product-url": "https://developers.google.com/merchant/api", "library_type": "GAPIC_AUTO" } diff --git a/google-shopping-merchant-data_sources-v1beta/README.md b/google-shopping-merchant-data_sources-v1beta/README.md index 0a87ad929ba7..edc8ea4940c4 100644 --- a/google-shopping-merchant-data_sources-v1beta/README.md +++ b/google-shopping-merchant-data_sources-v1beta/README.md @@ -1,7 +1,8 @@ # Ruby Client for the Merchant V1BETA API -Programmatically manage your Merchant Center accounts. +Programmatically manage your Merchant Center Accounts. +Merchant API consists of multiple Sub-APIs. Accounts Sub-API: Enables you to programmatically manage your accounts. Conversions Sub-API: Enables you to programmatically manage your conversion sources for a merchant account. Datasources Sub-API: Enables you to programmatically manage your datasources. Inventories Sub-API: This bundle enables you to programmatically manage your local and regional inventories. Local Feeds Partnerships Sub-API: This bundle enables LFP partners to submit local inventories for a merchant. Notifications Sub-API: This bundle enables you to programmatically manage your notification subscriptions. Products Sub-API: This bundle enables you to programmatically manage your products. Promotions Sub-API: This bundle enables you to programmatically manage your promotions for products. Quota Sub-API: This bundle enables you to list your quotas for all APIs you are using. Reports Sub-API: This bundle enables you to programmatically retrieve reports and insights about products, their performance and their competitive environment. https://github.com/googleapis/google-cloud-ruby diff --git a/google-shopping-merchant-data_sources-v1beta/gapic_metadata.json b/google-shopping-merchant-data_sources-v1beta/gapic_metadata.json index 837915a3335c..d925fc1c73dd 100644 --- a/google-shopping-merchant-data_sources-v1beta/gapic_metadata.json +++ b/google-shopping-merchant-data_sources-v1beta/gapic_metadata.json @@ -43,6 +43,20 @@ } } } + }, + "FileUploadsService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client", + "rpcs": { + "GetFileUpload": { + "methods": [ + "get_file_upload" + ] + } + } + } + } } } } diff --git a/google-shopping-merchant-data_sources-v1beta/google-shopping-merchant-data_sources-v1beta.gemspec b/google-shopping-merchant-data_sources-v1beta/google-shopping-merchant-data_sources-v1beta.gemspec index c7d272bc99d3..572db9394869 100644 --- a/google-shopping-merchant-data_sources-v1beta/google-shopping-merchant-data_sources-v1beta.gemspec +++ b/google-shopping-merchant-data_sources-v1beta/google-shopping-merchant-data_sources-v1beta.gemspec @@ -9,8 +9,8 @@ Gem::Specification.new do |gem| gem.authors = ["Google LLC"] gem.email = "googleapis-packages@google.com" - gem.description = "Programmatically manage your Merchant Center accounts. Note that google-shopping-merchant-data_sources-v1beta is a version-specific client library. For most uses, we recommend installing the main client library google-shopping-merchant-data_sources instead. See the readme for more details." - gem.summary = "Programmatically manage your Merchant Center accounts." + gem.description = "Merchant API consists of multiple Sub-APIs. Accounts Sub-API: Enables you to programmatically manage your accounts. Conversions Sub-API: Enables you to programmatically manage your conversion sources for a merchant account. Datasources Sub-API: Enables you to programmatically manage your datasources. Inventories Sub-API: This bundle enables you to programmatically manage your local and regional inventories. Local Feeds Partnerships Sub-API: This bundle enables LFP partners to submit local inventories for a merchant. Notifications Sub-API: This bundle enables you to programmatically manage your notification subscriptions. Products Sub-API: This bundle enables you to programmatically manage your products. Promotions Sub-API: This bundle enables you to programmatically manage your promotions for products. Quota Sub-API: This bundle enables you to list your quotas for all APIs you are using. Reports Sub-API: This bundle enables you to programmatically retrieve reports and insights about products, their performance and their competitive environment. Note that google-shopping-merchant-data_sources-v1beta is a version-specific client library. For most uses, we recommend installing the main client library google-shopping-merchant-data_sources instead. See the readme for more details." + gem.summary = "Programmatically manage your Merchant Center Accounts." gem.homepage = "https://github.com/googleapis/google-cloud-ruby" gem.license = "Apache-2.0" diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta.rb index 69a34e75df22..0dc88b2d43fa 100644 --- a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta.rb +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta.rb @@ -17,6 +17,7 @@ # Auto-generated by gapic-generator-ruby. DO NOT EDIT! require "google/shopping/merchant/data_sources/v1beta/data_sources_service" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service" require "google/shopping/merchant/data_sources/v1beta/version" module Google diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service.rb new file mode 100644 index 000000000000..ca6aa117bdb0 --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/data_sources/v1beta/version" + +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/credentials" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/paths" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/client" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest" + +module Google + module Shopping + module Merchant + module DataSources + module V1beta + ## + # Service to manage data source file uploads. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/data_sources/v1beta/file_uploads_service" + # client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest" + # client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client.new + # + module FileUploadsService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "file_uploads_service", "helpers.rb" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/client.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/client.rb new file mode 100644 index 000000000000..8b7133c8829d --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/client.rb @@ -0,0 +1,435 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/datasources/v1beta/fileuploads_pb" + +module Google + module Shopping + module Merchant + module DataSources + module V1beta + module FileUploadsService + ## + # Client for the FileUploadsService service. + # + # Service to manage data source file uploads. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :file_uploads_service_stub + + ## + # Configure the FileUploadsService Client class. + # + # See {::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all FileUploadsService clients + # ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "DataSources", "V1beta"] + 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 = 60.0 + default_config.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the FileUploadsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @file_uploads_service_stub.universe_domain + end + + ## + # Create a new FileUploadsService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the FileUploadsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/datasources/v1beta/fileuploads_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @file_uploads_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Gets the latest data source file upload. Only the `latest` alias is + # accepted for a file upload. + # + # @overload get_file_upload(request, options = nil) + # Pass arguments to `get_file_upload` via a request object, either of type + # {::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest, ::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. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_file_upload(name: nil) + # Pass arguments to `get_file_upload` 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). + # + # @param name [::String] + # Required. The name of the data source file upload to retrieve. + # Format: + # `accounts/{account}/dataSources/{datasource}/fileUploads/latest` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::DataSources::V1beta::FileUpload] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::DataSources::V1beta::FileUpload] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/data_sources/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest.new + # + # # Call the get_file_upload method. + # result = client.get_file_upload request + # + # # The returned object is of type Google::Shopping::Merchant::DataSources::V1beta::FileUpload. + # p result + # + def get_file_upload request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest + + # 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 + metadata = @config.rpcs.get_file_upload.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::DataSources::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_file_upload.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_file_upload.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @file_uploads_service_stub.call_rpc :get_file_upload, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the FileUploadsService API. + # + # This class represents the configuration for FileUploadsService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_file_upload to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_file_upload.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_file_upload.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the FileUploadsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_file_upload` + # @return [::Gapic::Config::Method] + # + attr_reader :get_file_upload + + # @private + def initialize parent_rpcs = nil + get_file_upload_config = parent_rpcs.get_file_upload if parent_rpcs.respond_to? :get_file_upload + @get_file_upload = ::Gapic::Config::Method.new get_file_upload_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/credentials.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/credentials.rb new file mode 100644 index 000000000000..49c1a8e975a9 --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module DataSources + module V1beta + module FileUploadsService + # Credentials for the FileUploadsService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/paths.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/paths.rb new file mode 100644 index 000000000000..ebad940e0b7e --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/paths.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module DataSources + module V1beta + module FileUploadsService + # Path helper methods for the FileUploadsService API. + module Paths + ## + # Create a fully-qualified FileUpload resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/dataSources/{datasource}/fileUploads/{fileupload}` + # + # @param account [String] + # @param datasource [String] + # @param fileupload [String] + # + # @return [::String] + def file_upload_path account:, datasource:, fileupload: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + raise ::ArgumentError, "datasource cannot contain /" if datasource.to_s.include? "/" + + "accounts/#{account}/dataSources/#{datasource}/fileUploads/#{fileupload}" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest.rb new file mode 100644 index 000000000000..5d5897f41825 --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/data_sources/v1beta/version" + +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/credentials" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/paths" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/client" + +module Google + module Shopping + module Merchant + module DataSources + module V1beta + ## + # Service to manage data source file uploads. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest" + # client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client.new + # + module FileUploadsService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/client.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/client.rb new file mode 100644 index 000000000000..7ed22a98cd59 --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/client.rb @@ -0,0 +1,402 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/datasources/v1beta/fileuploads_pb" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module DataSources + module V1beta + module FileUploadsService + module Rest + ## + # REST client for the FileUploadsService service. + # + # Service to manage data source file uploads. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :file_uploads_service_stub + + ## + # Configure the FileUploadsService Client class. + # + # See {::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all FileUploadsService clients + # ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "DataSources", "V1beta"] + 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 = 60.0 + default_config.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the FileUploadsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @file_uploads_service_stub.universe_domain + end + + ## + # Create a new FileUploadsService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the FileUploadsService client. + # @yieldparam config [Client::Configuration] + # + 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 + + @file_uploads_service_stub = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Gets the latest data source file upload. Only the `latest` alias is + # accepted for a file upload. + # + # @overload get_file_upload(request, options = nil) + # Pass arguments to `get_file_upload` via a request object, either of type + # {::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest, ::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. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_file_upload(name: nil) + # Pass arguments to `get_file_upload` 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). + # + # @param name [::String] + # Required. The name of the data source file upload to retrieve. + # Format: + # `accounts/{account}/dataSources/{datasource}/fileUploads/latest` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::DataSources::V1beta::FileUpload] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::DataSources::V1beta::FileUpload] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/data_sources/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest.new + # + # # Call the get_file_upload method. + # result = client.get_file_upload request + # + # # The returned object is of type Google::Shopping::Merchant::DataSources::V1beta::FileUpload. + # p result + # + def get_file_upload request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest + + # 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 + call_metadata = @config.rpcs.get_file_upload.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::DataSources::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_file_upload.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_file_upload.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @file_uploads_service_stub.get_file_upload 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 + + ## + # Configuration class for the FileUploadsService REST API. + # + # This class represents the configuration for FileUploadsService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_file_upload to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_file_upload.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_file_upload.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the FileUploadsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_file_upload` + # @return [::Gapic::Config::Method] + # + attr_reader :get_file_upload + + # @private + def initialize parent_rpcs = nil + get_file_upload_config = parent_rpcs.get_file_upload if parent_rpcs.respond_to? :get_file_upload + @get_file_upload = ::Gapic::Config::Method.new get_file_upload_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/service_stub.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/service_stub.rb new file mode 100644 index 000000000000..021855069676 --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest/service_stub.rb @@ -0,0 +1,130 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/datasources/v1beta/fileuploads_pb" + +module Google + module Shopping + module Merchant + module DataSources + module V1beta + module FileUploadsService + module Rest + ## + # REST service stub for the FileUploadsService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_file_upload REST call + # + # @param request_pb [::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::DataSources::V1beta::FileUpload] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::DataSources::V1beta::FileUpload] + # A result object deserialized from the server's reply + def get_file_upload request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_file_upload_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::DataSources::V1beta::FileUpload.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_file_upload REST call + # + # @param request_pb [::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_file_upload_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/datasources/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/dataSources/[^/]+/fileUploads/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/rest.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/rest.rb index bf326d2bfabd..73d6658d1b52 100644 --- a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/rest.rb +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/data_sources/v1beta/rest.rb @@ -17,6 +17,7 @@ # Auto-generated by gapic-generator-ruby. DO NOT EDIT! require "google/shopping/merchant/data_sources/v1beta/data_sources_service/rest" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest" require "google/shopping/merchant/data_sources/v1beta/version" module Google diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/datasourcetypes_pb.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/datasourcetypes_pb.rb index dda9e29bb644..3514812f1a90 100644 --- a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/datasourcetypes_pb.rb +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/datasourcetypes_pb.rb @@ -7,7 +7,7 @@ require 'google/api/field_behavior_pb' -descriptor_data = "\nAgoogle/shopping/merchant/datasources/v1beta/datasourcetypes.proto\x12+google.shopping.merchant.datasources.v1beta\x1a\x1fgoogle/api/field_behavior.proto\"\xe1\x02\n\x18PrimaryProductDataSource\x12\x66\n\x07\x63hannel\x18\x03 \x01(\x0e\x32M.google.shopping.merchant.datasources.v1beta.PrimaryProductDataSource.ChannelB\x06\xe0\x41\x02\xe0\x41\x05\x12\x1f\n\nfeed_label\x18\x04 \x01(\tB\x06\xe0\x41\x01\xe0\x41\x05H\x00\x88\x01\x01\x12%\n\x10\x63ontent_language\x18\x05 \x01(\tB\x06\xe0\x41\x01\xe0\x41\x05H\x01\x88\x01\x01\x12\x16\n\tcountries\x18\x06 \x03(\tB\x03\xe0\x41\x01\"Y\n\x07\x43hannel\x12\x17\n\x13\x43HANNEL_UNSPECIFIED\x10\x00\x12\x13\n\x0fONLINE_PRODUCTS\x10\x01\x12\x12\n\x0eLOCAL_PRODUCTS\x10\x02\x12\x0c\n\x08PRODUCTS\x10\x03\x42\r\n\x0b_feed_labelB\x13\n\x11_content_language\"\x8b\x01\n\x1dSupplementalProductDataSource\x12\x1f\n\nfeed_label\x18\x04 \x01(\tB\x06\xe0\x41\x01\xe0\x41\x05H\x00\x88\x01\x01\x12%\n\x10\x63ontent_language\x18\x05 \x01(\tB\x06\xe0\x41\x01\xe0\x41\x05H\x01\x88\x01\x01\x42\r\n\x0b_feed_labelB\x13\n\x11_content_language\"X\n\x18LocalInventoryDataSource\x12\x1a\n\nfeed_label\x18\x04 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\x12 \n\x10\x63ontent_language\x18\x05 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\"[\n\x1bRegionalInventoryDataSource\x12\x1a\n\nfeed_label\x18\x04 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\x12 \n\x10\x63ontent_language\x18\x05 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\"W\n\x13PromotionDataSource\x12\x1e\n\x0etarget_country\x18\x01 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\x12 \n\x10\x63ontent_language\x18\x02 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\x42\xb0\x02\n/com.google.shopping.merchant.datasources.v1betaB\x14\x44\x61tasourcetypesProtoP\x01ZWcloud.google.com/go/shopping/merchant/datasources/apiv1beta/datasourcespb;datasourcespb\xaa\x02+Google.Shopping.Merchant.DataSources.V1Beta\xca\x02+Google\\Shopping\\Merchant\\DataSources\\V1beta\xea\x02/Google::Shopping::Merchant::DataSources::V1betab\x06proto3" +descriptor_data = "\nAgoogle/shopping/merchant/datasources/v1beta/datasourcetypes.proto\x12+google.shopping.merchant.datasources.v1beta\x1a\x1fgoogle/api/field_behavior.proto\"\xc5\x04\n\x18PrimaryProductDataSource\x12\x66\n\x07\x63hannel\x18\x03 \x01(\x0e\x32M.google.shopping.merchant.datasources.v1beta.PrimaryProductDataSource.ChannelB\x06\xe0\x41\x02\xe0\x41\x05\x12\x1f\n\nfeed_label\x18\x04 \x01(\tB\x06\xe0\x41\x01\xe0\x41\x05H\x00\x88\x01\x01\x12%\n\x10\x63ontent_language\x18\x05 \x01(\tB\x06\xe0\x41\x01\xe0\x41\x05H\x01\x88\x01\x01\x12\x16\n\tcountries\x18\x06 \x03(\tB\x03\xe0\x41\x01\x12l\n\x0c\x64\x65\x66\x61ult_rule\x18\x07 \x01(\x0b\x32Q.google.shopping.merchant.datasources.v1beta.PrimaryProductDataSource.DefaultRuleB\x03\xe0\x41\x01\x1at\n\x0b\x44\x65\x66\x61ultRule\x12\x65\n\x16take_from_data_sources\x18\x01 \x03(\x0b\x32@.google.shopping.merchant.datasources.v1beta.DataSourceReferenceB\x03\xe0\x41\x02\"Y\n\x07\x43hannel\x12\x17\n\x13\x43HANNEL_UNSPECIFIED\x10\x00\x12\x13\n\x0fONLINE_PRODUCTS\x10\x01\x12\x12\n\x0eLOCAL_PRODUCTS\x10\x02\x12\x0c\n\x08PRODUCTS\x10\x03\x42\r\n\x0b_feed_labelB\x13\n\x11_content_language\"\xfc\x01\n\x1dSupplementalProductDataSource\x12\x1f\n\nfeed_label\x18\x04 \x01(\tB\x06\xe0\x41\x01\xe0\x41\x05H\x00\x88\x01\x01\x12%\n\x10\x63ontent_language\x18\x05 \x01(\tB\x06\xe0\x41\x01\xe0\x41\x05H\x01\x88\x01\x01\x12o\n referencing_primary_data_sources\x18\x07 \x03(\x0b\x32@.google.shopping.merchant.datasources.v1beta.DataSourceReferenceB\x03\xe0\x41\x03\x42\r\n\x0b_feed_labelB\x13\n\x11_content_language\"X\n\x18LocalInventoryDataSource\x12\x1a\n\nfeed_label\x18\x04 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\x12 \n\x10\x63ontent_language\x18\x05 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\"[\n\x1bRegionalInventoryDataSource\x12\x1a\n\nfeed_label\x18\x04 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\x12 \n\x10\x63ontent_language\x18\x05 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\"W\n\x13PromotionDataSource\x12\x1e\n\x0etarget_country\x18\x01 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\x12 \n\x10\x63ontent_language\x18\x02 \x01(\tB\x06\xe0\x41\x02\xe0\x41\x05\"\x8e\x01\n\x13\x44\x61taSourceReference\x12\x0e\n\x04self\x18\x01 \x01(\x08H\x00\x12\'\n\x18primary_data_source_name\x18\x03 \x01(\tB\x03\xe0\x41\x01H\x00\x12,\n\x1dsupplemental_data_source_name\x18\x02 \x01(\tB\x03\xe0\x41\x01H\x00\x42\x10\n\x0e\x64\x61ta_source_idB\xb0\x02\n/com.google.shopping.merchant.datasources.v1betaB\x14\x44\x61tasourcetypesProtoP\x01ZWcloud.google.com/go/shopping/merchant/datasources/apiv1beta/datasourcespb;datasourcespb\xaa\x02+Google.Shopping.Merchant.DataSources.V1Beta\xca\x02+Google\\Shopping\\Merchant\\DataSources\\V1beta\xea\x02/Google::Shopping::Merchant::DataSources::V1betab\x06proto3" pool = Google::Protobuf::DescriptorPool.generated_pool @@ -39,11 +39,13 @@ module Merchant module DataSources module V1beta PrimaryProductDataSource = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.PrimaryProductDataSource").msgclass + PrimaryProductDataSource::DefaultRule = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.PrimaryProductDataSource.DefaultRule").msgclass PrimaryProductDataSource::Channel = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.PrimaryProductDataSource.Channel").enummodule SupplementalProductDataSource = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.SupplementalProductDataSource").msgclass LocalInventoryDataSource = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.LocalInventoryDataSource").msgclass RegionalInventoryDataSource = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.RegionalInventoryDataSource").msgclass PromotionDataSource = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.PromotionDataSource").msgclass + DataSourceReference = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.DataSourceReference").msgclass end end end diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/fileuploads_pb.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/fileuploads_pb.rb new file mode 100644 index 000000000000..8801f3a40dd4 --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/fileuploads_pb.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/datasources/v1beta/fileuploads.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/timestamp_pb' + + +descriptor_data = "\n=google/shopping/merchant/datasources/v1beta/fileuploads.proto\x12+google.shopping.merchant.datasources.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x8a\x07\n\nFileUpload\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x1b\n\x0e\x64\x61ta_source_id\x18\x02 \x01(\x03\x42\x03\xe0\x41\x03\x12\x66\n\x10processing_state\x18\x03 \x01(\x0e\x32G.google.shopping.merchant.datasources.v1beta.FileUpload.ProcessingStateB\x03\xe0\x41\x03\x12R\n\x06issues\x18\x04 \x03(\x0b\x32=.google.shopping.merchant.datasources.v1beta.FileUpload.IssueB\x03\xe0\x41\x03\x12\x18\n\x0bitems_total\x18\x05 \x01(\x03\x42\x03\xe0\x41\x03\x12\x1a\n\ritems_created\x18\x06 \x01(\x03\x42\x03\xe0\x41\x03\x12\x1a\n\ritems_updated\x18\x07 \x01(\x03\x42\x03\xe0\x41\x03\x12\x34\n\x0bupload_time\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x1a\x99\x02\n\x05Issue\x12\x12\n\x05title\x18\x01 \x01(\tB\x03\xe0\x41\x03\x12\x18\n\x0b\x64\x65scription\x18\x02 \x01(\tB\x03\xe0\x41\x03\x12\x11\n\x04\x63ode\x18\x03 \x01(\tB\x03\xe0\x41\x03\x12\x12\n\x05\x63ount\x18\x04 \x01(\x03\x42\x03\xe0\x41\x03\x12]\n\x08severity\x18\x05 \x01(\x0e\x32\x46.google.shopping.merchant.datasources.v1beta.FileUpload.Issue.SeverityB\x03\xe0\x41\x03\x12\x1e\n\x11\x64ocumentation_uri\x18\x06 \x01(\tB\x03\xe0\x41\x03\"<\n\x08Severity\x12\x18\n\x14SEVERITY_UNSPECIFIED\x10\x00\x12\x0b\n\x07WARNING\x10\x01\x12\t\n\x05\x45RROR\x10\x02\"_\n\x0fProcessingState\x12 \n\x1cPROCESSING_STATE_UNSPECIFIED\x10\x00\x12\n\n\x06\x46\x41ILED\x10\x01\x12\x0f\n\x0bIN_PROGRESS\x10\x02\x12\r\n\tSUCCEEDED\x10\x03:\x8a\x01\xea\x41\x86\x01\n%merchantapi.googleapis.com/FileUpload\x12\x44\x61\x63\x63ounts/{account}/dataSources/{datasource}/fileUploads/{fileupload}*\x0b\x66ileUploads2\nfileUpload\"S\n\x14GetFileUploadRequest\x12;\n\x04name\x18\x01 \x01(\tB-\xe0\x41\x02\xfa\x41\'\n%merchantapi.googleapis.com/FileUpload2\xbd\x02\n\x12\x46ileUploadsService\x12\xdd\x01\n\rGetFileUpload\x12\x41.google.shopping.merchant.datasources.v1beta.GetFileUploadRequest\x1a\x37.google.shopping.merchant.datasources.v1beta.FileUpload\"P\xda\x41\x04name\x82\xd3\xe4\x93\x02\x43\x12\x41/datasources/v1beta/{name=accounts/*/dataSources/*/fileUploads/*}\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\xac\x02\n/com.google.shopping.merchant.datasources.v1betaB\x10\x46ileUploadsProtoP\x01ZWcloud.google.com/go/shopping/merchant/datasources/apiv1beta/datasourcespb;datasourcespb\xaa\x02+Google.Shopping.Merchant.DataSources.V1Beta\xca\x02+Google\\Shopping\\Merchant\\DataSources\\V1beta\xea\x02/Google::Shopping::Merchant::DataSources::V1betab\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.protobuf.Timestamp", "google/protobuf/timestamp.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module DataSources + module V1beta + FileUpload = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.FileUpload").msgclass + FileUpload::Issue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.FileUpload.Issue").msgclass + FileUpload::Issue::Severity = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.FileUpload.Issue.Severity").enummodule + FileUpload::ProcessingState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.FileUpload.ProcessingState").enummodule + GetFileUploadRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.datasources.v1beta.GetFileUploadRequest").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/fileuploads_services_pb.rb b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/fileuploads_services_pb.rb new file mode 100644 index 000000000000..10acdf2550d9 --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/lib/google/shopping/merchant/datasources/v1beta/fileuploads_services_pb.rb @@ -0,0 +1,48 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/datasources/v1beta/fileuploads.proto for package 'Google.Shopping.Merchant.DataSources.V1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/datasources/v1beta/fileuploads_pb' + +module Google + module Shopping + module Merchant + module DataSources + module V1beta + module FileUploadsService + # Service to manage data source file uploads. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.datasources.v1beta.FileUploadsService' + + # Gets the latest data source file upload. Only the `latest` alias is + # accepted for a file upload. + rpc :GetFileUpload, ::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest, ::Google::Shopping::Merchant::DataSources::V1beta::FileUpload + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/proto_docs/google/protobuf/timestamp.rb b/google-shopping-merchant-data_sources-v1beta/proto_docs/google/protobuf/timestamp.rb new file mode 100644 index 000000000000..4ac9c4801a3f --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/proto_docs/google/protobuf/timestamp.rb @@ -0,0 +1,127 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Protobuf + # A Timestamp represents a point in time independent of any time zone or local + # calendar, encoded as a count of seconds and fractions of seconds at + # nanosecond resolution. The count is relative to an epoch at UTC midnight on + # January 1, 1970, in the proleptic Gregorian calendar which extends the + # Gregorian calendar backwards to year one. + # + # All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + # second table is needed for interpretation, using a [24-hour linear + # smear](https://developers.google.com/time/smear). + # + # The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + # restricting to that range, we ensure that we can convert to and from [RFC + # 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + # + # # Examples + # + # Example 1: Compute Timestamp from POSIX `time()`. + # + # Timestamp timestamp; + # timestamp.set_seconds(time(NULL)); + # timestamp.set_nanos(0); + # + # Example 2: Compute Timestamp from POSIX `gettimeofday()`. + # + # struct timeval tv; + # gettimeofday(&tv, NULL); + # + # Timestamp timestamp; + # timestamp.set_seconds(tv.tv_sec); + # timestamp.set_nanos(tv.tv_usec * 1000); + # + # Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + # + # FILETIME ft; + # GetSystemTimeAsFileTime(&ft); + # UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + # + # // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + # // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + # Timestamp timestamp; + # timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + # timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + # + # Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + # + # long millis = System.currentTimeMillis(); + # + # Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + # .setNanos((int) ((millis % 1000) * 1000000)).build(); + # + # Example 5: Compute Timestamp from Java `Instant.now()`. + # + # Instant now = Instant.now(); + # + # Timestamp timestamp = + # Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + # .setNanos(now.getNano()).build(); + # + # Example 6: Compute Timestamp from current time in Python. + # + # timestamp = Timestamp() + # timestamp.GetCurrentTime() + # + # # JSON Mapping + # + # In JSON format, the Timestamp type is encoded as a string in the + # [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + # format is "\\{year}-\\{month}-\\{day}T\\{hour}:\\{min}:\\{sec}[.\\{frac_sec}]Z" + # where \\{year} is always expressed using four digits while \\{month}, \\{day}, + # \\{hour}, \\{min}, and \\{sec} are zero-padded to two digits each. The fractional + # seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + # are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + # is required. A proto3 JSON serializer should always use UTC (as indicated by + # "Z") when printing the Timestamp type and a proto3 JSON parser should be + # able to accept both UTC and other timezones (as indicated by an offset). + # + # For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + # 01:30 UTC on January 15, 2017. + # + # In JavaScript, one can convert a Date object to this format using the + # standard + # [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + # method. In Python, a standard `datetime.datetime` object can be converted + # to this format using + # [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + # the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + # the Joda Time's [`ISODateTimeFormat.dateTime()`]( + # http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime() + # ) to obtain a formatter capable of generating timestamps in this format. + # @!attribute [rw] seconds + # @return [::Integer] + # Represents seconds of UTC time since Unix epoch + # 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + # 9999-12-31T23:59:59Z inclusive. + # @!attribute [rw] nanos + # @return [::Integer] + # Non-negative fractions of a second at nanosecond resolution. Negative + # second values with fractions must still have non-negative nanos values + # that count forward in time. Must be from 0 to 999,999,999 + # inclusive. + class Timestamp + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/proto_docs/google/shopping/merchant/datasources/v1beta/datasourcetypes.rb b/google-shopping-merchant-data_sources-v1beta/proto_docs/google/shopping/merchant/datasources/v1beta/datasourcetypes.rb index 98679b747be5..9982d8e8e5fc 100644 --- a/google-shopping-merchant-data_sources-v1beta/proto_docs/google/shopping/merchant/datasources/v1beta/datasourcetypes.rb +++ b/google-shopping-merchant-data_sources-v1beta/proto_docs/google/shopping/merchant/datasources/v1beta/datasourcetypes.rb @@ -60,10 +60,42 @@ module V1beta # Optional. The countries where the items may be displayed. Represented as a # [CLDR territory # code](https://github.com/unicode-org/cldr/blob/latest/common/main/en.xml). + # @!attribute [rw] default_rule + # @return [::Google::Shopping::Merchant::DataSources::V1beta::PrimaryProductDataSource::DefaultRule] + # Optional. Default rule management of the data source. If set, the linked + # data sources will be replaced. class PrimaryProductDataSource include ::Google::Protobuf::MessageExts extend ::Google::Protobuf::MessageExts::ClassMethods + # Default rule management of the data source. + # @!attribute [rw] take_from_data_sources + # @return [::Array<::Google::Shopping::Merchant::DataSources::V1beta::DataSourceReference>] + # Required. The list of data sources linked in the [default + # rule](https://support.google.com/merchants/answer/7450276). + # This list is ordered by the default rule priority of joining the data. + # It might include none or multiple references to `self` and supplemental + # data sources. + # + # The list must not be empty. + # + # To link the data source to the default rule, you need to add a + # new reference to this list (in sequential order). + # + # To unlink the data source from the default rule, you need to + # remove the given reference from this list. + # + # Changing the order of this list will result in changing the priority of + # data sources in the default rule. + # + # For example, providing the following list: [`1001`, `self`] will + # take attribute values from supplemental data source `1001`, and fallback + # to `self` if the attribute is not set in `1001`. + class DefaultRule + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + # Data Source Channel. # # Channel is used to distinguish between data sources for different product @@ -79,6 +111,8 @@ module Channel LOCAL_PRODUCTS = 2 # Unified data source for both local and online products. + # Note: Products management through the API is not possible for this + # channel. PRODUCTS = 3 end end @@ -113,6 +147,11 @@ module Channel # If set, the data source will only accept products matching this # combination. If unset, the data source will accept produts without that # restriction. + # @!attribute [r] referencing_primary_data_sources + # @return [::Array<::Google::Shopping::Merchant::DataSources::V1beta::DataSourceReference>] + # Output only. The (unordered and deduplicated) list of all primary data + # sources linked to this data source in either default or custom rules. + # Supplemental data source cannot be deleted before all links are removed. class SupplementalProductDataSource include ::Google::Protobuf::MessageExts extend ::Google::Protobuf::MessageExts::ClassMethods @@ -175,6 +214,26 @@ class PromotionDataSource include ::Google::Protobuf::MessageExts extend ::Google::Protobuf::MessageExts::ClassMethods end + + # Data source reference can be used to manage related data sources within the + # data source service. + # @!attribute [rw] self + # @return [::Boolean] + # Self should be used to reference the primary data source itself. + # @!attribute [rw] primary_data_source_name + # @return [::String] + # Optional. The name of the primary data source. + # Format: + # `accounts/{account}/dataSources/{datasource}` + # @!attribute [rw] supplemental_data_source_name + # @return [::String] + # Optional. The name of the supplemental data source. + # Format: + # `accounts/{account}/dataSources/{datasource}` + class DataSourceReference + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end end end end diff --git a/google-shopping-merchant-data_sources-v1beta/proto_docs/google/shopping/merchant/datasources/v1beta/fileuploads.rb b/google-shopping-merchant-data_sources-v1beta/proto_docs/google/shopping/merchant/datasources/v1beta/fileuploads.rb new file mode 100644 index 000000000000..616d2b3c718c --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/proto_docs/google/shopping/merchant/datasources/v1beta/fileuploads.rb @@ -0,0 +1,131 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module DataSources + module V1beta + # The file upload of a specific data source, that is, the result of the + # retrieval of the data source at a certain timestamp computed asynchronously + # when the data source processing is finished. Only applicable to file data + # sources. + # @!attribute [rw] name + # @return [::String] + # Identifier. The name of the data source file upload. + # Format: + # `{datasource.name=accounts/{account}/dataSources/{datasource}/fileUploads/{fileupload}}` + # @!attribute [r] data_source_id + # @return [::Integer] + # Output only. The data source id. + # @!attribute [r] processing_state + # @return [::Google::Shopping::Merchant::DataSources::V1beta::FileUpload::ProcessingState] + # Output only. The processing state of the data source. + # @!attribute [r] issues + # @return [::Array<::Google::Shopping::Merchant::DataSources::V1beta::FileUpload::Issue>] + # Output only. The list of issues occurring in the data source. + # @!attribute [r] items_total + # @return [::Integer] + # Output only. The number of items in the data source that were processed. + # @!attribute [r] items_created + # @return [::Integer] + # Output only. The number of items in the data source that were created. + # @!attribute [r] items_updated + # @return [::Integer] + # Output only. The number of items in the data source that were updated. + # @!attribute [r] upload_time + # @return [::Google::Protobuf::Timestamp] + # Output only. The date at which the file of the data source was uploaded. + class FileUpload + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # An error occurring in the data source, like "invalid price". + # @!attribute [r] title + # @return [::String] + # Output only. The title of the issue, for example, "Item too big". + # @!attribute [r] description + # @return [::String] + # Output only. The error description, for example, "Your data source + # contains items which have too many attributes, or are too big. These + # items will be dropped". + # @!attribute [r] code + # @return [::String] + # Output only. The code of the error, for example, + # "validation/invalid_value". Returns + # "?" if the code is unknown. + # @!attribute [r] count + # @return [::Integer] + # Output only. The number of occurrences of the error in the file upload. + # @!attribute [r] severity + # @return [::Google::Shopping::Merchant::DataSources::V1beta::FileUpload::Issue::Severity] + # Output only. The severity of the issue. + # @!attribute [r] documentation_uri + # @return [::String] + # Output only. Link to the documentation explaining the issue in more + # details, if available. + class Issue + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The severity of the issue. + module Severity + # Severity unspecified. + SEVERITY_UNSPECIFIED = 0 + + # The issue is the warning. + WARNING = 1 + + # The issue is an error. + ERROR = 2 + end + end + + # The processing state of the data source. + module ProcessingState + # Processing state unspecified. + PROCESSING_STATE_UNSPECIFIED = 0 + + # The data source could not be processed or all the items had errors. + FAILED = 1 + + # The data source is being processed. + IN_PROGRESS = 2 + + # The data source was processed successfully, though some items might have + # had errors. + SUCCEEDED = 3 + end + end + + # Request message for the GetFileUploadRequest method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the data source file upload to retrieve. + # Format: + # `accounts/{account}/dataSources/{datasource}/fileUploads/latest` + class GetFileUploadRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/snippets/file_uploads_service/get_file_upload.rb b/google-shopping-merchant-data_sources-v1beta/snippets/file_uploads_service/get_file_upload.rb new file mode 100644 index 000000000000..b7f0e7d2da36 --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/snippets/file_uploads_service/get_file_upload.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_FileUploadsService_GetFileUpload_sync] +require "google/shopping/merchant/data_sources/v1beta" + +## +# Snippet for the get_file_upload call in the FileUploadsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client#get_file_upload. +# +def get_file_upload + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest.new + + # Call the get_file_upload method. + result = client.get_file_upload request + + # The returned object is of type Google::Shopping::Merchant::DataSources::V1beta::FileUpload. + p result +end +# [END merchantapi_v1beta_generated_FileUploadsService_GetFileUpload_sync] diff --git a/google-shopping-merchant-data_sources-v1beta/snippets/snippet_metadata_google.shopping.merchant.datasources.v1beta.json b/google-shopping-merchant-data_sources-v1beta/snippets/snippet_metadata_google.shopping.merchant.datasources.v1beta.json index b0fe7a1428af..38c88fd722c4 100644 --- a/google-shopping-merchant-data_sources-v1beta/snippets/snippet_metadata_google.shopping.merchant.datasources.v1beta.json +++ b/google-shopping-merchant-data_sources-v1beta/snippets/snippet_metadata_google.shopping.merchant.datasources.v1beta.json @@ -250,6 +250,46 @@ "type": "FULL" } ] + }, + { + "region_tag": "merchantapi_v1beta_generated_FileUploadsService_GetFileUpload_sync", + "title": "Snippet for the get_file_upload call in the FileUploadsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client#get_file_upload.", + "file": "file_uploads_service/get_file_upload.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_file_upload", + "full_name": "::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client#get_file_upload", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::DataSources::V1beta::FileUpload", + "client": { + "short_name": "FileUploadsService::Client", + "full_name": "::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client" + }, + "method": { + "short_name": "GetFileUpload", + "full_name": "google.shopping.merchant.datasources.v1beta.FileUploadsService.GetFileUpload", + "service": { + "short_name": "FileUploadsService", + "full_name": "google.shopping.merchant.datasources.v1beta.FileUploadsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] } ] } \ No newline at end of file diff --git a/google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_paths_test.rb b/google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_paths_test.rb new file mode 100644 index 000000000000..26256cf622a4 --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_paths_test.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service" + +class ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_file_upload_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.file_upload_path account: "value0", datasource: "value1", fileupload: "value2" + assert_equal "accounts/value0/dataSources/value1/fileUploads/value2", path + end + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_rest_test.rb b/google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_rest_test.rb new file mode 100644 index 000000000000..2c41b5fc1d54 --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_rest_test.rb @@ -0,0 +1,145 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/datasources/v1beta/fileuploads_pb" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service/rest" + + +class ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_file_upload + # Create test objects. + client_result = ::Google::Shopping::Merchant::DataSources::V1beta::FileUpload.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_file_upload_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::ServiceStub.stub :transcode_get_file_upload_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_file_upload_client_stub do + # Create client + client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_file_upload({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_file_upload name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_file_upload ::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_file_upload({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_file_upload(::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_file_upload_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_test.rb b/google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_test.rb new file mode 100644 index 000000000000..b21de25a7f8b --- /dev/null +++ b/google-shopping-merchant-data_sources-v1beta/test/google/shopping/merchant/data_sources/v1beta/file_uploads_service_test.rb @@ -0,0 +1,134 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/datasources/v1beta/fileuploads_pb" +require "google/shopping/merchant/datasources/v1beta/fileuploads_services_pb" +require "google/shopping/merchant/data_sources/v1beta/file_uploads_service" + +class ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_file_upload + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::DataSources::V1beta::FileUpload.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_file_upload_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_file_upload, name + assert_kind_of ::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_file_upload_client_stub do + # Create client + client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_file_upload({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_file_upload name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_file_upload ::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_file_upload({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_file_upload(::Google::Shopping::Merchant::DataSources::V1beta::GetFileUploadRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_file_upload_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::Client::Configuration, config + end +end