Class: Google::Cloud::Translate::V3::TranslationService::Rest::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/translate/v3/translation_service/rest/client.rb

Overview

REST client for the TranslationService service.

Provides natural language translation operations.

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#adaptive_mt_dataset_path, #adaptive_mt_file_path, #dataset_path, #glossary_entry_path, #glossary_path, #location_path, #model_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new TranslationService REST client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the TranslationService client.

Yield Parameters:



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 160

def initialize
  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end

  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @operations_client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Operations.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @config.endpoint
    config.universe_domain = @config.universe_domain
  end

  @translation_service_stub = ::Google::Cloud::Translate::V3::TranslationService::Rest::ServiceStub.new(
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    credentials: credentials
  )

  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @translation_service_stub.endpoint
    config.universe_domain = @translation_service_stub.universe_domain
    config.bindings_override = @config.bindings_override
  end

  @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @translation_service_stub.endpoint
    config.universe_domain = @translation_service_stub.universe_domain
  end
end

Instance Attribute Details

#iam_policy_clientGoogle::Iam::V1::IAMPolicy::Rest::Client (readonly)

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

Returns:

  • (Google::Iam::V1::IAMPolicy::Rest::Client)


232
233
234
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 232

def iam_policy_client
  @iam_policy_client
end

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

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

Returns:

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


225
226
227
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 225

def location_client
  @location_client
end

#operations_client::Google::Cloud::Translate::V3::TranslationService::Rest::Operations (readonly)

Get the associated client for long-running operations.



218
219
220
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 218

def operations_client
  @operations_client
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the TranslationService Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all TranslationService clients
::Google::Cloud::Translate::V3::TranslationService::Rest::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 66

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Translate", "V3"]
    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.rpcs.translate_text.timeout = 600.0

    default_config.rpcs.detect_language.timeout = 600.0

    default_config.rpcs.get_supported_languages.timeout = 600.0
    default_config.rpcs.get_supported_languages.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.translate_document.timeout = 600.0

    default_config.rpcs.batch_translate_text.timeout = 600.0

    default_config.rpcs.batch_translate_document.timeout = 600.0

    default_config.rpcs.create_glossary.timeout = 600.0

    default_config.rpcs.list_glossaries.timeout = 600.0
    default_config.rpcs.list_glossaries.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_glossary.timeout = 600.0
    default_config.rpcs.get_glossary.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.delete_glossary.timeout = 600.0
    default_config.rpcs.delete_glossary.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#adaptive_mt_translate(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse #adaptive_mt_translate(parent: nil, dataset: nil, content: nil, reference_sentence_config: nil, glossary_config: nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse

Translate text using Adaptive MT.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest.new

# Call the adaptive_mt_translate method.
result = client.adaptive_mt_translate request

# The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse.
p result

Overloads:

  • #adaptive_mt_translate(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse

    Pass arguments to adaptive_mt_translate via a request object, either of type AdaptiveMtTranslateRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #adaptive_mt_translate(parent: nil, dataset: nil, content: nil, reference_sentence_config: nil, glossary_config: nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse

    Pass arguments to adaptive_mt_translate via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Location to make a regional call.

      Format: projects/{project-number-or-id}/locations/{location-id}.

    • dataset (::String) (defaults to: nil)

      Required. The resource name for the dataset to use for adaptive MT. projects/{project}/locations/{location-id}/adaptiveMtDatasets/{dataset}

    • content (::Array<::String>) (defaults to: nil)

      Required. The content of the input in string format.

    • reference_sentence_config (::Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest::ReferenceSentenceConfig, ::Hash) (defaults to: nil)

      Configuration for caller provided reference sentences.

    • glossary_config (::Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest::GlossaryConfig, ::Hash) (defaults to: nil)

      Optional. Glossary to be applied. The glossary must be within the same region (have the same location-id) as the model, otherwise an INVALID_ARGUMENT (400) error is returned.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2762

def adaptive_mt_translate request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.adaptive_mt_translate..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.adaptive_mt_translate.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.adaptive_mt_translate.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.adaptive_mt_translate 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

#batch_translate_document(request, options = nil) ⇒ ::Gapic::Operation #batch_translate_document(parent: nil, source_language_code: nil, target_language_codes: nil, input_configs: nil, output_config: nil, models: nil, glossaries: nil, format_conversions: nil, customized_attribution: nil, enable_shadow_removal_native_pdf: nil, enable_rotation_correction: nil) ⇒ ::Gapic::Operation

Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::BatchTranslateDocumentRequest.new

