google-cloud-translate-v3 0.9.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,6 +32,9 @@ module Google
32
32
  # Provides natural language translation operations.
33
33
  #
34
34
  class Client
35
+ # @private
36
+ DEFAULT_ENDPOINT_TEMPLATE = "translate.$UNIVERSE_DOMAIN$"
37
+
35
38
  include Paths
36
39
 
37
40
  # @private
@@ -124,6 +127,15 @@ module Google
124
127
  @config
125
128
  end
126
129
 
130
+ ##
131
+ # The effective universe domain
132
+ #
133
+ # @return [String]
134
+ #
135
+ def universe_domain
136
+ @translation_service_stub.universe_domain
137
+ end
138
+
127
139
  ##
128
140
  # Create a new TranslationService REST client object.
129
141
  #
@@ -151,8 +163,9 @@ module Google
151
163
  credentials = @config.credentials
152
164
  # Use self-signed JWT if the endpoint is unchanged from default,
153
165
  # but only if the default endpoint does not have a region prefix.
154
- enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
155
- !@config.endpoint.split(".").first.include?("-")
166
+ enable_self_signed_jwt = @config.endpoint.nil? ||
167
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
168
+ !@config.endpoint.split(".").first.include?("-"))
156
169
  credentials ||= Credentials.default scope: @config.scope,
157
170
  enable_self_signed_jwt: enable_self_signed_jwt
158
171
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
@@ -166,9 +179,15 @@ module Google
166
179
  config.credentials = credentials
167
180
  config.quota_project = @quota_project_id
168
181
  config.endpoint = @config.endpoint
182
+ config.universe_domain = @config.universe_domain
169
183
  end
170
184
 
171
- @translation_service_stub = ::Google::Cloud::Translate::V3::TranslationService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
185
+ @translation_service_stub = ::Google::Cloud::Translate::V3::TranslationService::Rest::ServiceStub.new(
186
+ endpoint: @config.endpoint,
187
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
188
+ universe_domain: @config.universe_domain,
189
+ credentials: credentials
190
+ )
172
191
  end
173
192
 
174
193
  ##
@@ -901,9 +920,9 @@ module Google
901
920
  # @param glossaries [::Hash{::String => ::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash}]
902
921
  # Optional. Glossaries to be applied. It's keyed by target language code.
903
922
  # @param format_conversions [::Hash{::String => ::String}]
904
- # Optional. File format conversion map to be applied to all input files.
905
- # Map's key is the original mime_type. Map's value is the target mime_type of
906
- # translated documents.
923
+ # Optional. The file format conversion map that is applied to all input
924
+ # files. The map key is the original mime_type. The map value is the target
925
+ # mime_type of translated documents.
907
926
  #
908
927
  # Supported file format conversion includes:
909
928
  # - `application/pdf` to
@@ -1355,117 +1374,976 @@ module Google
1355
1374
  end
1356
1375
 
1357
1376
  ##
1358
- # Configuration class for the TranslationService REST API.
1377
+ # Creates an Adaptive MT dataset.
1359
1378
  #
1360
- # This class represents the configuration for TranslationService REST,
1361
- # providing control over timeouts, retry behavior, logging, transport
1362
- # parameters, and other low-level controls. Certain parameters can also be
1363
- # applied individually to specific RPCs. See
1364
- # {::Google::Cloud::Translate::V3::TranslationService::Rest::Client::Configuration::Rpcs}
1365
- # for a list of RPCs that can be configured independently.
1379
+ # @overload create_adaptive_mt_dataset(request, options = nil)
1380
+ # Pass arguments to `create_adaptive_mt_dataset` via a request object, either of type
1381
+ # {::Google::Cloud::Translate::V3::CreateAdaptiveMtDatasetRequest} or an equivalent Hash.
1366
1382
  #
1367
- # Configuration can be applied globally to all clients, or to a single client
1368
- # on construction.
1383
+ # @param request [::Google::Cloud::Translate::V3::CreateAdaptiveMtDatasetRequest, ::Hash]
1384
+ # A request object representing the call parameters. Required. To specify no
1385
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1386
+ # @param options [::Gapic::CallOptions, ::Hash]
1387
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1369
1388
  #
1370
- # @example
1389
+ # @overload create_adaptive_mt_dataset(parent: nil, adaptive_mt_dataset: nil)
1390
+ # Pass arguments to `create_adaptive_mt_dataset` via keyword arguments. Note that at
1391
+ # least one keyword argument is required. To specify no parameters, or to keep all
1392
+ # the default parameter values, pass an empty Hash as a request object (see above).
1371
1393
  #
1372
- # # Modify the global config, setting the timeout for
1373
- # # translate_text to 20 seconds,
1374
- # # and all remaining timeouts to 10 seconds.
1375
- # ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.configure do |config|
1376
- # config.timeout = 10.0
1377
- # config.rpcs.translate_text.timeout = 20.0
1378
- # end
1394
+ # @param parent [::String]
1395
+ # Required. Name of the parent project. In form of
1396
+ # `projects/{project-number-or-id}/locations/{location-id}`
1397
+ # @param adaptive_mt_dataset [::Google::Cloud::Translate::V3::AdaptiveMtDataset, ::Hash]
1398
+ # Required. The AdaptiveMtDataset to be created.
1399
+ # @yield [result, operation] Access the result along with the TransportOperation object
1400
+ # @yieldparam result [::Google::Cloud::Translate::V3::AdaptiveMtDataset]
1401
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1379
1402
  #
1380
- # # Apply the above configuration only to a new client.
1381
- # client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.new do |config|
1382
- # config.timeout = 10.0
1383
- # config.rpcs.translate_text.timeout = 20.0
1384
- # end
1403
+ # @return [::Google::Cloud::Translate::V3::AdaptiveMtDataset]
1385
1404
  #
1386
- # @!attribute [rw] endpoint
1387
- # The hostname or hostname:port of the service endpoint.
1388
- # Defaults to `"translate.googleapis.com"`.
1389
- # @return [::String]
1390
- # @!attribute [rw] credentials
1391
- # Credentials to send with calls. You may provide any of the following types:
1392
- # * (`String`) The path to a service account key file in JSON format
1393
- # * (`Hash`) A service account key as a Hash
1394
- # * (`Google::Auth::Credentials`) A googleauth credentials object
1395
- # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
1396
- # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1397
- # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
1398
- # * (`nil`) indicating no credentials
1399
- # @return [::Object]
1400
- # @!attribute [rw] scope
1401
- # The OAuth scopes
1402
- # @return [::Array<::String>]
1403
- # @!attribute [rw] lib_name
1404
- # The library name as recorded in instrumentation and logging
1405
- # @return [::String]
1406
- # @!attribute [rw] lib_version
1407
- # The library version as recorded in instrumentation and logging
1408
- # @return [::String]
1409
- # @!attribute [rw] timeout
1410
- # The call timeout in seconds.
1411
- # @return [::Numeric]
1412
- # @!attribute [rw] metadata
1413
- # Additional headers to be sent with the call.
1414
- # @return [::Hash{::Symbol=>::String}]
1415
- # @!attribute [rw] retry_policy
1416
- # The retry policy. The value is a hash with the following keys:
1417
- # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1418
- # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1419
- # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1420
- # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1421
- # trigger a retry.
1422
- # @return [::Hash]
1423
- # @!attribute [rw] quota_project
1424
- # A separate project against which to charge quota.
1425
- # @return [::String]
1405
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1426
1406
  #
