google-cloud-speech-v1p1beta1 0.3.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "googleauth"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Speech
24
+ module V1p1beta1
25
+ module Adaptation
26
+ # Credentials for the Adaptation API.
27
+ class Credentials < ::Google::Auth::Credentials
28
+ self.scope = [
29
+ "https://www.googleapis.com/auth/cloud-platform"
30
+ ]
31
+ self.env_vars = [
32
+ "SPEECH_CREDENTIALS",
33
+ "SPEECH_KEYFILE",
34
+ "GOOGLE_CLOUD_CREDENTIALS",
35
+ "GOOGLE_CLOUD_KEYFILE",
36
+ "GCLOUD_KEYFILE",
37
+ "SPEECH_CREDENTIALS_JSON",
38
+ "SPEECH_KEYFILE_JSON",
39
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
40
+ "GOOGLE_CLOUD_KEYFILE_JSON",
41
+ "GCLOUD_KEYFILE_JSON"
42
+ ]
43
+ self.paths = [
44
+ "~/.config/google_cloud/application_default_credentials.json"
45
+ ]
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+
20
+ module Google
21
+ module Cloud
22
+ module Speech
23
+ module V1p1beta1
24
+ module Adaptation
25
+ # Path helper methods for the Adaptation API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified CustomClass resource string.
29
+ #
30
+ # The resource will be in the following format:
31
+ #
32
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`
33
+ #
34
+ # @param project [String]
35
+ # @param location [String]
36
+ # @param custom_class [String]
37
+ #
38
+ # @return [::String]
39
+ def custom_class_path project:, location:, custom_class:
40
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
41
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
42
+
43
+ "projects/#{project}/locations/#{location}/customClasses/#{custom_class}"
44
+ end
45
+
46
+ ##
47
+ # Create a fully-qualified Location resource string.
48
+ #
49
+ # The resource will be in the following format:
50
+ #
51
+ # `projects/{project}/locations/{location}`
52
+ #
53
+ # @param project [String]
54
+ # @param location [String]
55
+ #
56
+ # @return [::String]
57
+ def location_path project:, location:
58
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
59
+
60
+ "projects/#{project}/locations/#{location}"
61
+ end
62
+
63
+ ##
64
+ # Create a fully-qualified PhraseSet resource string.
65
+ #
66
+ # The resource will be in the following format:
67
+ #
68
+ # `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
69
+ #
70
+ # @param project [String]
71
+ # @param location [String]
72
+ # @param phrase_set [String]
73
+ #
74
+ # @return [::String]
75
+ def phrase_set_path project:, location:, phrase_set:
76
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
77
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
78
+
79
+ "projects/#{project}/locations/#{location}/phraseSets/#{phrase_set}"
80
+ end
81
+
82
+ extend self
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,85 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/annotations_pb'
7
+ require 'google/api/client_pb'
8
+ require 'google/api/field_behavior_pb'
9
+ require 'google/api/resource_pb'
10
+ require 'google/cloud/speech/v1p1beta1/resource_pb'
11
+ require 'google/protobuf/empty_pb'
12
+ require 'google/protobuf/field_mask_pb'
13
+ Google::Protobuf::DescriptorPool.generated_pool.build do
14
+ add_file("google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto", :syntax => :proto3) do
15
+ add_message "google.cloud.speech.v1p1beta1.CreatePhraseSetRequest" do
16
+ optional :parent, :string, 1
17
+ optional :phrase_set_id, :string, 2
18
+ optional :phrase_set, :message, 3, "google.cloud.speech.v1p1beta1.PhraseSet"
19
+ end
20
+ add_message "google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest" do
21
+ optional :phrase_set, :message, 1, "google.cloud.speech.v1p1beta1.PhraseSet"
22
+ optional :update_mask, :message, 2, "google.protobuf.FieldMask"
23
+ end
24
+ add_message "google.cloud.speech.v1p1beta1.GetPhraseSetRequest" do
25
+ optional :name, :string, 1
26
+ end
27
+ add_message "google.cloud.speech.v1p1beta1.ListPhraseSetRequest" do
28
+ optional :parent, :string, 1
29
+ optional :page_size, :int32, 2
30
+ optional :page_token, :string, 3
31
+ end
32
+ add_message "google.cloud.speech.v1p1beta1.ListPhraseSetResponse" do
33
+ repeated :phrase_sets, :message, 1, "google.cloud.speech.v1p1beta1.PhraseSet"
34
+ optional :next_page_token, :string, 2
35
+ end
36
+ add_message "google.cloud.speech.v1p1beta1.DeletePhraseSetRequest" do
37
+ optional :name, :string, 1
38
+ end
39
+ add_message "google.cloud.speech.v1p1beta1.CreateCustomClassRequest" do
40
+ optional :parent, :string, 1
41
+ optional :custom_class_id, :string, 2
42
+ optional :custom_class, :message, 3, "google.cloud.speech.v1p1beta1.CustomClass"
43
+ end
44
+ add_message "google.cloud.speech.v1p1beta1.UpdateCustomClassRequest" do
45
+ optional :custom_class, :message, 1, "google.cloud.speech.v1p1beta1.CustomClass"
46
+ optional :update_mask, :message, 2, "google.protobuf.FieldMask"
47
+ end
48
+ add_message "google.cloud.speech.v1p1beta1.GetCustomClassRequest" do
49
+ optional :name, :string, 1
50
+ end
51
+ add_message "google.cloud.speech.v1p1beta1.ListCustomClassesRequest" do
52
+ optional :parent, :string, 1
53
+ optional :page_size, :int32, 2
54
+ optional :page_token, :string, 3
55
+ end
56
+ add_message "google.cloud.speech.v1p1beta1.ListCustomClassesResponse" do
57
+ repeated :custom_classes, :message, 1, "google.cloud.speech.v1p1beta1.CustomClass"
58
+ optional :next_page_token, :string, 2
59
+ end
60
+ add_message "google.cloud.speech.v1p1beta1.DeleteCustomClassRequest" do
61
+ optional :name, :string, 1
62
+ end
63
+ end
64
+ end
65
+
66
+ module Google
67
+ module Cloud
68
+ module Speech
69
+ module V1p1beta1
70
+ CreatePhraseSetRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.CreatePhraseSetRequest").msgclass
71
+ UpdatePhraseSetRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest").msgclass
72
+ GetPhraseSetRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.GetPhraseSetRequest").msgclass
73
+ ListPhraseSetRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.ListPhraseSetRequest").msgclass
74
+ ListPhraseSetResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.ListPhraseSetResponse").msgclass
75
+ DeletePhraseSetRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.DeletePhraseSetRequest").msgclass
76
+ CreateCustomClassRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.CreateCustomClassRequest").msgclass
77
+ UpdateCustomClassRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.UpdateCustomClassRequest").msgclass
78
+ GetCustomClassRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.GetCustomClassRequest").msgclass
79
+ ListCustomClassesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.ListCustomClassesRequest").msgclass
80
+ ListCustomClassesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.ListCustomClassesResponse").msgclass
81
+ DeleteCustomClassRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.speech.v1p1beta1.DeleteCustomClassRequest").msgclass
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,65 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto for package 'google.cloud.speech.v1p1beta1'
3
+ # Original file comments:
4
+ # Copyright 2021 Google LLC
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'grpc'
20
+ require 'google/cloud/speech/v1p1beta1/cloud_speech_adaptation_pb'
21
+
22
+ module Google
23
+ module Cloud
24
+ module Speech
25
+ module V1p1beta1
26
+ module Adaptation
27
+ # Service that implements Google Cloud Speech Adaptation API.
28
+ class Service
29
+
30
+ include GRPC::GenericService
31
+
32
+ self.marshal_class_method = :encode
33
+ self.unmarshal_class_method = :decode
34
+ self.service_name = 'google.cloud.speech.v1p1beta1.Adaptation'
35
+
36
+ # Create a set of phrase hints. Each item in the set can be a single word or
37
+ # a multi-word phrase. The items in the PhraseSet are favored by the
38
+ # recognition model when you send a call that includes the PhraseSet.
39
+ rpc :CreatePhraseSet, ::Google::Cloud::Speech::V1p1beta1::CreatePhraseSetRequest, ::Google::Cloud::Speech::V1p1beta1::PhraseSet
40
+ # Get a phrase set.
41
+ rpc :GetPhraseSet, ::Google::Cloud::Speech::V1p1beta1::GetPhraseSetRequest, ::Google::Cloud::Speech::V1p1beta1::PhraseSet
42
+ # List phrase sets.
43
+ rpc :ListPhraseSet, ::Google::Cloud::Speech::V1p1beta1::ListPhraseSetRequest, ::Google::Cloud::Speech::V1p1beta1::ListPhraseSetResponse
44
+ # Update a phrase set.
45
+ rpc :UpdatePhraseSet, ::Google::Cloud::Speech::V1p1beta1::UpdatePhraseSetRequest, ::Google::Cloud::Speech::V1p1beta1::PhraseSet
46
+ # Delete a phrase set.
47
+ rpc :DeletePhraseSet, ::Google::Cloud::Speech::V1p1beta1::DeletePhraseSetRequest, ::Google::Protobuf::Empty
48
+ # Create a custom class.
49
+ rpc :CreateCustomClass, ::Google::Cloud::Speech::V1p1beta1::CreateCustomClassRequest, ::Google::Cloud::Speech::V1p1beta1::CustomClass
50
+ # Get a custom class.
51
+ rpc :GetCustomClass, ::Google::Cloud::Speech::V1p1beta1::GetCustomClassRequest, ::Google::Cloud::Speech::V1p1beta1::CustomClass
52
+ # List custom classes.
53
+ rpc :ListCustomClasses, ::Google::Cloud::Speech::V1p1beta1::ListCustomClassesRequest, ::Google::Cloud::Speech::V1p1beta1::ListCustomClassesResponse
54
+ # Update a custom class.
55
+ rpc :UpdateCustomClass, ::Google::Cloud::Speech::V1p1beta1::UpdateCustomClassRequest, ::Google::Cloud::Speech::V1p1beta1::CustomClass
56
+ # Delete a custom class.
57
+ rpc :DeleteCustomClass, ::Google::Cloud::Speech::V1p1beta1::DeleteCustomClassRequest, ::Google::Protobuf::Empty
58
+ end
59
+
60
+ Stub = Service.rpc_stub_class
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -35,17 +35,17 @@ module Google
35
35
 