# Call the batch_translate_document method.
result = client.batch_translate_document request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #batch_translate_document(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to batch_translate_document via a request object, either of type BatchTranslateDocumentRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::BatchTranslateDocumentRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #batch_translate_document(parent: nil, source_language_code: nil, target_language_codes: nil, input_configs: nil, output_config: nil, models: nil, glossaries: nil, format_conversions: nil, customized_attribution: nil, enable_shadow_removal_native_pdf: nil, enable_rotation_correction: nil) ⇒ ::Gapic::Operation

    Pass arguments to batch_translate_document via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Location to make a regional call.

      Format: projects/{project-number-or-id}/locations/{location-id}.

      The global location is not supported for batch translation.

      Only AutoML Translation models or glossaries within the same region (have the same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.

    • source_language_code (::String) (defaults to: nil)

      Required. The ISO-639 language code of the input document if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support.

    • target_language_codes (::Array<::String>) (defaults to: nil)

      Required. The ISO-639 language code to use for translation of the input document. Specify up to 10 language codes here.

    • input_configs (::Array<::Google::Cloud::Translate::V3::BatchDocumentInputConfig, ::Hash>) (defaults to: nil)

      Required. Input configurations. The total number of files matched should be <= 100. The total content size to translate should be <= 100M Unicode codepoints. The files must use UTF-8 encoding.

    • output_config (::Google::Cloud::Translate::V3::BatchDocumentOutputConfig, ::Hash) (defaults to: nil)

      Required. Output configuration. If 2 input configs match to the same file (that is, same input path), we don't generate output for duplicate inputs.

    • models (::Hash{::String => ::String}) (defaults to: nil)

      Optional. The models to use for translation. Map's key is target language code. Map's value is the model name. Value can be a built-in general model, or an AutoML Translation model.

      The value format depends on model type:

      • AutoML Translation models: projects/{project-number-or-id}/locations/{location-id}/models/{model-id}

      • General (built-in) models: projects/{project-number-or-id}/locations/{location-id}/models/general/nmt,

      If the map is empty or a specific model is not requested for a language pair, then default google model (nmt) is used.

    • glossaries (::Hash{::String => ::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash}) (defaults to: nil)

      Optional. Glossaries to be applied. It's keyed by target language code.

    • format_conversions (::Hash{::String => ::String}) (defaults to: nil)

      Optional. The file format conversion map that is applied to all input files. The map key is the original mime_type. The map value is the target mime_type of translated documents.

      Supported file format conversion includes:

      • application/pdf to application/vnd.openxmlformats-officedocument.wordprocessingml.document

      If nothing specified, output files will be in the same format as the original file.

    • customized_attribution (::String) (defaults to: nil)

      Optional. This flag is to support user customized attribution. If not provided, the default is Machine Translated by Google. Customized attribution should follow rules in https://cloud.google.com/translate/attribution#attribution_and_logos

    • enable_shadow_removal_native_pdf (::Boolean) (defaults to: nil)

      Optional. If true, use the text removal server to remove the shadow text on background image for native pdf translation. Shadow removal feature can only be enabled when is_translate_native_pdf_only: false && pdf_native_only: false

    • enable_rotation_correction (::Boolean) (defaults to: nil)

      Optional. If true, enable auto rotation correction in DVS.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1111

def batch_translate_document request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::BatchTranslateDocumentRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.batch_translate_document..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.batch_translate_document.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.batch_translate_document.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.batch_translate_document request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#batch_translate_text(request, options = nil) ⇒ ::Gapic::Operation #batch_translate_text(parent: nil, source_language_code: nil, target_language_codes: nil, models: nil, input_configs: nil, output_config: nil, glossaries: nil, labels: nil) ⇒ ::Gapic::Operation

Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::BatchTranslateTextRequest.new

# Call the batch_translate_text method.
result = client.batch_translate_text request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #batch_translate_text(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to batch_translate_text via a request object, either of type BatchTranslateTextRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::BatchTranslateTextRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #batch_translate_text(parent: nil, source_language_code: nil, target_language_codes: nil, models: nil, input_configs: nil, output_config: nil, glossaries: nil, labels: nil) ⇒ ::Gapic::Operation

    Pass arguments to batch_translate_text via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Location to make a call. Must refer to a caller's project.

      Format: projects/{project-number-or-id}/locations/{location-id}.

      The global location is not supported for batch translation.

      Only AutoML Translation models or glossaries within the same region (have the same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.

    • source_language_code (::String) (defaults to: nil)

      Required. Source language code.

    • target_language_codes (::Array<::String>) (defaults to: nil)

      Required. Specify up to 10 language codes here.

    • models (::Hash{::String => ::String}) (defaults to: nil)

      Optional. The models to use for translation. Map's key is target language code. Map's value is model name. Value can be a built-in general model, or an AutoML Translation model.

      The value format depends on model type:

      • AutoML Translation models: projects/{project-number-or-id}/locations/{location-id}/models/{model-id}

      • General (built-in) models: projects/{project-number-or-id}/locations/{location-id}/models/general/nmt,

      If the map is empty or a specific model is not requested for a language pair, then default google model (nmt) is used.

    • input_configs (::Array<::Google::Cloud::Translate::V3::InputConfig, ::Hash>) (defaults to: nil)

      Required. Input configurations. The total number of files matched should be <= 100. The total content size should be <= 100M Unicode codepoints. The files must use UTF-8 encoding.

    • output_config (::Google::Cloud::Translate::V3::OutputConfig, ::Hash) (defaults to: nil)

      Required. Output configuration. If 2 input configs match to the same file (that is, same input path), we don't generate output for duplicate inputs.

    • glossaries (::Hash{::String => ::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash}) (defaults to: nil)

      Optional. Glossaries to be applied for translation. It's keyed by target language code.

    • labels (::Hash{::String => ::String}) (defaults to: nil)

      Optional. The labels with user-defined metadata for the request.

      Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.

      See https://cloud.google.com/translate/docs/advanced/labels for more information.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 953

def batch_translate_text request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::BatchTranslateTextRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.batch_translate_text..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.batch_translate_text.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.batch_translate_text.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.batch_translate_text request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#configure {|config| ... } ⇒ Client::Configuration

Configure the TranslationService Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



130
131
132
133
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 130

def configure
  yield @config if block_given?
  @config
end

#create_adaptive_mt_dataset(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtDataset #create_adaptive_mt_dataset(parent: nil, adaptive_mt_dataset: nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtDataset

Creates an Adaptive MT dataset.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::CreateAdaptiveMtDatasetRequest.new

# Call the create_adaptive_mt_dataset method.
result = client.create_adaptive_mt_dataset request

# The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtDataset.
p result

Overloads:

  • #create_adaptive_mt_dataset(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtDataset

    Pass arguments to create_adaptive_mt_dataset via a request object, either of type CreateAdaptiveMtDatasetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::CreateAdaptiveMtDatasetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_adaptive_mt_dataset(parent: nil, adaptive_mt_dataset: nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtDataset

    Pass arguments to create_adaptive_mt_dataset via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Name of the parent project. In form of projects/{project-number-or-id}/locations/{location-id}

    • adaptive_mt_dataset (::Google::Cloud::Translate::V3::AdaptiveMtDataset, ::Hash) (defaults to: nil)

      Required. The AdaptiveMtDataset to be created.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2412

def create_adaptive_mt_dataset request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::CreateAdaptiveMtDatasetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_adaptive_mt_dataset..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.create_adaptive_mt_dataset.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_adaptive_mt_dataset.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.create_adaptive_mt_dataset 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

#create_dataset(request, options = nil) ⇒ ::Gapic::Operation #create_dataset(parent: nil, dataset: nil) ⇒ ::Gapic::Operation

Creates a Dataset.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::CreateDatasetRequest.new

# Call the create_dataset method.
result = client.create_dataset request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #create_dataset(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to create_dataset via a request object, either of type CreateDatasetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::CreateDatasetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_dataset(parent: nil, dataset: nil) ⇒ ::Gapic::Operation

    Pass arguments to create_dataset via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2071

def create_dataset request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::CreateDatasetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_dataset..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.create_dataset.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_dataset.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.create_dataset request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_glossary(request, options = nil) ⇒ ::Gapic::Operation #create_glossary(parent: nil, glossary: nil) ⇒ ::Gapic::Operation

Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::CreateGlossaryRequest.new

# Call the create_glossary method.
result = client.create_glossary request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #create_glossary(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to create_glossary via a request object, either of type CreateGlossaryRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::CreateGlossaryRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_glossary(parent: nil, glossary: nil) ⇒ ::Gapic::Operation

    Pass arguments to create_glossary via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1201

def create_glossary request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::CreateGlossaryRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_glossary..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.create_glossary.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_glossary.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.create_glossary request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_glossary_entry(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::GlossaryEntry #create_glossary_entry(parent: nil, glossary_entry: nil) ⇒ ::Google::Cloud::Translate::V3::GlossaryEntry

Creates a glossary entry.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::CreateGlossaryEntryRequest.new

# Call the create_glossary_entry method.
result = client.create_glossary_entry request

# The returned object is of type Google::Cloud::Translate::V3::GlossaryEntry.
p result

Overloads:

  • #create_glossary_entry(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::GlossaryEntry

    Pass arguments to create_glossary_entry via a request object, either of type CreateGlossaryEntryRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::CreateGlossaryEntryRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_glossary_entry(parent: nil, glossary_entry: nil) ⇒ ::Google::Cloud::Translate::V3::GlossaryEntry

    Pass arguments to create_glossary_entry via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The resource name of the glossary to create the entry under.

    • glossary_entry (::Google::Cloud::Translate::V3::GlossaryEntry, ::Hash) (defaults to: nil)

      Required. The glossary entry to create

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1825

def create_glossary_entry request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::CreateGlossaryEntryRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_glossary_entry..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.create_glossary_entry.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_glossary_entry.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.create_glossary_entry 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

#create_model(request, options = nil) ⇒ ::Gapic::Operation #create_model(parent: nil, model: nil) ⇒ ::Gapic::Operation

Creates a Model.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::CreateModelRequest.new

# Call the create_model method.
result = client.create_model request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #create_model(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to create_model via a request object, either of type CreateModelRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::CreateModelRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_model(parent: nil, model: nil) ⇒ ::Gapic::Operation

    Pass arguments to create_model via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The project name, in form of projects/{project}/locations/{location}

    • model (::Google::Cloud::Translate::V3::Model, ::Hash) (defaults to: nil)

      Required. The Model to create.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 3561

def create_model request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::CreateModelRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_model..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.create_model.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_model.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.create_model request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_adaptive_mt_dataset(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_adaptive_mt_dataset(name: nil) ⇒ ::Google::Protobuf::Empty

Deletes an Adaptive MT dataset, including all its entries and associated metadata.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DeleteAdaptiveMtDatasetRequest.new

# Call the delete_adaptive_mt_dataset method.
result = client.delete_adaptive_mt_dataset request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #delete_adaptive_mt_dataset(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_adaptive_mt_dataset via a request object, either of type DeleteAdaptiveMtDatasetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::DeleteAdaptiveMtDatasetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_adaptive_mt_dataset(name: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_adaptive_mt_dataset via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the dataset. In the form of projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2493

def delete_adaptive_mt_dataset request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DeleteAdaptiveMtDatasetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_adaptive_mt_dataset..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.delete_adaptive_mt_dataset.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_adaptive_mt_dataset.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.delete_adaptive_mt_dataset request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_adaptive_mt_file(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_adaptive_mt_file(name: nil) ⇒ ::Google::Protobuf::Empty

Deletes an AdaptiveMtFile along with its sentences.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DeleteAdaptiveMtFileRequest.new

# Call the delete_adaptive_mt_file method.
result = client.delete_adaptive_mt_file request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #delete_adaptive_mt_file(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_adaptive_mt_file via a request object, either of type DeleteAdaptiveMtFileRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::DeleteAdaptiveMtFileRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_adaptive_mt_file(name: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_adaptive_mt_file via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the file to delete, in form of projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2922

def delete_adaptive_mt_file request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DeleteAdaptiveMtFileRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_adaptive_mt_file..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.delete_adaptive_mt_file.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_adaptive_mt_file.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.delete_adaptive_mt_file request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_dataset(request, options = nil) ⇒ ::Gapic::Operation #delete_dataset(name: nil) ⇒ ::Gapic::Operation

Deletes a dataset and all of its contents.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DeleteDatasetRequest.new

# Call the delete_dataset method.
result = client.delete_dataset request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #delete_dataset(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_dataset via a request object, either of type DeleteDatasetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::DeleteDatasetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_dataset(name: nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_dataset via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the dataset to delete.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2329

def delete_dataset request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DeleteDatasetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_dataset..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.delete_dataset.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_dataset.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.delete_dataset request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_glossary(request, options = nil) ⇒ ::Gapic::Operation #delete_glossary(name: nil) ⇒ ::Gapic::Operation

Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DeleteGlossaryRequest.new

# Call the delete_glossary method.
result = client.delete_glossary request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #delete_glossary(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_glossary via a request object, either of type DeleteGlossaryRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::DeleteGlossaryRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_glossary(name: nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_glossary via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the glossary to delete.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1571

def delete_glossary request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DeleteGlossaryRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_glossary..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.delete_glossary.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_glossary.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.delete_glossary request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_glossary_entry(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_glossary_entry(name: nil) ⇒ ::Google::Protobuf::Empty

Deletes a single entry from the glossary

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DeleteGlossaryEntryRequest.new

# Call the delete_glossary_entry method.
result = client.delete_glossary_entry request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #delete_glossary_entry(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_glossary_entry via a request object, either of type DeleteGlossaryEntryRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::DeleteGlossaryEntryRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_glossary_entry(name: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_glossary_entry via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the glossary entry to delete

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1983

def delete_glossary_entry request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DeleteGlossaryEntryRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_glossary_entry..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.delete_glossary_entry.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_glossary_entry.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.delete_glossary_entry request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_model(request, options = nil) ⇒ ::Gapic::Operation #delete_model(name: nil) ⇒ ::Gapic::Operation

Deletes a model.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DeleteModelRequest.new

# Call the delete_model method.
result = client.delete_model request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #delete_model(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_model via a request object, either of type DeleteModelRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::DeleteModelRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_model(name: nil) ⇒ ::Gapic::Operation

    Pass arguments to delete_model via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the model to delete.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 3823

def delete_model request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DeleteModelRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_model..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.delete_model.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_model.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.delete_model request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#detect_language(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::DetectLanguageResponse #detect_language(parent: nil, model: nil, content: nil, mime_type: nil, labels: nil) ⇒ ::Google::Cloud::Translate::V3::DetectLanguageResponse

Detects the language of text within a request.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DetectLanguageRequest.new

# Call the detect_language method.
result = client.detect_language request

# The returned object is of type Google::Cloud::Translate::V3::DetectLanguageResponse.
p result

Overloads:

  • #detect_language(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::DetectLanguageResponse

    Pass arguments to detect_language via a request object, either of type DetectLanguageRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::DetectLanguageRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #detect_language(parent: nil, model: nil, content: nil, mime_type: nil, labels: nil) ⇒ ::Google::Cloud::Translate::V3::DetectLanguageResponse

    Pass arguments to detect_language via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Project or location to make a call. Must refer to a caller's project.

      Format: projects/{project-number-or-id}/locations/{location-id} or projects/{project-number-or-id}.

      For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

      Only models within the same region (has same location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is returned.

    • model (::String) (defaults to: nil)

      Optional. The language detection model to be used.

      Format: projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}

      Only one language detection model is currently supported: projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default.

      If not specified, the default model is used.

    • content (::String) (defaults to: nil)

      The content of the input stored as a string.

    • mime_type (::String) (defaults to: nil)

      Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html".

    • labels (::Hash{::String => ::String}) (defaults to: nil)

      Optional. The labels with user-defined metadata for the request.

      Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.

      See https://cloud.google.com/translate/docs/advanced/labels for more information.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 550

def detect_language request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DetectLanguageRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.detect_language..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.detect_language.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.detect_language.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.detect_language 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

#export_data(request, options = nil) ⇒ ::Gapic::Operation #export_data(dataset: nil, output_config: nil) ⇒ ::Gapic::Operation

Exports dataset's data to the provided output location.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ExportDataRequest.new

# Call the export_data method.
result = client.export_data request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #export_data(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to export_data via a request object, either of type ExportDataRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::ExportDataRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #export_data(dataset: nil, output_config: nil) ⇒ ::Gapic::Operation

    Pass arguments to export_data via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • dataset (::String) (defaults to: nil)

      Required. Name of the dataset. In form of projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}

    • output_config (::Google::Cloud::Translate::V3::DatasetOutputConfig, ::Hash) (defaults to: nil)

      Required. The config for the output content.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 3375

def export_data request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ExportDataRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.export_data..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.export_data.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.export_data.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.export_data request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_adaptive_mt_dataset(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtDataset #get_adaptive_mt_dataset(name: nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtDataset

Gets the Adaptive MT dataset.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetAdaptiveMtDatasetRequest.new

# Call the get_adaptive_mt_dataset method.
result = client.get_adaptive_mt_dataset request

# The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtDataset.
p result

Overloads:

  • #get_adaptive_mt_dataset(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtDataset

    Pass arguments to get_adaptive_mt_dataset via a request object, either of type GetAdaptiveMtDatasetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::GetAdaptiveMtDatasetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_adaptive_mt_dataset(name: nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtDataset

    Pass arguments to get_adaptive_mt_dataset via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the dataset. In the form of projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2573

def get_adaptive_mt_dataset request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetAdaptiveMtDatasetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_adaptive_mt_dataset..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.get_adaptive_mt_dataset.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_adaptive_mt_dataset.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.get_adaptive_mt_dataset request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_adaptive_mt_file(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtFile #get_adaptive_mt_file(name: nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtFile

Gets and AdaptiveMtFile

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetAdaptiveMtFileRequest.new

# Call the get_adaptive_mt_file method.
result = client.get_adaptive_mt_file request

# The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtFile.
p result

Overloads:

  • #get_adaptive_mt_file(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtFile

    Pass arguments to get_adaptive_mt_file via a request object, either of type GetAdaptiveMtFileRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::GetAdaptiveMtFileRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_adaptive_mt_file(name: nil) ⇒ ::Google::Cloud::Translate::V3::AdaptiveMtFile

    Pass arguments to get_adaptive_mt_file via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the file, in form of projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2842

def get_adaptive_mt_file request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetAdaptiveMtFileRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_adaptive_mt_file..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.get_adaptive_mt_file.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_adaptive_mt_file.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.get_adaptive_mt_file request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_dataset(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::Dataset #get_dataset(name: nil) ⇒ ::Google::Cloud::Translate::V3::Dataset

Gets a Dataset.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetDatasetRequest.new

# Call the get_dataset method.
result = client.get_dataset request

# The returned object is of type Google::Cloud::Translate::V3::Dataset.
p result

Overloads:

  • #get_dataset(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::Dataset

    Pass arguments to get_dataset via a request object, either of type GetDatasetRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::GetDatasetRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_dataset(name: nil) ⇒ ::Google::Cloud::Translate::V3::Dataset

    Pass arguments to get_dataset via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the dataset to retrieve.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2151

def get_dataset request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetDatasetRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_dataset..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.get_dataset.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_dataset.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.get_dataset request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_glossary(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::Glossary #get_glossary(name: nil) ⇒ ::Google::Cloud::Translate::V3::Glossary

Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetGlossaryRequest.new

# Call the get_glossary method.
result = client.get_glossary request

# The returned object is of type Google::Cloud::Translate::V3::Glossary.
p result

Overloads:

  • #get_glossary(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::Glossary

    Pass arguments to get_glossary via a request object, either of type GetGlossaryRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::GetGlossaryRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_glossary(name: nil) ⇒ ::Google::Cloud::Translate::V3::Glossary

    Pass arguments to get_glossary via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the glossary to retrieve.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1483

def get_glossary request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetGlossaryRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_glossary..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.get_glossary.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_glossary.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.get_glossary request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_glossary_entry(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::GlossaryEntry #get_glossary_entry(name: nil) ⇒ ::Google::Cloud::Translate::V3::GlossaryEntry

Gets a single glossary entry by the given id.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetGlossaryEntryRequest.new

# Call the get_glossary_entry method.
result = client.get_glossary_entry request

# The returned object is of type Google::Cloud::Translate::V3::GlossaryEntry.
p result

Overloads:

  • #get_glossary_entry(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::GlossaryEntry

    Pass arguments to get_glossary_entry via a request object, either of type GetGlossaryEntryRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::GetGlossaryEntryRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_glossary_entry(name: nil) ⇒ ::Google::Cloud::Translate::V3::GlossaryEntry

    Pass arguments to get_glossary_entry via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the glossary entry to get

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1651

def get_glossary_entry request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetGlossaryEntryRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_glossary_entry..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.get_glossary_entry.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_glossary_entry.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.get_glossary_entry request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_model(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::Model #get_model(name: nil) ⇒ ::Google::Cloud::Translate::V3::Model

Gets a model.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetModelRequest.new

# Call the get_model method.
result = client.get_model request

# The returned object is of type Google::Cloud::Translate::V3::Model.
p result

Overloads:

  • #get_model(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::Model

    Pass arguments to get_model via a request object, either of type GetModelRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::GetModelRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_model(name: nil) ⇒ ::Google::Cloud::Translate::V3::Model

    Pass arguments to get_model via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the model to retrieve.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 3737

def get_model request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetModelRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_model..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.get_model.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_model.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.get_model request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_supported_languages(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::SupportedLanguages #get_supported_languages(parent: nil, display_language_code: nil, model: nil) ⇒ ::Google::Cloud::Translate::V3::SupportedLanguages

Returns a list of supported languages for translation.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetSupportedLanguagesRequest.new

# Call the get_supported_languages method.
result = client.get_supported_languages request

# The returned object is of type Google::Cloud::Translate::V3::SupportedLanguages.
p result

Overloads:

  • #get_supported_languages(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::SupportedLanguages

    Pass arguments to get_supported_languages via a request object, either of type GetSupportedLanguagesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::GetSupportedLanguagesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_supported_languages(parent: nil, display_language_code: nil, model: nil) ⇒ ::Google::Cloud::Translate::V3::SupportedLanguages

    Pass arguments to get_supported_languages via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Project or location to make a call. Must refer to a caller's project.

      Format: projects/{project-number-or-id} or projects/{project-number-or-id}/locations/{location-id}.

      For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

      Non-global location is required for AutoML models.

      Only models within the same region (have same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.

    • display_language_code (::String) (defaults to: nil)

      Optional. The language to use to return localized, human readable names of supported languages. If missing, then display names are not returned in a response.

    • model (::String) (defaults to: nil)

      Optional. Get supported languages of this model.

      The format depends on model type:

      • AutoML Translation models: projects/{project-number-or-id}/locations/{location-id}/models/{model-id}

      • General (built-in) models: projects/{project-number-or-id}/locations/{location-id}/models/general/nmt,

      Returns languages supported by the specified model. If missing, we get supported languages of Google general NMT model.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 659

def get_supported_languages request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetSupportedLanguagesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_supported_languages..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.get_supported_languages.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_supported_languages.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.get_supported_languages request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#import_adaptive_mt_file(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse #import_adaptive_mt_file(parent: nil, file_input_source: nil, gcs_input_source: nil) ⇒ ::Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse

Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ImportAdaptiveMtFileRequest.new

# Call the import_adaptive_mt_file method.
result = client.import_adaptive_mt_file request

# The returned object is of type Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse.
p result

Overloads:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 3007

def import_adaptive_mt_file request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ImportAdaptiveMtFileRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.import_adaptive_mt_file..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.import_adaptive_mt_file.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.import_adaptive_mt_file.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.import_adaptive_mt_file request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#import_data(request, options = nil) ⇒ ::Gapic::Operation #import_data(dataset: nil, input_config: nil) ⇒ ::Gapic::Operation

Import sentence pairs into translation Dataset.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ImportDataRequest.new

# Call the import_data method.
result = client.import_data request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #import_data(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to import_data via a request object, either of type ImportDataRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::ImportDataRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #import_data(dataset: nil, input_config: nil) ⇒ ::Gapic::Operation

    Pass arguments to import_data via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • dataset (::String) (defaults to: nil)

      Required. Name of the dataset. In form of projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}

    • input_config (::Google::Cloud::Translate::V3::DatasetInputConfig, ::Hash) (defaults to: nil)

      Required. The config for the input content.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 3285

def import_data request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ImportDataRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.import_data..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.import_data.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.import_data.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.import_data request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_adaptive_mt_datasets(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtDataset> #list_adaptive_mt_datasets(parent: nil, page_size: nil, page_token: nil, filter: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtDataset>

Lists all Adaptive MT datasets for which the caller has read permission.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListAdaptiveMtDatasetsRequest.new

# Call the list_adaptive_mt_datasets method.
result = client.list_adaptive_mt_datasets request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::AdaptiveMtDataset.
  p item
end

Overloads:

  • #list_adaptive_mt_datasets(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtDataset>

    Pass arguments to list_adaptive_mt_datasets via a request object, either of type ListAdaptiveMtDatasetsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::ListAdaptiveMtDatasetsRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_adaptive_mt_datasets(parent: nil, page_size: nil, page_token: nil, filter: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtDataset>

    Pass arguments to list_adaptive_mt_datasets via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The resource name of the project from which to list the Adaptive MT datasets. projects/{project-number-or-id}/locations/{location-id}

    • page_size (::Integer) (defaults to: nil)

      Optional. Requested page size. The server may return fewer results than requested. If unspecified, the server picks an appropriate default.

    • page_token (::String) (defaults to: nil)

      Optional. A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtDatasetsResponse.next_page_token returned from the previous call to ListAdaptiveMtDatasets method. The first page is returned if page_tokenis empty or missing.

    • filter (::String) (defaults to: nil)

      Optional. An expression for filtering the results of the request. Filter is not supported yet.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2669

def list_adaptive_mt_datasets request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListAdaptiveMtDatasetsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_adaptive_mt_datasets..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.list_adaptive_mt_datasets.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_adaptive_mt_datasets.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.list_adaptive_mt_datasets request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_adaptive_mt_datasets, "adaptive_mt_datasets", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_adaptive_mt_files(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtFile> #list_adaptive_mt_files(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtFile>

Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListAdaptiveMtFilesRequest.new

# Call the list_adaptive_mt_files method.
result = client.list_adaptive_mt_files request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::AdaptiveMtFile.
  p item
end

Overloads:

  • #list_adaptive_mt_files(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtFile>

    Pass arguments to list_adaptive_mt_files via a request object, either of type ListAdaptiveMtFilesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::ListAdaptiveMtFilesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_adaptive_mt_files(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtFile>

    Pass arguments to list_adaptive_mt_files via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The resource name of the project from which to list the Adaptive MT files. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}

    • page_size (::Integer) (defaults to: nil)

      Optional.

    • page_token (::String) (defaults to: nil)

      Optional. A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtFilesResponse.next_page_token returned from the previous call to ListAdaptiveMtFiles method. The first page is returned if page_tokenis empty or missing.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 3100

def list_adaptive_mt_files request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListAdaptiveMtFilesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_adaptive_mt_files..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.list_adaptive_mt_files.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_adaptive_mt_files.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.list_adaptive_mt_files request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_adaptive_mt_files, "adaptive_mt_files", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_adaptive_mt_sentences(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtSentence> #list_adaptive_mt_sentences(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtSentence>

Lists all AdaptiveMtSentences under a given file/dataset.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListAdaptiveMtSentencesRequest.new

# Call the list_adaptive_mt_sentences method.
result = client.list_adaptive_mt_sentences request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::AdaptiveMtSentence.
  p item
end

Overloads:

  • #list_adaptive_mt_sentences(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtSentence>

    Pass arguments to list_adaptive_mt_sentences via a request object, either of type ListAdaptiveMtSentencesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::ListAdaptiveMtSentencesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_adaptive_mt_sentences(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtSentence>

    Pass arguments to list_adaptive_mt_sentences via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The resource name of the project from which to list the Adaptive MT files. The following format lists all sentences under a file. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file} The following format lists all sentences within a dataset. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}

    • page_size (::Integer) (defaults to: nil)
    • page_token (::String) (defaults to: nil)

      A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtSentencesRequest.next_page_token returned from the previous call to ListTranslationMemories method. The first page is returned if page_token is empty or missing.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 3195

def list_adaptive_mt_sentences request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListAdaptiveMtSentencesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_adaptive_mt_sentences..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.list_adaptive_mt_sentences.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_adaptive_mt_sentences.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.list_adaptive_mt_sentences request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_adaptive_mt_sentences, "adaptive_mt_sentences", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_datasets(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Dataset> #list_datasets(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Dataset>

Lists datasets.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListDatasetsRequest.new

# Call the list_datasets method.
result = client.list_datasets request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::Dataset.
  p item
end

Overloads:

  • #list_datasets(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Dataset>

    Pass arguments to list_datasets via a request object, either of type ListDatasetsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::ListDatasetsRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_datasets(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Dataset>

    Pass arguments to list_datasets via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Name of the parent project. In form of projects/{project-number-or-id}/locations/{location-id}

    • page_size (::Integer) (defaults to: nil)

      Optional. Requested page size. The server can return fewer results than requested.

    • page_token (::String) (defaults to: nil)

      Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListDatasets call.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 2242

def list_datasets request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListDatasetsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_datasets..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.list_datasets.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_datasets.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.list_datasets request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_datasets, "datasets", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_examples(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Example> #list_examples(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Example>

Lists sentence pairs in the dataset.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListExamplesRequest.new

# Call the list_examples method.
result = client.list_examples request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::Example.
  p item
end

Overloads:

  • #list_examples(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Example>

    Pass arguments to list_examples via a request object, either of type ListExamplesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::ListExamplesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_examples(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Example>

    Pass arguments to list_examples via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Name of the parent dataset. In form of projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}

    • filter (::String) (defaults to: nil)

      Optional. An expression for filtering the examples that will be returned. Example filter:

      • usage=TRAIN
    • page_size (::Integer) (defaults to: nil)

      Optional. Requested page size. The server can return fewer results than requested.

    • page_token (::String) (defaults to: nil)

      Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListExamples call.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 3471

def list_examples request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListExamplesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_examples..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.list_examples.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_examples.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.list_examples request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_examples, "examples", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_glossaries(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary> #list_glossaries(parent: nil, page_size: nil, page_token: nil, filter: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>

Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListGlossariesRequest.new

# Call the list_glossaries method.
result = client.list_glossaries request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::Glossary.
  p item
end

Overloads:

  • #list_glossaries(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>

    Pass arguments to list_glossaries via a request object, either of type ListGlossariesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::ListGlossariesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_glossaries(parent: nil, page_size: nil, page_token: nil, filter: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>

    Pass arguments to list_glossaries via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The name of the project from which to list all of the glossaries.

    • page_size (::Integer) (defaults to: nil)

      Optional. Requested page size. The server may return fewer glossaries than requested. If unspecified, the server picks an appropriate default.

    • page_token (::String) (defaults to: nil)

      Optional. A token identifying a page of results the server should return. Typically, this is the value of [ListGlossariesResponse.next_page_token] returned from the previous call to ListGlossaries method. The first page is returned if page_tokenis empty or missing.

    • filter (::String) (defaults to: nil)

      Optional. Filter specifying constraints of a list operation. Specify the constraint by the format of "key=value", where key must be "src" or "tgt", and the value must be a valid language code. For multiple restrictions, concatenate them by "AND" (uppercase only), such as: "src=en-US AND tgt=zh-CN". Notice that the exact match is used here, which means using 'en-US' and 'en' can lead to different results, which depends on the language code you used when you create the glossary. For the unidirectional glossaries, the "src" and "tgt" add restrictions on the source and target language code separately. For the equivalent term set glossaries, the "src" and/or "tgt" add restrictions on the term set. For example: "src=en-US AND tgt=zh-CN" will only pick the unidirectional glossaries which exactly match the source language code as "en-US" and the target language code "zh-CN", but all equivalent term set glossaries which contain "en-US" and "zh-CN" in their language set will be picked. If missing, no filtering is performed.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1402

def list_glossaries request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListGlossariesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_glossaries..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.list_glossaries.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_glossaries.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.list_glossaries request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_glossaries, "glossaries", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_glossary_entries(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::GlossaryEntry> #list_glossary_entries(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::GlossaryEntry>

List the entries for the glossary.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListGlossaryEntriesRequest.new

# Call the list_glossary_entries method.
result = client.list_glossary_entries request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::GlossaryEntry.
  p item
end

Overloads:

  • #list_glossary_entries(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::GlossaryEntry>

    Pass arguments to list_glossary_entries via a request object, either of type ListGlossaryEntriesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::ListGlossaryEntriesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_glossary_entries(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::GlossaryEntry>

    Pass arguments to list_glossary_entries via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The parent glossary resource name for listing the glossary's entries.

    • page_size (::Integer) (defaults to: nil)

      Optional. Requested page size. The server may return fewer glossary entries than requested. If unspecified, the server picks an appropriate default.

    • page_token (::String) (defaults to: nil)

      Optional. A token identifying a page of results the server should return. Typically, this is the value of [ListGlossaryEntriesResponse.next_page_token] returned from the previous call. The first page is returned if page_tokenis empty or missing.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1743

def list_glossary_entries request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListGlossaryEntriesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_glossary_entries..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.list_glossary_entries.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_glossary_entries.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.list_glossary_entries request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_glossary_entries, "glossary_entries", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_models(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Model> #list_models(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Model>

Lists models.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListModelsRequest.new

# Call the list_models method.
result = client.list_models request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::Model.
  p item
end

Overloads:

  • #list_models(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Model>

    Pass arguments to list_models via a request object, either of type ListModelsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::ListModelsRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_models(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Model>

    Pass arguments to list_models via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Name of the parent project. In form of projects/{project-number-or-id}/locations/{location-id}

    • filter (::String) (defaults to: nil)

      Optional. An expression for filtering the models that will be returned. Supported filter: dataset_id=${dataset_id}

    • page_size (::Integer) (defaults to: nil)

      Optional. Requested page size. The server can return fewer results than requested.

    • page_token (::String) (defaults to: nil)

      Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListModels call.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 3657

def list_models request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListModelsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_models..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.list_models.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_models.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.list_models request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_models, "models", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#romanize_text(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::RomanizeTextResponse #romanize_text(parent: nil, contents: nil, source_language_code: nil) ⇒ ::Google::Cloud::Translate::V3::RomanizeTextResponse

Romanize input text written in non-Latin scripts to Latin text.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::RomanizeTextRequest.new

# Call the romanize_text method.
result = client.romanize_text request

# The returned object is of type Google::Cloud::Translate::V3::RomanizeTextResponse.
p result

Overloads:

  • #romanize_text(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::RomanizeTextResponse

    Pass arguments to romanize_text via a request object, either of type RomanizeTextRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::RomanizeTextRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #romanize_text(parent: nil, contents: nil, source_language_code: nil) ⇒ ::Google::Cloud::Translate::V3::RomanizeTextResponse

    Pass arguments to romanize_text via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Project or location to make a call. Must refer to a caller's project.

      Format: projects/{project-number-or-id}/locations/{location-id} or projects/{project-number-or-id}.

      For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

    • contents (::Array<::String>) (defaults to: nil)

      Required. The content of the input in string format.

    • source_language_code (::String) (defaults to: nil)

      Optional. The ISO-639 language code of the input text if known, for example, "hi" or "zh". If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language for each content in the response.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 436

def romanize_text request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::RomanizeTextRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.romanize_text..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.romanize_text.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.romanize_text.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.romanize_text 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

#translate_document(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::TranslateDocumentResponse #translate_document(parent: nil, source_language_code: nil, target_language_code: nil, document_input_config: nil, document_output_config: nil, model: nil, glossary_config: nil, labels: nil, customized_attribution: nil, is_translate_native_pdf_only: nil, enable_shadow_removal_native_pdf: nil, enable_rotation_correction: nil) ⇒ ::Google::Cloud::Translate::V3::TranslateDocumentResponse

Translates documents in synchronous mode.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::TranslateDocumentRequest.new

# Call the translate_document method.
result = client.translate_document request

# The returned object is of type Google::Cloud::Translate::V3::TranslateDocumentResponse.
p result

Overloads:

  • #translate_document(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::TranslateDocumentResponse

    Pass arguments to translate_document via a request object, either of type Google::Cloud::Translate::V3::TranslateDocumentRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::TranslateDocumentRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #translate_document(parent: nil, source_language_code: nil, target_language_code: nil, document_input_config: nil, document_output_config: nil, model: nil, glossary_config: nil, labels: nil, customized_attribution: nil, is_translate_native_pdf_only: nil, enable_shadow_removal_native_pdf: nil, enable_rotation_correction: nil) ⇒ ::Google::Cloud::Translate::V3::TranslateDocumentResponse

    Pass arguments to translate_document via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. Location to make a regional call.

      Format: projects/{project-number-or-id}/locations/{location-id}.

      For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

      Non-global location is required for requests using AutoML models or custom glossaries.

      Models and glossaries must be within the same region (have the same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.

    • source_language_code (::String) (defaults to: nil)

      Optional. The ISO-639 language code of the input document if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language within the response. Source language must be specified if the request contains a glossary or a custom model.

    • target_language_code (::String) (defaults to: nil)

      Required. The ISO-639 language code to use for translation of the input document, set to one of the language codes listed in Language Support.

    • document_input_config (::Google::Cloud::Translate::V3::DocumentInputConfig, ::Hash) (defaults to: nil)

      Required. Input configurations.

    • document_output_config (::Google::Cloud::Translate::V3::DocumentOutputConfig, ::Hash) (defaults to: nil)

      Optional. Output configurations. Defines if the output file should be stored within Cloud Storage as well as the desired output format. If not provided the translated file will only be returned through a byte-stream and its output mime type will be the same as the input file's mime type.

    • model (::String) (defaults to: nil)

      Optional. The model type requested for this translation.

      The format depends on model type:

      • AutoML Translation models: projects/{project-number-or-id}/locations/{location-id}/models/{model-id}

      • General (built-in) models: projects/{project-number-or-id}/locations/{location-id}/models/general/nmt,

      If not provided, the default Google model (NMT) will be used for translation.

    • glossary_config (::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash) (defaults to: nil)

      Optional. Glossary to be applied. The glossary must be within the same region (have the same location-id) as the model, otherwise an INVALID_ARGUMENT (400) error is returned.

    • labels (::Hash{::String => ::String}) (defaults to: nil)

      Optional. The labels with user-defined metadata for the request.

      Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.

      See https://cloud.google.com/translate/docs/advanced/labels for more information.

    • customized_attribution (::String) (defaults to: nil)

      Optional. This flag is to support user customized attribution. If not provided, the default is Machine Translated by Google. Customized attribution should follow rules in https://cloud.google.com/translate/attribution#attribution_and_logos

    • is_translate_native_pdf_only (::Boolean) (defaults to: nil)

      Optional. is_translate_native_pdf_only field for external customers. If true, the page limit of online native pdf translation is 300 and only native pdf pages will be translated.

    • enable_shadow_removal_native_pdf (::Boolean) (defaults to: nil)

      Optional. If true, use the text removal server to remove the shadow text on background image for native pdf translation. Shadow removal feature can only be enabled when is_translate_native_pdf_only: false && pdf_native_only: false

    • enable_rotation_correction (::Boolean) (defaults to: nil)

      Optional. If true, enable auto rotation correction in DVS.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 811

def translate_document request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::TranslateDocumentRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.translate_document..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.translate_document.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.translate_document.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.translate_document 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

#translate_text(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::TranslateTextResponse #translate_text(contents: nil, mime_type: nil, source_language_code: nil, target_language_code: nil, parent: nil, model: nil, glossary_config: nil, transliteration_config: nil, labels: nil) ⇒ ::Google::Cloud::Translate::V3::TranslateTextResponse

Translates input text and returns translated text.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::TranslateTextRequest.new

# Call the translate_text method.
result = client.translate_text request

# The returned object is of type Google::Cloud::Translate::V3::TranslateTextResponse.
p result

Overloads:

  • #translate_text(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::TranslateTextResponse

    Pass arguments to translate_text via a request object, either of type Google::Cloud::Translate::V3::TranslateTextRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::TranslateTextRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #translate_text(contents: nil, mime_type: nil, source_language_code: nil, target_language_code: nil, parent: nil, model: nil, glossary_config: nil, transliteration_config: nil, labels: nil) ⇒ ::Google::Cloud::Translate::V3::TranslateTextResponse

    Pass arguments to translate_text via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • contents (::Array<::String>) (defaults to: nil)

      Required. The content of the input in string format. We recommend the total content be less than 30,000 codepoints. The max length of this field is 1024. Use BatchTranslateText for larger text.

    • mime_type (::String) (defaults to: nil)

      Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html".

    • source_language_code (::String) (defaults to: nil)

      Optional. The ISO-639 language code of the input text if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language within the response.

    • target_language_code (::String) (defaults to: nil)

      Required. The ISO-639 language code to use for translation of the input text, set to one of the language codes listed in Language Support.

    • parent (::String) (defaults to: nil)

      Required. Project or location to make a call. Must refer to a caller's project.

      Format: projects/{project-number-or-id} or projects/{project-number-or-id}/locations/{location-id}.

      For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

      Non-global location is required for requests using AutoML models or custom glossaries.

      Models and glossaries must be within the same region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.

    • model (::String) (defaults to: nil)

      Optional. The model type requested for this translation.

      The format depends on model type:

      • AutoML Translation models: projects/{project-number-or-id}/locations/{location-id}/models/{model-id}

      • General (built-in) models: projects/{project-number-or-id}/locations/{location-id}/models/general/nmt,

      • Translation LLM models: projects/{project-number-or-id}/locations/{location-id}/models/general/translation-llm,

      For global (non-regionalized) requests, use location-id global. For example, projects/{project-number-or-id}/locations/global/models/general/nmt.

      If not provided, the default Google model (NMT) will be used

    • glossary_config (::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash) (defaults to: nil)

      Optional. Glossary to be applied. The glossary must be within the same region (have the same location-id) as the model, otherwise an INVALID_ARGUMENT (400) error is returned.

    • transliteration_config (::Google::Cloud::Translate::V3::TransliterationConfig, ::Hash) (defaults to: nil)

      Optional. Transliteration to be applied.

    • labels (::Hash{::String => ::String}) (defaults to: nil)

      Optional. The labels with user-defined metadata for the request.

      Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.

      See https://cloud.google.com/translate/docs/advanced/labels for more information.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 343

def translate_text request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::TranslateTextRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.translate_text..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.translate_text.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.translate_text.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.translate_text 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

#universe_domainString

The effective universe domain

Returns:

  • (String)


140
141
142
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 140

def universe_domain
  @translation_service_stub.universe_domain
end

#update_glossary(request, options = nil) ⇒ ::Gapic::Operation #update_glossary(glossary: nil, update_mask: nil) ⇒ ::Gapic::Operation

Updates a glossary. A LRO is used since the update can be async if the glossary's entry file is updated.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::UpdateGlossaryRequest.new

# Call the update_glossary method.
result = client.update_glossary request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

Overloads:

  • #update_glossary(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to update_glossary via a request object, either of type UpdateGlossaryRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Translate::V3::UpdateGlossaryRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_glossary(glossary: nil, update_mask: nil) ⇒ ::Gapic::Operation

    Pass arguments to update_glossary via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

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

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1292

def update_glossary request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::UpdateGlossaryRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_glossary..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.update_glossary.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_glossary.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.update_glossary request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_glossary_entry(request, options = nil) ⇒ ::Google::Cloud::Translate::V3::GlossaryEntry #update_glossary_entry(glossary_entry: nil) ⇒ ::Google::Cloud::Translate::V3::GlossaryEntry

Updates a glossary entry.

Examples:

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::UpdateGlossaryEntryRequest.new

# Call the update_glossary_entry method.
result = client.update_glossary_entry request

# The returned object is of type Google::Cloud::Translate::V3::GlossaryEntry.
p result

Overloads:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
# File 'lib/google/cloud/translate/v3/translation_service/rest/client.rb', line 1904

def update_glossary_entry request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::UpdateGlossaryEntryRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_glossary_entry..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Translate::V3::VERSION,
    transports_version_send: [:rest]

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

  options.apply_defaults timeout:      @config.rpcs.update_glossary_entry.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_glossary_entry.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @translation_service_stub.update_glossary_entry 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