1427
- class Configuration
1428
- extend ::Gapic::Config
1407
+ # @example Basic example
1408
+ # require "google/cloud/translate/v3"
1409
+ #
1410
+ # # Create a client object. The client can be reused for multiple calls.
1411
+ # client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
1412
+ #
1413
+ # # Create a request. To set request fields, pass in keyword arguments.
1414
+ # request = Google::Cloud::Translate::V3::CreateAdaptiveMtDatasetRequest.new
1415
+ #
1416
+ # # Call the create_adaptive_mt_dataset method.
1417
+ # result = client.create_adaptive_mt_dataset request
1418
+ #
1419
+ # # The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtDataset.
1420
+ # p result
1421
+ #
1422
+ def create_adaptive_mt_dataset request, options = nil
1423
+ raise ::ArgumentError, "request must be provided" if request.nil?
1429
1424
 
1430
- DEFAULT_ENDPOINT = "translate.googleapis.com"
1425
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::CreateAdaptiveMtDatasetRequest
1431
1426
 
1432
- config_attr :endpoint, DEFAULT_ENDPOINT, ::String
1433
- config_attr :credentials, nil do |value|
1434
- allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1435
- allowed.any? { |klass| klass === value }
1427
+ # Converts hash and nil to an options object
1428
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1429
+
1430
+ # Customize the options with defaults
1431
+ call_metadata = @config.rpcs.create_adaptive_mt_dataset.metadata.to_h
1432
+
1433
+ # Set x-goog-api-client and x-goog-user-project headers
1434
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1435
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1436
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION,
1437
+ transports_version_send: [:rest]
1438
+
1439
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1440
+
1441
+ options.apply_defaults timeout: @config.rpcs.create_adaptive_mt_dataset.timeout,
1442
+ metadata: call_metadata,
1443
+ retry_policy: @config.rpcs.create_adaptive_mt_dataset.retry_policy
1444
+
1445
+ options.apply_defaults timeout: @config.timeout,
1446
+ metadata: @config.metadata,
1447
+ retry_policy: @config.retry_policy
1448
+
1449
+ @translation_service_stub.create_adaptive_mt_dataset request, options do |result, operation|
1450
+ yield result, operation if block_given?
1451
+ return result
1436
1452
  end
1437
- config_attr :scope, nil, ::String, ::Array, nil
1438
- config_attr :lib_name, nil, ::String, nil
1439
- config_attr :lib_version, nil, ::String, nil
1440
- config_attr :timeout, nil, ::Numeric, nil
1441
- config_attr :metadata, nil, ::Hash, nil
1442
- config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1443
- config_attr :quota_project, nil, ::String, nil
1453
+ rescue ::Gapic::Rest::Error => e
1454
+ raise ::Google::Cloud::Error.from_error(e)
1455
+ end
1444
1456
 
1445
- # @private
1446
- def initialize parent_config = nil
1447
- @parent_config = parent_config unless parent_config.nil?
1457
+ ##
1458
+ # Deletes an Adaptive MT dataset, including all its entries and associated
1459
+ # metadata.
1460
+ #
1461
+ # @overload delete_adaptive_mt_dataset(request, options = nil)
1462
+ # Pass arguments to `delete_adaptive_mt_dataset` via a request object, either of type
1463
+ # {::Google::Cloud::Translate::V3::DeleteAdaptiveMtDatasetRequest} or an equivalent Hash.
1464
+ #
1465
+ # @param request [::Google::Cloud::Translate::V3::DeleteAdaptiveMtDatasetRequest, ::Hash]
1466
+ # A request object representing the call parameters. Required. To specify no
1467
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1468
+ # @param options [::Gapic::CallOptions, ::Hash]
1469
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1470
+ #
1471
+ # @overload delete_adaptive_mt_dataset(name: nil)
1472
+ # Pass arguments to `delete_adaptive_mt_dataset` via keyword arguments. Note that at
1473
+ # least one keyword argument is required. To specify no parameters, or to keep all
1474
+ # the default parameter values, pass an empty Hash as a request object (see above).
1475
+ #
1476
+ # @param name [::String]
1477
+ # Required. Name of the dataset. In the form of
1478
+ # `projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}`
1479
+ # @yield [result, operation] Access the result along with the TransportOperation object
1480
+ # @yieldparam result [::Google::Protobuf::Empty]
1481
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1482
+ #
1483
+ # @return [::Google::Protobuf::Empty]
1484
+ #
1485
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1486
+ #
1487
+ # @example Basic example
1488
+ # require "google/cloud/translate/v3"
1489
+ #
1490
+ # # Create a client object. The client can be reused for multiple calls.
1491
+ # client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
1492
+ #
1493
+ # # Create a request. To set request fields, pass in keyword arguments.
1494
+ # request = Google::Cloud::Translate::V3::DeleteAdaptiveMtDatasetRequest.new
1495
+ #
1496
+ # # Call the delete_adaptive_mt_dataset method.
1497
+ # result = client.delete_adaptive_mt_dataset request
1498
+ #
1499
+ # # The returned object is of type Google::Protobuf::Empty.
1500
+ # p result
1501
+ #
1502
+ def delete_adaptive_mt_dataset request, options = nil
1503
+ raise ::ArgumentError, "request must be provided" if request.nil?
1448
1504
 
1449
- yield self if block_given?
1505
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DeleteAdaptiveMtDatasetRequest
1506
+
1507
+ # Converts hash and nil to an options object
1508
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1509
+
1510
+ # Customize the options with defaults
1511
+ call_metadata = @config.rpcs.delete_adaptive_mt_dataset.metadata.to_h
1512
+
1513
+ # Set x-goog-api-client and x-goog-user-project headers
1514
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1515
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1516
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION,
1517
+ transports_version_send: [:rest]
1518
+
1519
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1520
+
1521
+ options.apply_defaults timeout: @config.rpcs.delete_adaptive_mt_dataset.timeout,
1522
+ metadata: call_metadata,
1523
+ retry_policy: @config.rpcs.delete_adaptive_mt_dataset.retry_policy
1524
+
1525
+ options.apply_defaults timeout: @config.timeout,
1526
+ metadata: @config.metadata,
1527
+ retry_policy: @config.retry_policy
1528
+
1529
+ @translation_service_stub.delete_adaptive_mt_dataset request, options do |result, operation|
1530
+ yield result, operation if block_given?
1531
+ return result
1450
1532
  end
1533
+ rescue ::Gapic::Rest::Error => e
1534
+ raise ::Google::Cloud::Error.from_error(e)
1535
+ end
1451
1536
 