36
36
  # Performs synchronous speech recognition: receive results after all audio
37
37
  # has been sent and processed.
38
- rpc :Recognize, Google::Cloud::Speech::V1p1beta1::RecognizeRequest, Google::Cloud::Speech::V1p1beta1::RecognizeResponse
38
+ rpc :Recognize, ::Google::Cloud::Speech::V1p1beta1::RecognizeRequest, ::Google::Cloud::Speech::V1p1beta1::RecognizeResponse
39
39
  # Performs asynchronous speech recognition: receive results via the
40
40
  # google.longrunning.Operations interface. Returns either an
41
41
  # `Operation.error` or an `Operation.response` which contains
42
42
  # a `LongRunningRecognizeResponse` message.
43
43
  # For more information on asynchronous speech recognition, see the
44
44
  # [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
45
- rpc :LongRunningRecognize, Google::Cloud::Speech::V1p1beta1::LongRunningRecognizeRequest, Google::Longrunning::Operation
45
+ rpc :LongRunningRecognize, ::Google::Cloud::Speech::V1p1beta1::LongRunningRecognizeRequest, ::Google::Longrunning::Operation
46
46
  # Performs bidirectional streaming speech recognition: receive results while
47
47
  # sending audio. This method is only available via the gRPC API (not REST).
