lib/google/cloud/translate.rb in google-cloud-translate-3.3.0 vs lib/google/cloud/translate.rb in google-cloud-translate-3.4.0

- old
+ new

@@ -47,33 +47,37 @@ ## # Create a new client object for TranslationService. # # By default, this returns an instance of # [Google::Cloud::Translate::V3::TranslationService::Client](https://googleapis.dev/ruby/google-cloud-translate-v3/latest/Google/Cloud/Translate/V3/TranslationService/Client.html) - # for version V3 of the API. - # However, you can specify specify a different API version by passing it in the + # for a gRPC client for version V3 of the API. + # However, you can specify a different API version by passing it in the # `version` parameter. If the TranslationService service is # supported by that API version, and the corresponding gem is available, the # appropriate versioned client will be returned. + # You can also specify a different transport by passing `:rest` or `:grpc` in + # the `transport` parameter. # # ## About TranslationService # # Provides natural language translation operations. # # @param version [::String, ::Symbol] The API version to connect to. Optional. # Defaults to `:v3`. - # @return [TranslationService::Client] A client object for the specified version. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [::Object] A client object for the specified version. # - def self.translation_service version: :v3, &block + def self.translation_service version: :v3, transport: :grpc, &block require "google/cloud/translate/#{version.to_s.downcase}" package_name = Google::Cloud::Translate .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first - package_module = Google::Cloud::Translate.const_get package_name - package_module.const_get(:TranslationService).const_get(:Client).new(&block) + service_module = Google::Cloud::Translate.const_get(package_name).const_get(:TranslationService) + service_module = service_module.const_get(:Rest) if transport == :rest + service_module.const_get(:Client).new(&block) end ## # Configure the google-cloud-translate library. # @@ -89,10 +93,10 @@ # * `interceptors` (*type:* `Array<GRPC::ClientInterceptor>`) - # An array of interceptors that are run before calls are executed. # * `timeout` (*type:* `Numeric`) - # Default timeout in seconds. # * `metadata` (*type:* `Hash{Symbol=>String}`) - - # Additional gRPC headers to be sent with the call. + # Additional headers to be sent with the call. # * `retry_policy` (*type:* `Hash`) - # 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.