1452
- ##
1453
- # Configurations for individual RPCs
1454
- # @return [Rpcs]
1455
- #
1456
- def rpcs
1457
- @rpcs ||= begin
1458
- parent_rpcs = nil
1459
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1460
- Rpcs.new parent_rpcs
1461
- end
1537
+ ##
1538
+ # Gets the Adaptive MT dataset.
1539
+ #
1540
+ # @overload get_adaptive_mt_dataset(request, options = nil)
1541
+ # Pass arguments to `get_adaptive_mt_dataset` via a request object, either of type
1542
+ # {::Google::Cloud::Translate::V3::GetAdaptiveMtDatasetRequest} or an equivalent Hash.
1543
+ #
1544
+ # @param request [::Google::Cloud::Translate::V3::GetAdaptiveMtDatasetRequest, ::Hash]
1545
+ # A request object representing the call parameters. Required. To specify no
1546
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1547
+ # @param options [::Gapic::CallOptions, ::Hash]
1548
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1549
+ #
1550
+ # @overload get_adaptive_mt_dataset(name: nil)
1551
+ # Pass arguments to `get_adaptive_mt_dataset` via keyword arguments. Note that at
1552
+ # least one keyword argument is required. To specify no parameters, or to keep all
1553
+ # the default parameter values, pass an empty Hash as a request object (see above).
1554
+ #
1555
+ # @param name [::String]
1556
+ # Required. Name of the dataset. In the form of
1557
+ # `projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}`
1558
+ # @yield [result, operation] Access the result along with the TransportOperation object
1559
+ # @yieldparam result [::Google::Cloud::Translate::V3::AdaptiveMtDataset]
1560
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1561
+ #
1562
+ # @return [::Google::Cloud::Translate::V3::AdaptiveMtDataset]
1563
+ #
1564
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1565
+ #
1566
+ # @example Basic example
1567
+ # require "google/cloud/translate/v3"
1568
+ #
1569
+ # # Create a client object. The client can be reused for multiple calls.
1570
+ # client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
1571
+ #
1572
+ # # Create a request. To set request fields, pass in keyword arguments.
1573
+ # request = Google::Cloud::Translate::V3::GetAdaptiveMtDatasetRequest.new
1574
+ #
1575
+ # # Call the get_adaptive_mt_dataset method.
1576
+ # result = client.get_adaptive_mt_dataset request
1577
+ #
1578
+ # # The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtDataset.
1579
+ # p result
1580
+ #
1581
+ def get_adaptive_mt_dataset request, options = nil
1582
+ raise ::ArgumentError, "request must be provided" if request.nil?
1583
+
1584
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetAdaptiveMtDatasetRequest
1585
+
1586
+ # Converts hash and nil to an options object
1587
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1588
+
1589
+ # Customize the options with defaults
1590
+ call_metadata = @config.rpcs.get_adaptive_mt_dataset.metadata.to_h
1591
+
1592
+ # Set x-goog-api-client and x-goog-user-project headers
1593
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1594
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1595
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION,
1596
+ transports_version_send: [:rest]
1597
+
1598
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1599
+
1600
+ options.apply_defaults timeout: @config.rpcs.get_adaptive_mt_dataset.timeout,
1601
+ metadata: call_metadata,
1602
+ retry_policy: @config.rpcs.get_adaptive_mt_dataset.retry_policy
1603
+
1604
+ options.apply_defaults timeout: @config.timeout,
1605
+ metadata: @config.metadata,
1606
+ retry_policy: @config.retry_policy
1607
+
1608
+ @translation_service_stub.get_adaptive_mt_dataset request, options do |result, operation|
1609
+ yield result, operation if block_given?
1610
+ return result
1462
1611
  end
1612
+ rescue ::Gapic::Rest::Error => e
1613
+ raise ::Google::Cloud::Error.from_error(e)
1614
+ end
1463
1615
 