48
- rpc :StreamingRecognize, stream(Google::Cloud::Speech::V1p1beta1::StreamingRecognizeRequest), stream(Google::Cloud::Speech::V1p1beta1::StreamingRecognizeResponse)
48
+ rpc :StreamingRecognize, stream(::Google::Cloud::Speech::V1p1beta1::StreamingRecognizeRequest), stream(::Google::Cloud::Speech::V1p1beta1::StreamingRecognizeResponse)
49
49
  end
50
50
 
51
51
  Stub = Service.rpc_stub_class
@@ -3,8 +3,8 @@
3
3
 
4
4
  require 'google/protobuf'
5
5
 
6
- require 'google/api/annotations_pb'
7
6
  require 'google/api/resource_pb'
7
+ require 'google/api/annotations_pb'
8
8
  Google::Protobuf::DescriptorPool.generated_pool.build do
9
9
  add_file("google/cloud/speech/v1p1beta1/resource.proto", :syntax => :proto3) do
10
10
  add_message "google.cloud.speech.v1p1beta1.CustomClass" do
@@ -26,7 +26,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
26
26
  end
27
27
  add_message "google.cloud.speech.v1p1beta1.SpeechAdaptation" do
28
28
  repeated :phrase_sets, :message, 1, "google.cloud.speech.v1p1beta1.PhraseSet"
