lib/google/cloud/vision_ai/v1/warehouse/rest/client.rb in google-cloud-vision_ai-v1-0.2.0 vs lib/google/cloud/vision_ai/v1/warehouse/rest/client.rb in google-cloud-vision_ai-v1-0.3.0

- old
+ new

@@ -182,25 +182,38 @@ @warehouse_stub = ::Google::Cloud::VisionAI::V1::Warehouse::Rest::ServiceStub.new( endpoint: @config.endpoint, endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, universe_domain: @config.universe_domain, - credentials: credentials + credentials: credentials, + logger: @config.logger ) + @warehouse_stub.logger(stub: true)&.info do |entry| + entry.set_system_name + entry.set_service + entry.message = "Created client for #{entry.service}" + entry.set_credentials_fields credentials + entry.set "customEndpoint", @config.endpoint if @config.endpoint + entry.set "defaultTimeout", @config.timeout if @config.timeout + entry.set "quotaProject", @quota_project_id if @quota_project_id + end + @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config| config.credentials = credentials config.quota_project = @quota_project_id config.endpoint = @warehouse_stub.endpoint config.universe_domain = @warehouse_stub.universe_domain + config.logger = @warehouse_stub.logger if config.respond_to? :logger= end @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config| config.credentials = credentials config.quota_project = @quota_project_id config.endpoint = @warehouse_stub.endpoint config.universe_domain = @warehouse_stub.universe_domain + config.logger = @warehouse_stub.logger if config.respond_to? :logger= end end ## # Get the associated client for long-running operations. @@ -221,10 +234,19 @@ # # @return [Google::Iam::V1::IAMPolicy::Rest::Client] # attr_reader :iam_policy_client + ## + # The logger used for request/response debug logging. + # + # @return [Logger] + # + def logger + @warehouse_stub.logger + end + # Service calls ## # Creates an asset inside corpus. # @@ -308,11 +330,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.create_asset 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 @@ -393,11 +414,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.update_asset 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 @@ -474,11 +494,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.get_asset 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 @@ -576,11 +595,11 @@ retry_policy: @config.retry_policy @warehouse_stub.list_assets request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :list_assets, "assets", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -665,11 +684,11 @@ retry_policy: @config.retry_policy @warehouse_stub.delete_asset request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -765,11 +784,11 @@ retry_policy: @config.retry_policy @warehouse_stub.upload_asset request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -848,11 +867,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.generate_retrieval_url 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 @@ -937,11 +955,11 @@ retry_policy: @config.retry_policy @warehouse_stub.analyze_asset request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -1031,11 +1049,11 @@ retry_policy: @config.retry_policy @warehouse_stub.index_asset request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -1125,11 +1143,11 @@ retry_policy: @config.retry_policy @warehouse_stub.remove_index_asset request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -1227,11 +1245,11 @@ retry_policy: @config.retry_policy @warehouse_stub.view_indexed_assets request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :view_indexed_assets, "indexed_assets", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -1326,11 +1344,11 @@ retry_policy: @config.retry_policy @warehouse_stub.create_index request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -1422,11 +1440,11 @@ retry_policy: @config.retry_policy @warehouse_stub.update_index request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -1503,11 +1521,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.get_index 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 @@ -1600,11 +1617,11 @@ retry_policy: @config.retry_policy @warehouse_stub.list_indexes request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :list_indexes, "indexes", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -1690,11 +1707,11 @@ retry_policy: @config.retry_policy @warehouse_stub.delete_index request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -1779,11 +1796,11 @@ retry_policy: @config.retry_policy @warehouse_stub.create_corpus request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -1858,11 +1875,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.get_corpus 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 @@ -1939,11 +1955,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.update_corpus 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 @@ -2041,11 +2056,11 @@ retry_policy: @config.retry_policy @warehouse_stub.list_corpora request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :list_corpora, "corpora", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -2121,11 +2136,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.delete_corpus 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 @@ -2210,11 +2224,11 @@ retry_policy: @config.retry_policy @warehouse_stub.analyze_corpus request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -2293,11 +2307,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.create_data_schema 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 @@ -2376,11 +2389,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.update_data_schema 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 @@ -2457,11 +2469,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.get_data_schema 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 @@ -2538,11 +2549,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.delete_data_schema 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 @@ -2634,11 +2644,11 @@ retry_policy: @config.retry_policy @warehouse_stub.list_data_schemas request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :list_data_schemas, "data_schemas", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -2725,11 +2735,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.create_annotation 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 @@ -2806,11 +2815,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.get_annotation 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 @@ -2918,11 +2926,11 @@ retry_policy: @config.retry_policy @warehouse_stub.list_annotations request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :list_annotations, "annotations", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -3002,11 +3010,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.update_annotation 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 @@ -3083,11 +3090,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.delete_annotation 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 @@ -3171,11 +3177,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.clip_asset 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 @@ -3260,11 +3265,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.generate_hls_uri 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 @@ -3356,11 +3360,11 @@ retry_policy: @config.retry_policy @warehouse_stub.import_assets request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -3458,11 +3462,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.create_search_config 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 @@ -3557,11 +3560,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.update_search_config 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 @@ -3638,11 +3640,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.get_search_config 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 @@ -3722,11 +3723,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.delete_search_config 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 @@ -3819,11 +3819,11 @@ retry_policy: @config.retry_policy @warehouse_stub.list_search_configs request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :list_search_configs, "search_configs", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -3904,11 +3904,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.create_search_hypernym 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 @@ -3989,11 +3988,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.update_search_hypernym 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 @@ -4070,11 +4068,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.get_search_hypernym 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 @@ -4151,11 +4148,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.delete_search_hypernym 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 @@ -4248,11 +4244,11 @@ retry_policy: @config.retry_policy @warehouse_stub.list_search_hypernyms request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :list_search_hypernyms, "search_hypernyms", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -4360,11 +4356,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.search_assets 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 @@ -4464,11 +4459,11 @@ retry_policy: @config.retry_policy @warehouse_stub.search_index_endpoint request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :search_index_endpoint, "search_result_items", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -4561,11 +4556,11 @@ retry_policy: @config.retry_policy @warehouse_stub.create_index_endpoint request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -4640,11 +4635,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.get_index_endpoint 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 @@ -4743,11 +4737,11 @@ retry_policy: @config.retry_policy @warehouse_stub.list_index_endpoints request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :list_index_endpoints, "index_endpoints", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -4838,11 +4832,11 @@ retry_policy: @config.retry_policy @warehouse_stub.update_index_endpoint request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -4925,11 +4919,11 @@ retry_policy: @config.retry_policy @warehouse_stub.delete_index_endpoint request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -5016,11 +5010,11 @@ retry_policy: @config.retry_policy @warehouse_stub.deploy_index request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -5105,11 +5099,11 @@ retry_policy: @config.retry_policy @warehouse_stub.undeploy_index request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -5203,11 +5197,11 @@ retry_policy: @config.retry_policy @warehouse_stub.create_collection request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -5291,11 +5285,11 @@ retry_policy: @config.retry_policy @warehouse_stub.delete_collection request, options do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -5371,11 +5365,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.get_collection 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 @@ -5462,11 +5455,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.update_collection 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 @@ -5557,11 +5549,11 @@ retry_policy: @config.retry_policy @warehouse_stub.list_collections request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :list_collections, "collections", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -5636,11 +5628,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.add_collection_item 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 @@ -5715,11 +5706,10 @@ metadata: @config.metadata, retry_policy: @config.retry_policy @warehouse_stub.remove_collection_item 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 @@ -5811,11 +5801,11 @@ retry_policy: @config.retry_policy @warehouse_stub.view_collection_items request, options do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @warehouse_stub, :view_collection_items, "items", request, result, options yield result, operation if block_given? - return result + throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end @@ -5891,10 +5881,15 @@ # @!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] + # @!attribute [rw] logger + # A custom logger to use for request/response debug logging, or the value + # `:default` (the default) to construct a default logger, or `nil` to + # explicitly disable logging. + # @return [::Logger,:default,nil] # class Configuration extend ::Gapic::Config # @private @@ -5912,9 +5907,10 @@ 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 + config_attr :logger, :default, ::Logger, nil, :default # @private def initialize parent_config = nil @parent_config = parent_config unless parent_config.nil?