1464
- ##
1465
- # Configuration RPC class for the TranslationService API.
1466
- #
1467
- # Includes fields providing the configuration for each RPC in this service.
1468
- # Each configuration object is of type `Gapic::Config::Method` and includes
1616
+ ##
1617
+ # Lists all Adaptive MT datasets for which the caller has read permission.
1618
+ #
1619
+ # @overload list_adaptive_mt_datasets(request, options = nil)
1620
+ # Pass arguments to `list_adaptive_mt_datasets` via a request object, either of type
1621
+ # {::Google::Cloud::Translate::V3::ListAdaptiveMtDatasetsRequest} or an equivalent Hash.
1622
+ #
1623
+ # @param request [::Google::Cloud::Translate::V3::ListAdaptiveMtDatasetsRequest, ::Hash]
1624
+ # A request object representing the call parameters. Required. To specify no
1625
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1626
+ # @param options [::Gapic::CallOptions, ::Hash]
1627
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1628
+ #
1629
+ # @overload list_adaptive_mt_datasets(parent: nil, page_size: nil, page_token: nil, filter: nil)
1630
+ # Pass arguments to `list_adaptive_mt_datasets` via keyword arguments. Note that at
1631
+ # least one keyword argument is required. To specify no parameters, or to keep all
1632
+ # the default parameter values, pass an empty Hash as a request object (see above).
1633
+ #
1634
+ # @param parent [::String]
1635
+ # Required. The resource name of the project from which to list the Adaptive
1636
+ # MT datasets. `projects/{project-number-or-id}/locations/{location-id}`
1637
+ # @param page_size [::Integer]
1638
+ # Optional. Requested page size. The server may return fewer results than
1639
+ # requested. If unspecified, the server picks an appropriate default.
1640
+ # @param page_token [::String]
1641
+ # Optional. A token identifying a page of results the server should return.
1642
+ # Typically, this is the value of
1643
+ # ListAdaptiveMtDatasetsResponse.next_page_token returned from the
1644
+ # previous call to `ListAdaptiveMtDatasets` method. The first page is
1645
+ # returned if `page_token`is empty or missing.
1646
+ # @param filter [::String]
1647
+ # Optional. An expression for filtering the results of the request.
1648
+ # Filter is not supported yet.
1649
+ # @yield [result, operation] Access the result along with the TransportOperation object
1650
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtDataset>]
1651
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1652
+ #
1653
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtDataset>]
1654
+ #
1655
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1656
+ #
1657
+ # @example Basic example
1658
+ # require "google/cloud/translate/v3"
1659
+ #
1660
+ # # Create a client object. The client can be reused for multiple calls.
1661
+ # client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
1662
+ #
1663
+ # # Create a request. To set request fields, pass in keyword arguments.
1664
+ # request = Google::Cloud::Translate::V3::ListAdaptiveMtDatasetsRequest.new
1665
+ #
1666
+ # # Call the list_adaptive_mt_datasets method.
1667
+ # result = client.list_adaptive_mt_datasets request
1668
+ #
1669
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
1670
+ # # over elements, and API calls will be issued to fetch pages as needed.
1671
+ # result.each do |item|
1672
+ # # Each element is of type ::Google::Cloud::Translate::V3::AdaptiveMtDataset.
1673
+ # p item
1674
+ # end
1675
+ #
1676
+ def list_adaptive_mt_datasets request, options = nil
1677
+ raise ::ArgumentError, "request must be provided" if request.nil?
1678
+
1679
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListAdaptiveMtDatasetsRequest
1680
+
1681
+ # Converts hash and nil to an options object
1682
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1683
+
1684
+ # Customize the options with defaults
1685
+ call_metadata = @config.rpcs.list_adaptive_mt_datasets.metadata.to_h
1686
+
1687
+ # Set x-goog-api-client and x-goog-user-project headers
1688
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1689
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1690
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION,
1691
+ transports_version_send: [:rest]
1692
+
1693
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1694
+
1695
+ options.apply_defaults timeout: @config.rpcs.list_adaptive_mt_datasets.timeout,
1696
+ metadata: call_metadata,
1697
+ retry_policy: @config.rpcs.list_adaptive_mt_datasets.retry_policy
1698
+
1699
+ options.apply_defaults timeout: @config.timeout,
1700
+ metadata: @config.metadata,
1701
+ retry_policy: @config.retry_policy
1702
+
1703
+ @translation_service_stub.list_adaptive_mt_datasets request, options do |result, operation|
1704
+ result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_adaptive_mt_datasets, "adaptive_mt_datasets", request, result, options
1705
+ yield result, operation if block_given?
1706
+ return result
1707
+ end
1708
+ rescue ::Gapic::Rest::Error => e
1709
+ raise ::Google::Cloud::Error.from_error(e)
1710
+ end
1711
+
1712
+ ##
1713
+ # Translate text using Adaptive MT.
1714
+ #
1715
+ # @overload adaptive_mt_translate(request, options = nil)
1716
+ # Pass arguments to `adaptive_mt_translate` via a request object, either of type
1717
+ # {::Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest} or an equivalent Hash.
1718
+ #
1719
+ # @param request [::Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest, ::Hash]
1720
+ # A request object representing the call parameters. Required. To specify no
1721
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1722
+ # @param options [::Gapic::CallOptions, ::Hash]
1723
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1724
+ #
1725
+ # @overload adaptive_mt_translate(parent: nil, dataset: nil, content: nil)
1726
+ # Pass arguments to `adaptive_mt_translate` via keyword arguments. Note that at
1727
+ # least one keyword argument is required. To specify no parameters, or to keep all
1728
+ # the default parameter values, pass an empty Hash as a request object (see above).
1729
+ #
1730
+ # @param parent [::String]
1731
+ # Required. Location to make a regional call.
1732
+ #
1733
+ # Format: `projects/{project-number-or-id}/locations/{location-id}`.
1734
+ # @param dataset [::String]
1735
+ # Required. The resource name for the dataset to use for adaptive MT.
1736
+ # `projects/{project}/locations/{location-id}/adaptiveMtDatasets/{dataset}`
1737
+ # @param content [::Array<::String>]
1738
+ # Required. The content of the input in string format.
1739
+ # For now only one sentence per request is supported.
1740
+ # @yield [result, operation] Access the result along with the TransportOperation object
1741
+ # @yieldparam result [::Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse]
1742
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1743
+ #
1744
+ # @return [::Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse]
1745
+ #
1746
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1747
+ #
1748
+ # @example Basic example
1749
+ # require "google/cloud/translate/v3"
1750
+ #
1751
+ # # Create a client object. The client can be reused for multiple calls.
1752
+ # client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
1753
+ #
1754
+ # # Create a request. To set request fields, pass in keyword arguments.
1755
+ # request = Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest.new
1756
+ #
1757
+ # # Call the adaptive_mt_translate method.
1758
+ # result = client.adaptive_mt_translate request
1759
+ #
1760
+ # # The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse.
1761
+ # p result
1762
+ #
1763
+ def adaptive_mt_translate request, options = nil
1764
+ raise ::ArgumentError, "request must be provided" if request.nil?
1765
+
1766
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest
1767
+
1768
+ # Converts hash and nil to an options object
1769
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1770
+
1771
+ # Customize the options with defaults
1772
+ call_metadata = @config.rpcs.adaptive_mt_translate.metadata.to_h
1773
+
1774
+ # Set x-goog-api-client and x-goog-user-project headers
1775
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1776
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1777
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION,
1778
+ transports_version_send: [:rest]
1779
+
1780
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1781
+
1782
+ options.apply_defaults timeout: @config.rpcs.adaptive_mt_translate.timeout,
1783
+ metadata: call_metadata,
1784
+ retry_policy: @config.rpcs.adaptive_mt_translate.retry_policy
1785
+
1786
+ options.apply_defaults timeout: @config.timeout,
1787
+ metadata: @config.metadata,
1788
+ retry_policy: @config.retry_policy
1789
+
1790
+ @translation_service_stub.adaptive_mt_translate request, options do |result, operation|
1791
+ yield result, operation if block_given?
1792
+ return result
1793
+ end
1794
+ rescue ::Gapic::Rest::Error => e
1795
+ raise ::Google::Cloud::Error.from_error(e)
1796
+ end
1797
+
1798
+ ##
1799
+ # Gets and AdaptiveMtFile
1800
+ #
1801
+ # @overload get_adaptive_mt_file(request, options = nil)
1802
+ # Pass arguments to `get_adaptive_mt_file` via a request object, either of type
1803
+ # {::Google::Cloud::Translate::V3::GetAdaptiveMtFileRequest} or an equivalent Hash.
1804
+ #
1805
+ # @param request [::Google::Cloud::Translate::V3::GetAdaptiveMtFileRequest, ::Hash]
1806
+ # A request object representing the call parameters. Required. To specify no
1807
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1808
+ # @param options [::Gapic::CallOptions, ::Hash]
1809
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1810
+ #
1811
+ # @overload get_adaptive_mt_file(name: nil)
1812
+ # Pass arguments to `get_adaptive_mt_file` via keyword arguments. Note that at
1813
+ # least one keyword argument is required. To specify no parameters, or to keep all
1814
+ # the default parameter values, pass an empty Hash as a request object (see above).
1815
+ #
1816
+ # @param name [::String]
1817
+ # Required. The resource name of the file, in form of
1818
+ # `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
1819
+ # @yield [result, operation] Access the result along with the TransportOperation object
1820
+ # @yieldparam result [::Google::Cloud::Translate::V3::AdaptiveMtFile]
1821
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1822
+ #
1823
+ # @return [::Google::Cloud::Translate::V3::AdaptiveMtFile]
1824
+ #
1825
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1826
+ #
1827
+ # @example Basic example
1828
+ # require "google/cloud/translate/v3"
1829
+ #
1830
+ # # Create a client object. The client can be reused for multiple calls.
1831
+ # client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
1832
+ #
1833
+ # # Create a request. To set request fields, pass in keyword arguments.
1834
+ # request = Google::Cloud::Translate::V3::GetAdaptiveMtFileRequest.new
1835
+ #
1836
+ # # Call the get_adaptive_mt_file method.
1837
+ # result = client.get_adaptive_mt_file request
1838
+ #
1839
+ # # The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtFile.
1840
+ # p result
1841
+ #
1842
+ def get_adaptive_mt_file request, options = nil
1843
+ raise ::ArgumentError, "request must be provided" if request.nil?
1844
+
1845
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetAdaptiveMtFileRequest
1846
+
1847
+ # Converts hash and nil to an options object
1848
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1849
+
1850
+ # Customize the options with defaults
1851
+ call_metadata = @config.rpcs.get_adaptive_mt_file.metadata.to_h
1852
+
1853
+ # Set x-goog-api-client and x-goog-user-project headers
1854
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1855
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1856
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION,
1857
+ transports_version_send: [:rest]
1858
+
1859
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1860
+
1861
+ options.apply_defaults timeout: @config.rpcs.get_adaptive_mt_file.timeout,
1862
+ metadata: call_metadata,
1863
+ retry_policy: @config.rpcs.get_adaptive_mt_file.retry_policy
1864
+
1865
+ options.apply_defaults timeout: @config.timeout,
1866
+ metadata: @config.metadata,
1867
+ retry_policy: @config.retry_policy
1868
+
1869
+ @translation_service_stub.get_adaptive_mt_file request, options do |result, operation|
1870
+ yield result, operation if block_given?
1871
+ return result
1872
+ end
1873
+ rescue ::Gapic::Rest::Error => e
1874
+ raise ::Google::Cloud::Error.from_error(e)
1875
+ end
1876
+
1877
+ ##
1878
+ # Deletes an AdaptiveMtFile along with its sentences.
1879
+ #
1880
+ # @overload delete_adaptive_mt_file(request, options = nil)
1881
+ # Pass arguments to `delete_adaptive_mt_file` via a request object, either of type
1882
+ # {::Google::Cloud::Translate::V3::DeleteAdaptiveMtFileRequest} or an equivalent Hash.
1883
+ #
1884
+ # @param request [::Google::Cloud::Translate::V3::DeleteAdaptiveMtFileRequest, ::Hash]
1885
+ # A request object representing the call parameters. Required. To specify no
1886
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1887
+ # @param options [::Gapic::CallOptions, ::Hash]
1888
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1889
+ #
1890
+ # @overload delete_adaptive_mt_file(name: nil)
1891
+ # Pass arguments to `delete_adaptive_mt_file` via keyword arguments. Note that at
1892
+ # least one keyword argument is required. To specify no parameters, or to keep all
1893
+ # the default parameter values, pass an empty Hash as a request object (see above).
1894
+ #
1895
+ # @param name [::String]
1896
+ # Required. The resource name of the file to delete, in form of
1897
+ # `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
1898
+ # @yield [result, operation] Access the result along with the TransportOperation object
1899
+ # @yieldparam result [::Google::Protobuf::Empty]
1900
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1901
+ #
1902
+ # @return [::Google::Protobuf::Empty]
1903
+ #
1904
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1905
+ #
1906
+ # @example Basic example
1907
+ # require "google/cloud/translate/v3"
1908
+ #
1909
+ # # Create a client object. The client can be reused for multiple calls.
1910
+ # client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
1911
+ #
1912
+ # # Create a request. To set request fields, pass in keyword arguments.
1913
+ # request = Google::Cloud::Translate::V3::DeleteAdaptiveMtFileRequest.new
1914
+ #
1915
+ # # Call the delete_adaptive_mt_file method.
1916
+ # result = client.delete_adaptive_mt_file request
1917
+ #
1918
+ # # The returned object is of type Google::Protobuf::Empty.
1919
+ # p result
1920
+ #
1921
+ def delete_adaptive_mt_file request, options = nil
1922
+ raise ::ArgumentError, "request must be provided" if request.nil?
1923
+
1924
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DeleteAdaptiveMtFileRequest
1925
+
1926
+ # Converts hash and nil to an options object
1927
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1928
+
1929
+ # Customize the options with defaults
1930
+ call_metadata = @config.rpcs.delete_adaptive_mt_file.metadata.to_h
1931
+
1932
+ # Set x-goog-api-client and x-goog-user-project headers
1933
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1934
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1935
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION,
1936
+ transports_version_send: [:rest]
1937
+
1938
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1939
+
1940
+ options.apply_defaults timeout: @config.rpcs.delete_adaptive_mt_file.timeout,
1941
+ metadata: call_metadata,
1942
+ retry_policy: @config.rpcs.delete_adaptive_mt_file.retry_policy
1943
+
1944
+ options.apply_defaults timeout: @config.timeout,
1945
+ metadata: @config.metadata,
1946
+ retry_policy: @config.retry_policy
1947
+
1948
+ @translation_service_stub.delete_adaptive_mt_file request, options do |result, operation|
1949
+ yield result, operation if block_given?
1950
+ return result
1951
+ end
1952
+ rescue ::Gapic::Rest::Error => e
1953
+ raise ::Google::Cloud::Error.from_error(e)
1954
+ end
1955
+
1956
+ ##
1957
+ # Imports an AdaptiveMtFile and adds all of its sentences into the
1958
+ # AdaptiveMtDataset.
1959
+ #
1960
+ # @overload import_adaptive_mt_file(request, options = nil)
1961
+ # Pass arguments to `import_adaptive_mt_file` via a request object, either of type
1962
+ # {::Google::Cloud::Translate::V3::ImportAdaptiveMtFileRequest} or an equivalent Hash.
1963
+ #
1964
+ # @param request [::Google::Cloud::Translate::V3::ImportAdaptiveMtFileRequest, ::Hash]
1965
+ # A request object representing the call parameters. Required. To specify no
1966
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1967
+ # @param options [::Gapic::CallOptions, ::Hash]
1968
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1969
+ #
1970
+ # @overload import_adaptive_mt_file(parent: nil, file_input_source: nil, gcs_input_source: nil)
1971
+ # Pass arguments to `import_adaptive_mt_file` via keyword arguments. Note that at
1972
+ # least one keyword argument is required. To specify no parameters, or to keep all
1973
+ # the default parameter values, pass an empty Hash as a request object (see above).
1974
+ #
1975
+ # @param parent [::String]
1976
+ # Required. The resource name of the file, in form of
1977
+ # `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}`
1978
+ # @param file_input_source [::Google::Cloud::Translate::V3::FileInputSource, ::Hash]
1979
+ # Inline file source.
1980
+ # @param gcs_input_source [::Google::Cloud::Translate::V3::GcsInputSource, ::Hash]
1981
+ # Google Cloud Storage file source.
1982
+ # @yield [result, operation] Access the result along with the TransportOperation object
1983
+ # @yieldparam result [::Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse]
1984
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1985
+ #
1986
+ # @return [::Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse]
1987
+ #
1988
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1989
+ #
1990
+ # @example Basic example
1991
+ # require "google/cloud/translate/v3"
1992
+ #
1993
+ # # Create a client object. The client can be reused for multiple calls.
1994
+ # client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
1995
+ #
1996
+ # # Create a request. To set request fields, pass in keyword arguments.
1997
+ # request = Google::Cloud::Translate::V3::ImportAdaptiveMtFileRequest.new
1998
+ #
1999
+ # # Call the import_adaptive_mt_file method.
2000
+ # result = client.import_adaptive_mt_file request
2001
+ #
2002
+ # # The returned object is of type Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse.
2003
+ # p result
2004
+ #
2005
+ def import_adaptive_mt_file request, options = nil
2006
+ raise ::ArgumentError, "request must be provided" if request.nil?
2007
+
2008
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ImportAdaptiveMtFileRequest
2009
+
2010
+ # Converts hash and nil to an options object
2011
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2012
+
2013
+ # Customize the options with defaults
2014
+ call_metadata = @config.rpcs.import_adaptive_mt_file.metadata.to_h
2015
+
2016
+ # Set x-goog-api-client and x-goog-user-project headers
2017
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2018
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2019
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION,
2020
+ transports_version_send: [:rest]
2021
+
2022
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2023
+
2024
+ options.apply_defaults timeout: @config.rpcs.import_adaptive_mt_file.timeout,
2025
+ metadata: call_metadata,
2026
+ retry_policy: @config.rpcs.import_adaptive_mt_file.retry_policy
2027
+
2028
+ options.apply_defaults timeout: @config.timeout,
2029
+ metadata: @config.metadata,
2030
+ retry_policy: @config.retry_policy
2031
+
2032
+ @translation_service_stub.import_adaptive_mt_file request, options do |result, operation|
2033
+ yield result, operation if block_given?
2034
+ return result
2035
+ end
2036
+ rescue ::Gapic::Rest::Error => e
2037
+ raise ::Google::Cloud::Error.from_error(e)
2038
+ end
2039
+
2040
+ ##
2041
+ # Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.
2042
+ #
2043
+ # @overload list_adaptive_mt_files(request, options = nil)
2044
+ # Pass arguments to `list_adaptive_mt_files` via a request object, either of type
2045
+ # {::Google::Cloud::Translate::V3::ListAdaptiveMtFilesRequest} or an equivalent Hash.
2046
+ #
2047
+ # @param request [::Google::Cloud::Translate::V3::ListAdaptiveMtFilesRequest, ::Hash]
2048
+ # A request object representing the call parameters. Required. To specify no
2049
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2050
+ # @param options [::Gapic::CallOptions, ::Hash]
2051
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
2052
+ #
2053
+ # @overload list_adaptive_mt_files(parent: nil, page_size: nil, page_token: nil)
2054
+ # Pass arguments to `list_adaptive_mt_files` via keyword arguments. Note that at
2055
+ # least one keyword argument is required. To specify no parameters, or to keep all
2056
+ # the default parameter values, pass an empty Hash as a request object (see above).
2057
+ #
2058
+ # @param parent [::String]
2059
+ # Required. The resource name of the project from which to list the Adaptive
2060
+ # MT files.
2061
+ # `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
2062
+ # @param page_size [::Integer]
2063
+ # Optional.
2064
+ # @param page_token [::String]
2065
+ # Optional. A token identifying a page of results the server should return.
2066
+ # Typically, this is the value of
2067
+ # ListAdaptiveMtFilesResponse.next_page_token returned from the
2068
+ # previous call to `ListAdaptiveMtFiles` method. The first page is
2069
+ # returned if `page_token`is empty or missing.
2070
+ # @yield [result, operation] Access the result along with the TransportOperation object
2071
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtFile>]
2072
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
2073
+ #
2074
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtFile>]
2075
+ #
2076
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
2077
+ #
2078
+ # @example Basic example
2079
+ # require "google/cloud/translate/v3"
2080
+ #
2081
+ # # Create a client object. The client can be reused for multiple calls.
2082
+ # client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
2083
+ #
2084
+ # # Create a request. To set request fields, pass in keyword arguments.
2085
+ # request = Google::Cloud::Translate::V3::ListAdaptiveMtFilesRequest.new
2086
+ #
2087
+ # # Call the list_adaptive_mt_files method.
2088
+ # result = client.list_adaptive_mt_files request
2089
+ #
2090
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
2091
+ # # over elements, and API calls will be issued to fetch pages as needed.
2092
+ # result.each do |item|
2093
+ # # Each element is of type ::Google::Cloud::Translate::V3::AdaptiveMtFile.
2094
+ # p item
2095
+ # end
2096
+ #
2097
+ def list_adaptive_mt_files request, options = nil
2098
+ raise ::ArgumentError, "request must be provided" if request.nil?
2099
+
2100
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListAdaptiveMtFilesRequest
2101
+
2102
+ # Converts hash and nil to an options object
2103
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2104
+
2105
+ # Customize the options with defaults
2106
+ call_metadata = @config.rpcs.list_adaptive_mt_files.metadata.to_h
2107
+
2108
+ # Set x-goog-api-client and x-goog-user-project headers
2109
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2110
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2111
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION,
2112
+ transports_version_send: [:rest]
2113
+
2114
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2115
+
2116
+ options.apply_defaults timeout: @config.rpcs.list_adaptive_mt_files.timeout,
2117
+ metadata: call_metadata,
2118
+ retry_policy: @config.rpcs.list_adaptive_mt_files.retry_policy
2119
+
2120
+ options.apply_defaults timeout: @config.timeout,
2121
+ metadata: @config.metadata,
2122
+ retry_policy: @config.retry_policy
2123
+
2124
+ @translation_service_stub.list_adaptive_mt_files request, options do |result, operation|
2125
+ result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_adaptive_mt_files, "adaptive_mt_files", request, result, options
2126
+ yield result, operation if block_given?
2127
+ return result
2128
+ end
2129
+ rescue ::Gapic::Rest::Error => e
2130
+ raise ::Google::Cloud::Error.from_error(e)
2131
+ end
2132
+
2133
+ ##
2134
+ # Lists all AdaptiveMtSentences under a given file/dataset.
2135
+ #
2136
+ # @overload list_adaptive_mt_sentences(request, options = nil)
2137
+ # Pass arguments to `list_adaptive_mt_sentences` via a request object, either of type
2138
+ # {::Google::Cloud::Translate::V3::ListAdaptiveMtSentencesRequest} or an equivalent Hash.
2139
+ #
2140
+ # @param request [::Google::Cloud::Translate::V3::ListAdaptiveMtSentencesRequest, ::Hash]
2141
+ # A request object representing the call parameters. Required. To specify no
2142
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2143
+ # @param options [::Gapic::CallOptions, ::Hash]
2144
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
2145
+ #
2146
+ # @overload list_adaptive_mt_sentences(parent: nil, page_size: nil, page_token: nil)
2147
+ # Pass arguments to `list_adaptive_mt_sentences` via keyword arguments. Note that at
2148
+ # least one keyword argument is required. To specify no parameters, or to keep all
2149
+ # the default parameter values, pass an empty Hash as a request object (see above).
2150
+ #
2151
+ # @param parent [::String]
2152
+ # Required. The resource name of the project from which to list the Adaptive
2153
+ # MT files. The following format lists all sentences under a file.
2154
+ # `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
2155
+ # The following format lists all sentences within a dataset.
2156
+ # `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
2157
+ # @param page_size [::Integer]
2158
+ # @param page_token [::String]
2159
+ # A token identifying a page of results the server should return.
2160
+ # Typically, this is the value of
2161
+ # ListAdaptiveMtSentencesRequest.next_page_token returned from the
2162
+ # previous call to `ListTranslationMemories` method. The first page is
2163
+ # returned if `page_token` is empty or missing.
2164
+ # @yield [result, operation] Access the result along with the TransportOperation object
2165
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtSentence>]
2166
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
2167
+ #
2168
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtSentence>]
2169
+ #
2170
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
2171
+ #
2172
+ # @example Basic example
2173
+ # require "google/cloud/translate/v3"
2174
+ #
2175
+ # # Create a client object. The client can be reused for multiple calls.
2176
+ # client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
2177
+ #
2178
+ # # Create a request. To set request fields, pass in keyword arguments.
2179
+ # request = Google::Cloud::Translate::V3::ListAdaptiveMtSentencesRequest.new
2180
+ #
2181
+ # # Call the list_adaptive_mt_sentences method.
2182
+ # result = client.list_adaptive_mt_sentences request
2183
+ #
2184
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
2185
+ # # over elements, and API calls will be issued to fetch pages as needed.
2186
+ # result.each do |item|
2187
+ # # Each element is of type ::Google::Cloud::Translate::V3::AdaptiveMtSentence.
2188
+ # p item
2189
+ # end
2190
+ #
2191
+ def list_adaptive_mt_sentences request, options = nil
2192
+ raise ::ArgumentError, "request must be provided" if request.nil?
2193
+
2194
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListAdaptiveMtSentencesRequest
2195
+
2196
+ # Converts hash and nil to an options object
2197
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2198
+
2199
+ # Customize the options with defaults
2200
+ call_metadata = @config.rpcs.list_adaptive_mt_sentences.metadata.to_h
2201
+
2202
+ # Set x-goog-api-client and x-goog-user-project headers
2203
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2204
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2205
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION,
2206
+ transports_version_send: [:rest]
2207
+
2208
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2209
+
2210
+ options.apply_defaults timeout: @config.rpcs.list_adaptive_mt_sentences.timeout,
2211
+ metadata: call_metadata,
2212
+ retry_policy: @config.rpcs.list_adaptive_mt_sentences.retry_policy
2213
+
2214
+ options.apply_defaults timeout: @config.timeout,
2215
+ metadata: @config.metadata,
2216
+ retry_policy: @config.retry_policy
2217
+
2218
+ @translation_service_stub.list_adaptive_mt_sentences request, options do |result, operation|
2219
+ result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_adaptive_mt_sentences, "adaptive_mt_sentences", request, result, options
2220
+ yield result, operation if block_given?
2221
+ return result
2222
+ end
2223
+ rescue ::Gapic::Rest::Error => e
2224
+ raise ::Google::Cloud::Error.from_error(e)
2225
+ end
2226
+
2227
+ ##
2228
+ # Configuration class for the TranslationService REST API.
2229
+ #
2230
+ # This class represents the configuration for TranslationService REST,
2231
+ # providing control over timeouts, retry behavior, logging, transport
2232
+ # parameters, and other low-level controls. Certain parameters can also be
2233
+ # applied individually to specific RPCs. See
2234
+ # {::Google::Cloud::Translate::V3::TranslationService::Rest::Client::Configuration::Rpcs}
2235
+ # for a list of RPCs that can be configured independently.
2236
+ #
2237
+ # Configuration can be applied globally to all clients, or to a single client
2238
+ # on construction.
2239
+ #
2240
+ # @example
2241
+ #
2242
+ # # Modify the global config, setting the timeout for
2243
+ # # translate_text to 20 seconds,
2244
+ # # and all remaining timeouts to 10 seconds.
2245
+ # ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.configure do |config|
2246
+ # config.timeout = 10.0
2247
+ # config.rpcs.translate_text.timeout = 20.0
2248
+ # end
2249
+ #
2250
+ # # Apply the above configuration only to a new client.
2251
+ # client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.new do |config|
2252
+ # config.timeout = 10.0
2253
+ # config.rpcs.translate_text.timeout = 20.0
2254
+ # end
2255
+ #
2256
+ # @!attribute [rw] endpoint
2257
+ # A custom service endpoint, as a hostname or hostname:port. The default is
2258
+ # nil, indicating to use the default endpoint in the current universe domain.
2259
+ # @return [::String,nil]
2260
+ # @!attribute [rw] credentials
2261
+ # Credentials to send with calls. You may provide any of the following types:
2262
+ # * (`String`) The path to a service account key file in JSON format
2263
+ # * (`Hash`) A service account key as a Hash
2264
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
2265
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
2266
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
2267
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
2268
+ # * (`nil`) indicating no credentials
2269
+ # @return [::Object]
2270
+ # @!attribute [rw] scope
2271
+ # The OAuth scopes
2272
+ # @return [::Array<::String>]
2273
+ # @!attribute [rw] lib_name
2274
+ # The library name as recorded in instrumentation and logging
2275
+ # @return [::String]
2276
+ # @!attribute [rw] lib_version
2277
+ # The library version as recorded in instrumentation and logging
2278
+ # @return [::String]
2279
+ # @!attribute [rw] timeout
2280
+ # The call timeout in seconds.
2281
+ # @return [::Numeric]
2282
+ # @!attribute [rw] metadata
2283
+ # Additional headers to be sent with the call.
2284
+ # @return [::Hash{::Symbol=>::String}]
2285
+ # @!attribute [rw] retry_policy
2286
+ # The retry policy. The value is a hash with the following keys:
2287
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
2288
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
2289
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
2290
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
2291
+ # trigger a retry.
2292
+ # @return [::Hash]
2293
+ # @!attribute [rw] quota_project
2294
+ # A separate project against which to charge quota.
2295
+ # @return [::String]
2296
+ # @!attribute [rw] universe_domain
2297
+ # The universe domain within which to make requests. This determines the
2298
+ # default endpoint URL. The default value of nil uses the environment
2299
+ # universe (usually the default "googleapis.com" universe).
2300
+ # @return [::String,nil]
2301
+ #
2302
+ class Configuration
2303
+ extend ::Gapic::Config
2304
+
2305
+ # @private
2306
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
2307
+ DEFAULT_ENDPOINT = "translate.googleapis.com"
2308
+
2309
+ config_attr :endpoint, nil, ::String, nil
2310
+ config_attr :credentials, nil do |value|
2311
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
2312
+ allowed.any? { |klass| klass === value }
2313
+ end
2314
+ config_attr :scope, nil, ::String, ::Array, nil
2315
+ config_attr :lib_name, nil, ::String, nil
2316
+ config_attr :lib_version, nil, ::String, nil
2317
+ config_attr :timeout, nil, ::Numeric, nil
2318
+ config_attr :metadata, nil, ::Hash, nil
2319
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2320
+ config_attr :quota_project, nil, ::String, nil
2321
+ config_attr :universe_domain, nil, ::String, nil
2322
+
2323
+ # @private
2324
+ def initialize parent_config = nil
2325
+ @parent_config = parent_config unless parent_config.nil?
2326
+
2327
+ yield self if block_given?
2328
+ end
2329
+
2330
+ ##
2331
+ # Configurations for individual RPCs
2332
+ # @return [Rpcs]
2333
+ #
2334
+ def rpcs
2335
+ @rpcs ||= begin
2336
+ parent_rpcs = nil
2337
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
2338
+ Rpcs.new parent_rpcs
2339
+ end
2340
+ end
2341
+
2342
+ ##
2343
+ # Configuration RPC class for the TranslationService API.
2344
+ #
2345
+ # Includes fields providing the configuration for each RPC in this service.
2346
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1469
2347
  # the following configuration fields:
1470
2348
  #
1471
2349
  # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
@@ -1529,6 +2407,56 @@ module Google
1529
2407
  # @return [::Gapic::Config::Method]
1530
2408
  #
1531
2409
  attr_reader :delete_glossary
2410
+ ##
2411
+ # RPC-specific configuration for `create_adaptive_mt_dataset`
2412
+ # @return [::Gapic::Config::Method]
2413
+ #
2414
+ attr_reader :create_adaptive_mt_dataset
2415
+ ##
2416
+ # RPC-specific configuration for `delete_adaptive_mt_dataset`
2417
+ # @return [::Gapic::Config::Method]
2418
+ #
2419
+ attr_reader :delete_adaptive_mt_dataset
2420
+ ##
2421
+ # RPC-specific configuration for `get_adaptive_mt_dataset`
2422
+ # @return [::Gapic::Config::Method]
2423
+ #
2424
+ attr_reader :get_adaptive_mt_dataset
2425
+ ##
2426
+ # RPC-specific configuration for `list_adaptive_mt_datasets`
2427
+ # @return [::Gapic::Config::Method]
2428
+ #
2429
+ attr_reader :list_adaptive_mt_datasets
2430
+ ##
2431
+ # RPC-specific configuration for `adaptive_mt_translate`
2432
+ # @return [::Gapic::Config::Method]
2433
+ #
2434
+ attr_reader :adaptive_mt_translate
2435
+ ##
2436
+ # RPC-specific configuration for `get_adaptive_mt_file`
2437
+ # @return [::Gapic::Config::Method]
2438
+ #
2439
+ attr_reader :get_adaptive_mt_file
2440
+ ##
2441
+ # RPC-specific configuration for `delete_adaptive_mt_file`
2442
+ # @return [::Gapic::Config::Method]
2443
+ #
2444
+ attr_reader :delete_adaptive_mt_file
2445
+ ##
2446
+ # RPC-specific configuration for `import_adaptive_mt_file`
2447
+ # @return [::Gapic::Config::Method]
2448
+ #
2449
+ attr_reader :import_adaptive_mt_file
2450
+ ##
2451
+ # RPC-specific configuration for `list_adaptive_mt_files`
2452
+ # @return [::Gapic::Config::Method]
2453
+ #
2454
+ attr_reader :list_adaptive_mt_files
2455
+ ##
2456
+ # RPC-specific configuration for `list_adaptive_mt_sentences`
2457
+ # @return [::Gapic::Config::Method]
2458
+ #
2459
+ attr_reader :list_adaptive_mt_sentences
1532
2460
 