29
- repeated :custom_classes, :message, 2, "google.cloud.speech.v1p1beta1.CustomClass"
29
+ repeated :phrase_set_references, :string, 2
30
+ repeated :custom_classes, :message, 3, "google.cloud.speech.v1p1beta1.CustomClass"
30
31
  end
31
32
  end
32
33
  end
@@ -60,7 +60,7 @@ module Google
60
60
  parent_config = while namespace.any?
61
61
  parent_name = namespace.join "::"
62
62
  parent_const = const_get parent_name
63
- break parent_const.configure if parent_const&.respond_to? :configure
63
+ break parent_const.configure if parent_const.respond_to? :configure
64
64
  namespace.pop
65
65
  end
66
66
  default_config = Client::Configuration.new parent_config
@@ -68,9 +68,9 @@ module Google
68
68
  default_config.rpcs.recognize.timeout = 5000.0
69
69
  default_config.rpcs.recognize.retry_policy = {
70
70
  initial_delay: 0.1,
71
- max_delay: 60.0,
72
- multiplier: 1.3,
73
- retry_codes: [4, 14]
71
+ max_delay: 60.0,
72
+ multiplier: 1.3,
73
+ retry_codes: [4, 14]
74
74
  }
75
75
 
76
76
  default_config.rpcs.long_running_recognize.timeout = 5000.0
@@ -78,9 +78,9 @@ module Google
78
78
  default_config.rpcs.streaming_recognize.timeout = 5000.0
79
79
  default_config.rpcs.streaming_recognize.retry_policy = {
80
80
  initial_delay: 0.1,
81
- max_delay: 60.0,
82
- multiplier: 1.3,
83
- retry_codes: [4, 14]
81
+ max_delay: 60.0,
82
+ multiplier: 1.3,
83
+ retry_codes: [4, 14]
84
84
  }
85
85
 
86
86
  default_config
@@ -144,7 +144,13 @@ module Google
144
144
 
145
145
  # Create credentials
146
146
  credentials = @config.credentials
147
- credentials ||= Credentials.default scope: @config.scope
147
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
148
+ # but only if the default endpoint does not have a region prefix.
149
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
150
+ @config.endpoint == Client.configure.endpoint &&
151
+ !@config.endpoint.split(".").first.include?("-")
152
+ credentials ||= Credentials.default scope: @config.scope,
153
+ enable_self_signed_jwt: enable_self_signed_jwt
148
154
  if credentials.is_a?(String) || credentials.is_a?(Hash)
149
155
  credentials = Credentials.new credentials, scope: @config.scope
150
156
  end
@@ -445,14 +451,14 @@ module Google
445
451
 
446
452
  config_attr :endpoint, "speech.googleapis.com", ::String
447
453
  config_attr :credentials, nil do |value|
448
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
454
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
449
455
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
450
456
  allowed.any? { |klass| klass === value }
451
457
  end
452
458
  config_attr :scope, nil, ::String, ::Array, nil
453
459
  config_attr :lib_name, nil, ::String, nil
454
460
  config_attr :lib_version, nil, ::String, nil
455
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
461
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
456
462
  config_attr :interceptors, nil, ::Array, nil
457
463
  config_attr :timeout, nil, ::Numeric, nil
458
464
  config_attr :metadata, nil, ::Hash, nil
@@ -473,7 +479,7 @@ module Google
473
479
  def rpcs
474
480
  @rpcs ||= begin
475
481
  parent_rpcs = nil
476
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
482
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
477
483
  Rpcs.new parent_rpcs
478
484
  end
479
485
  end
@@ -485,7 +491,7 @@ module Google
485
491
  # Each configuration object is of type `Gapic::Config::Method` and includes
486
492
  # the following configuration fields:
487
493
  #
488
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
494
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
489
495
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
490
496
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
491
497
  # include the following keys:
@@ -514,11 +520,11 @@ module Google
514
520
 
515
521
  # @private
516
522
  def initialize parent_rpcs = nil
517
- recognize_config = parent_rpcs&.recognize if parent_rpcs&.respond_to? :recognize
523
+ recognize_config = parent_rpcs.recognize if parent_rpcs.respond_to? :recognize
518
524
  @recognize = ::Gapic::Config::Method.new recognize_config
519
- long_running_recognize_config = parent_rpcs&.long_running_recognize if parent_rpcs&.respond_to? :long_running_recognize
525
+ long_running_recognize_config = parent_rpcs.long_running_recognize if parent_rpcs.respond_to? :long_running_recognize
520
526
  @long_running_recognize = ::Gapic::Config::Method.new long_running_recognize_config
521
- streaming_recognize_config = parent_rpcs&.streaming_recognize if parent_rpcs&.respond_to? :streaming_recognize
527
+ streaming_recognize_config = parent_rpcs.streaming_recognize if parent_rpcs.respond_to? :streaming_recognize
522
528
  @streaming_recognize = ::Gapic::Config::Method.new streaming_recognize_config
523
529
 
524
530
  yield self if block_given?
@@ -103,8 +103,13 @@ module Google
103
103
  # Lists operations that match the specified filter in the request. If the
104
104
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
105
105
  #
106
- # NOTE: the `name` binding below allows API services to override the binding
107
- # to use different resource name schemes, such as `users/*/operations`.
106
+ # NOTE: the `name` binding allows API services to override the binding
107
+ # to use different resource name schemes, such as `users/*/operations`. To
108
+ # override the binding, API services can add a binding such as
109
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
110
+ # For backwards compatibility, the default name includes the operations
111
+ # collection id, however overriding users must ensure the name binding
112
+ # is the parent resource, without the operations collection id.
108
113
  #
109
114
  # @overload list_operations(request, options = nil)
110
115
  # Pass arguments to `list_operations` via a request object, either of type
@@ -122,7 +127,7 @@ module Google
122
127
  # the default parameter values, pass an empty Hash as a request object (see above).
123
128
  #
124
129
  # @param name [::String]
125
- # The name of the operation collection.
130
+ # The name of the operation's parent resource.
126
131
  # @param filter [::String]
127
132
  # The standard list filter.
128
133
  # @param page_size [::Integer]
@@ -390,6 +395,79 @@ module Google
390
395
  raise ::Google::Cloud::Error.from_error(e)
391
396
  end
392
397
 