1533
2461
  # @private
1534
2462
  def initialize parent_rpcs = nil
@@ -1552,6 +2480,26 @@ module Google
1552
2480
  @get_glossary = ::Gapic::Config::Method.new get_glossary_config
1553
2481
  delete_glossary_config = parent_rpcs.delete_glossary if parent_rpcs.respond_to? :delete_glossary
1554
2482
  @delete_glossary = ::Gapic::Config::Method.new delete_glossary_config
2483
+ create_adaptive_mt_dataset_config = parent_rpcs.create_adaptive_mt_dataset if parent_rpcs.respond_to? :create_adaptive_mt_dataset
2484
+ @create_adaptive_mt_dataset = ::Gapic::Config::Method.new create_adaptive_mt_dataset_config
2485
+ delete_adaptive_mt_dataset_config = parent_rpcs.delete_adaptive_mt_dataset if parent_rpcs.respond_to? :delete_adaptive_mt_dataset
2486
+ @delete_adaptive_mt_dataset = ::Gapic::Config::Method.new delete_adaptive_mt_dataset_config
2487
+ get_adaptive_mt_dataset_config = parent_rpcs.get_adaptive_mt_dataset if parent_rpcs.respond_to? :get_adaptive_mt_dataset
2488
+ @get_adaptive_mt_dataset = ::Gapic::Config::Method.new get_adaptive_mt_dataset_config
2489
+ list_adaptive_mt_datasets_config = parent_rpcs.list_adaptive_mt_datasets if parent_rpcs.respond_to? :list_adaptive_mt_datasets
2490
+ @list_adaptive_mt_datasets = ::Gapic::Config::Method.new list_adaptive_mt_datasets_config
2491
+ adaptive_mt_translate_config = parent_rpcs.adaptive_mt_translate if parent_rpcs.respond_to? :adaptive_mt_translate
2492
+ @adaptive_mt_translate = ::Gapic::Config::Method.new adaptive_mt_translate_config
2493
+ get_adaptive_mt_file_config = parent_rpcs.get_adaptive_mt_file if parent_rpcs.respond_to? :get_adaptive_mt_file
2494
+ @get_adaptive_mt_file = ::Gapic::Config::Method.new get_adaptive_mt_file_config
2495
+ delete_adaptive_mt_file_config = parent_rpcs.delete_adaptive_mt_file if parent_rpcs.respond_to? :delete_adaptive_mt_file
2496
+ @delete_adaptive_mt_file = ::Gapic::Config::Method.new delete_adaptive_mt_file_config
2497
+ import_adaptive_mt_file_config = parent_rpcs.import_adaptive_mt_file if parent_rpcs.respond_to? :import_adaptive_mt_file
2498
+ @import_adaptive_mt_file = ::Gapic::Config::Method.new import_adaptive_mt_file_config
2499
+ list_adaptive_mt_files_config = parent_rpcs.list_adaptive_mt_files if parent_rpcs.respond_to? :list_adaptive_mt_files
2500
+ @list_adaptive_mt_files = ::Gapic::Config::Method.new list_adaptive_mt_files_config
2501
+ list_adaptive_mt_sentences_config = parent_rpcs.list_adaptive_mt_sentences if parent_rpcs.respond_to? :list_adaptive_mt_sentences
2502
+ @list_adaptive_mt_sentences = ::Gapic::Config::Method.new list_adaptive_mt_sentences_config
1555
2503
 
1556
2504
  yield self if block_given?
1557
2505
  end