398
+ ##
399
+ # Waits for the specified long-running operation until it is done or reaches
400
+ # at most a specified timeout, returning the latest state. If the operation
401
+ # is already done, the latest state is immediately returned. If the timeout
402
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
403
+ # timeout is used. If the server does not support this method, it returns
404
+ # `google.rpc.Code.UNIMPLEMENTED`.
405
+ # Note that this method is on a best-effort basis. It may return the latest
406
+ # state before the specified timeout (including immediately), meaning even an
407
+ # immediate response is no guarantee that the operation is done.
408
+ #
409
+ # @overload wait_operation(request, options = nil)
410
+ # Pass arguments to `wait_operation` via a request object, either of type
411
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
412
+ #
413
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
414
+ # A request object representing the call parameters. Required. To specify no
415
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
416
+ # @param options [::Gapic::CallOptions, ::Hash]
417
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
418
+ #
419
+ # @overload wait_operation(name: nil, timeout: nil)
420
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
421
+ # least one keyword argument is required. To specify no parameters, or to keep all
422
+ # the default parameter values, pass an empty Hash as a request object (see above).
423
+ #
424
+ # @param name [::String]
425
+ # The name of the operation resource to wait on.
426
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
427
+ # The maximum duration to wait before timing out. If left blank, the wait
428
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
429
+ # If RPC context deadline is also specified, the shorter one will be used.
430
+ #
431
+ # @yield [response, operation] Access the result along with the RPC operation
432
+ # @yieldparam response [::Gapic::Operation]
433
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
434
+ #
435
+ # @return [::Gapic::Operation]
436
+ #
437
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
438
+ #
439
+ def wait_operation request, options = nil
440
+ raise ::ArgumentError, "request must be provided" if request.nil?
441
+
442
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
443
+
444
+ # Converts hash and nil to an options object
445
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
446
+
447
+ # Customize the options with defaults
448
+ metadata = @config.rpcs.wait_operation.metadata.to_h
449
+
450
+ # Set x-goog-api-client and x-goog-user-project headers
451
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
452
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
453
+ gapic_version: ::Google::Cloud::Speech::V1p1beta1::VERSION
454
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
455
+
456
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
457
+ metadata: metadata,
458
+ retry_policy: @config.rpcs.wait_operation.retry_policy
459
+ options.apply_defaults metadata: @config.metadata,
460
+ retry_policy: @config.retry_policy
461
+
462
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
463
+ response = ::Gapic::Operation.new response, @operations_client, options: options
464
+ yield response, operation if block_given?
465
+ return response
466
+ end
467
+ rescue ::GRPC::BadStatus => e
468
+ raise ::Google::Cloud::Error.from_error(e)
469
+ end
470
+
393
471
  ##
394
472
  # Configuration class for the Operations API.
395
473
  #
@@ -475,14 +553,14 @@ module Google
475
553
 
476
554
  config_attr :endpoint, "speech.googleapis.com", ::String
477
555
  config_attr :credentials, nil do |value|
478
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
556
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
479
557
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
480
558
  allowed.any? { |klass| klass === value }
481
559
  end
482
560
  config_attr :scope, nil, ::String, ::Array, nil
483
561
  config_attr :lib_name, nil, ::String, nil
484
562
  config_attr :lib_version, nil, ::String, nil
485
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
563
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
486
564
  config_attr :interceptors, nil, ::Array, nil
487
565
  config_attr :timeout, nil, ::Numeric, nil
488
566
  config_attr :metadata, nil, ::Hash, nil
@@ -503,7 +581,7 @@ module Google
503
581
  def rpcs
504
582
  @rpcs ||= begin
505
583
  parent_rpcs = nil
506
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
584
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
507
585
  Rpcs.new parent_rpcs
508
586
  end
509
587
  end
@@ -515,7 +593,7 @@ module Google
515
593
  # Each configuration object is of type `Gapic::Config::Method` and includes
516
594
  # the following configuration fields:
517
595
  #
518
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
596
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
519
597
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
520
598
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
521
599
  # include the following keys:
@@ -546,17 +624,24 @@ module Google
546
624
  # @return [::Gapic::Config::Method]
547
625
  #
548
626
  attr_reader :cancel_operation
627
+ ##
628
+ # RPC-specific configuration for `wait_operation`
629
+ # @return [::Gapic::Config::Method]
630
+ #
631
+ attr_reader :wait_operation
549
632
 
550
633
  # @private
551
634
  def initialize parent_rpcs = nil
552
- list_operations_config = parent_rpcs&.list_operations if parent_rpcs&.respond_to? :list_operations
635
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
553
636
  @list_operations = ::Gapic::Config::Method.new list_operations_config
554
- get_operation_config = parent_rpcs&.get_operation if parent_rpcs&.respond_to? :get_operation
637
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
555
638
  @get_operation = ::Gapic::Config::Method.new get_operation_config
556
- delete_operation_config = parent_rpcs&.delete_operation if parent_rpcs&.respond_to? :delete_operation
639
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
557
640
  @delete_operation = ::Gapic::Config::Method.new delete_operation_config
558
- cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
641
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
559
642
  @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
643
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
644
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
560
645
 
561
646
  yield self if block_given?
562
647
  end