google-cloud-dialogflow-v2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +24 -0
  6. data/lib/google-cloud-dialogflow-v2.rb +1 -0
  7. data/lib/google/cloud/common_resources_pb.rb +15 -0
  8. data/lib/google/cloud/dialogflow/v2.rb +24 -0
  9. data/lib/google/cloud/dialogflow/v2/agent_pb.rb +122 -0
  10. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +110 -0
  11. data/lib/google/cloud/dialogflow/v2/agents.rb +21 -0
  12. data/lib/google/cloud/dialogflow/v2/agents/client.rb +1047 -0
  13. data/lib/google/cloud/dialogflow/v2/agents/credentials.rb +53 -0
  14. data/lib/google/cloud/dialogflow/v2/agents/operations.rb +559 -0
  15. data/lib/google/cloud/dialogflow/v2/agents/paths.rb +59 -0
  16. data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +97 -0
  17. data/lib/google/cloud/dialogflow/v2/context_pb.rb +64 -0
  18. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +74 -0
  19. data/lib/google/cloud/dialogflow/v2/contexts.rb +20 -0
  20. data/lib/google/cloud/dialogflow/v2/contexts/client.rb +756 -0
  21. data/lib/google/cloud/dialogflow/v2/contexts/credentials.rb +53 -0
  22. data/lib/google/cloud/dialogflow/v2/contexts/paths.rb +50 -0
  23. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +126 -0
  24. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +104 -0
  25. data/lib/google/cloud/dialogflow/v2/entity_types.rb +21 -0
  26. data/lib/google/cloud/dialogflow/v2/entity_types/client.rb +1150 -0
  27. data/lib/google/cloud/dialogflow/v2/entity_types/credentials.rb +53 -0
  28. data/lib/google/cloud/dialogflow/v2/entity_types/operations.rb +559 -0
  29. data/lib/google/cloud/dialogflow/v2/entity_types/paths.rb +62 -0
  30. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +368 -0
  31. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +92 -0
  32. data/lib/google/cloud/dialogflow/v2/intents.rb +21 -0
  33. data/lib/google/cloud/dialogflow/v2/intents/client.rb +893 -0
  34. data/lib/google/cloud/dialogflow/v2/intents/credentials.rb +53 -0
  35. data/lib/google/cloud/dialogflow/v2/intents/operations.rb +559 -0
  36. data/lib/google/cloud/dialogflow/v2/intents/paths.rb +81 -0
  37. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +66 -0
  38. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +92 -0
  39. data/lib/google/cloud/dialogflow/v2/session_entity_types.rb +20 -0
  40. data/lib/google/cloud/dialogflow/v2/session_entity_types/client.rb +727 -0
  41. data/lib/google/cloud/dialogflow/v2/session_entity_types/credentials.rb +53 -0
  42. data/lib/google/cloud/dialogflow/v2/session_entity_types/paths.rb +69 -0
  43. data/lib/google/cloud/dialogflow/v2/session_pb.rb +142 -0
  44. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +55 -0
  45. data/lib/google/cloud/dialogflow/v2/sessions.rb +20 -0
  46. data/lib/google/cloud/dialogflow/v2/sessions/client.rb +472 -0
  47. data/lib/google/cloud/dialogflow/v2/sessions/credentials.rb +53 -0
  48. data/lib/google/cloud/dialogflow/v2/sessions/paths.rb +110 -0
  49. data/lib/google/cloud/dialogflow/v2/validation_result_pb.rb +37 -0
  50. data/lib/google/cloud/dialogflow/v2/version.rb +28 -0
  51. data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +47 -0
  52. data/proto_docs/README.md +4 -0
  53. data/proto_docs/google/api/field_behavior.rb +59 -0
  54. data/proto_docs/google/api/resource.rb +247 -0
  55. data/proto_docs/google/cloud/dialogflow/v2/agent.rb +287 -0
  56. data/proto_docs/google/cloud/dialogflow/v2/audio_config.rb +363 -0
  57. data/proto_docs/google/cloud/dialogflow/v2/context.rb +144 -0
  58. data/proto_docs/google/cloud/dialogflow/v2/entity_type.rb +354 -0
  59. data/proto_docs/google/cloud/dialogflow/v2/intent.rb +1070 -0
  60. data/proto_docs/google/cloud/dialogflow/v2/session.rb +541 -0
  61. data/proto_docs/google/cloud/dialogflow/v2/session_entity_type.rb +155 -0
  62. data/proto_docs/google/cloud/dialogflow/v2/validation_result.rb +81 -0
  63. data/proto_docs/google/cloud/dialogflow/v2/webhook.rb +153 -0
  64. data/proto_docs/google/longrunning/operations.rb +150 -0
  65. data/proto_docs/google/protobuf/any.rb +137 -0
  66. data/proto_docs/google/protobuf/duration.rb +98 -0
  67. data/proto_docs/google/protobuf/empty.rb +36 -0
  68. data/proto_docs/google/protobuf/field_mask.rb +237 -0
  69. data/proto_docs/google/protobuf/struct.rb +96 -0
  70. data/proto_docs/google/rpc/status.rb +46 -0
  71. data/proto_docs/google/type/latlng.rb +38 -0
  72. metadata +225 -0
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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
+
22
+ module Google
23
+ module Cloud
24
+ module Dialogflow
25
+ module V2
26
+ module SessionEntityTypes
27
+ # Credentials for the SessionEntityTypes API.
28
+ class Credentials < Google::Auth::Credentials
29
+ self.scope = [
30
+ "https://www.googleapis.com/auth/cloud-platform",
31
+ "https://www.googleapis.com/auth/dialogflow"
32
+ ]
33
+ self.env_vars = [
34
+ "DIALOGFLOW_CREDENTIALS",
35
+ "DIALOGFLOW_KEYFILE",
36
+ "GOOGLE_CLOUD_CREDENTIALS",
37
+ "GOOGLE_CLOUD_KEYFILE",
38
+ "GCLOUD_KEYFILE",
39
+ "DIALOGFLOW_CREDENTIALS_JSON",
40
+ "DIALOGFLOW_KEYFILE_JSON",
41
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
42
+ "GOOGLE_CLOUD_KEYFILE_JSON",
43
+ "GCLOUD_KEYFILE_JSON"
44
+ ]
45
+ self.paths = [
46
+ "~/.config/google_cloud/application_default_credentials.json"
47
+ ]
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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 Dialogflow
23
+ module V2
24
+ module SessionEntityTypes
25
+ # Path helper methods for the SessionEntityTypes API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Context resource string.
29
+ #
30
+ # The resource will be in the following format:
31
+ #
32
+ # `projects/{project}/agent/sessions/{session}/contexts/{context}`
33
+ #
34
+ # @param project [String]
35
+ # @param session [String]
36
+ # @param context [String]
37
+ #
38
+ # @return [String]
39
+ def context_path project:, session:, context:
40
+ raise ArgumentError, "project cannot contain /" if project.to_s.include? "/"
41
+ raise ArgumentError, "session cannot contain /" if session.to_s.include? "/"
42
+
43
+ "projects/#{project}/agent/sessions/#{session}/contexts/#{context}"
44
+ end
45
+
46
+ ##
47
+ # Create a fully-qualified SessionEntityType resource string.
48
+ #
49
+ # The resource will be in the following format:
50
+ #
51
+ # `projects/{project}/agent/sessions/{session}/entityTypes/{entity_type}`
52
+ #
53
+ # @param project [String]
54
+ # @param session [String]
55
+ # @param entity_type [String]
56
+ #
57
+ # @return [String]
58
+ def session_entity_type_path project:, session:, entity_type:
59
+ raise ArgumentError, "project cannot contain /" if project.to_s.include? "/"
60
+ raise ArgumentError, "session cannot contain /" if session.to_s.include? "/"
61
+
62
+ "projects/#{project}/agent/sessions/#{session}/entityTypes/#{entity_type}"
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,142 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/dialogflow/v2/session.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/dialogflow/v2/audio_config_pb'
11
+ require 'google/cloud/dialogflow/v2/context_pb'
12
+ require 'google/cloud/dialogflow/v2/intent_pb'
13
+ require 'google/cloud/dialogflow/v2/session_entity_type_pb'
14
+ require 'google/protobuf/duration_pb'
15
+ require 'google/protobuf/field_mask_pb'
16
+ require 'google/protobuf/struct_pb'
17
+ require 'google/rpc/status_pb'
18
+ require 'google/type/latlng_pb'
19
+ Google::Protobuf::DescriptorPool.generated_pool.build do
20
+ add_file("google/cloud/dialogflow/v2/session.proto", :syntax => :proto3) do
21
+ add_message "google.cloud.dialogflow.v2.DetectIntentRequest" do
22
+ optional :session, :string, 1
23
+ optional :query_params, :message, 2, "google.cloud.dialogflow.v2.QueryParameters"
24
+ optional :query_input, :message, 3, "google.cloud.dialogflow.v2.QueryInput"
25
+ optional :output_audio_config, :message, 4, "google.cloud.dialogflow.v2.OutputAudioConfig"
26
+ optional :output_audio_config_mask, :message, 7, "google.protobuf.FieldMask"
27
+ optional :input_audio, :bytes, 5
28
+ end
29
+ add_message "google.cloud.dialogflow.v2.DetectIntentResponse" do
30
+ optional :response_id, :string, 1
31
+ optional :query_result, :message, 2, "google.cloud.dialogflow.v2.QueryResult"
32
+ optional :webhook_status, :message, 3, "google.rpc.Status"
33
+ optional :output_audio, :bytes, 4
34
+ optional :output_audio_config, :message, 6, "google.cloud.dialogflow.v2.OutputAudioConfig"
35
+ end
36
+ add_message "google.cloud.dialogflow.v2.QueryParameters" do
37
+ optional :time_zone, :string, 1
38
+ optional :geo_location, :message, 2, "google.type.LatLng"
39
+ repeated :contexts, :message, 3, "google.cloud.dialogflow.v2.Context"
40
+ optional :reset_contexts, :bool, 4
41
+ repeated :session_entity_types, :message, 5, "google.cloud.dialogflow.v2.SessionEntityType"
42
+ optional :payload, :message, 6, "google.protobuf.Struct"
43
+ optional :sentiment_analysis_request_config, :message, 10, "google.cloud.dialogflow.v2.SentimentAnalysisRequestConfig"
44
+ end
45
+ add_message "google.cloud.dialogflow.v2.QueryInput" do
46
+ oneof :input do
47
+ optional :audio_config, :message, 1, "google.cloud.dialogflow.v2.InputAudioConfig"
48
+ optional :text, :message, 2, "google.cloud.dialogflow.v2.TextInput"
49
+ optional :event, :message, 3, "google.cloud.dialogflow.v2.EventInput"
50
+ end
51
+ end
52
+ add_message "google.cloud.dialogflow.v2.QueryResult" do
53
+ optional :query_text, :string, 1
54
+ optional :language_code, :string, 15
55
+ optional :speech_recognition_confidence, :float, 2
56
+ optional :action, :string, 3
57
+ optional :parameters, :message, 4, "google.protobuf.Struct"
58
+ optional :all_required_params_present, :bool, 5
59
+ optional :fulfillment_text, :string, 6
60
+ repeated :fulfillment_messages, :message, 7, "google.cloud.dialogflow.v2.Intent.Message"
61
+ optional :webhook_source, :string, 8
62
+ optional :webhook_payload, :message, 9, "google.protobuf.Struct"
63
+ repeated :output_contexts, :message, 10, "google.cloud.dialogflow.v2.Context"
64
+ optional :intent, :message, 11, "google.cloud.dialogflow.v2.Intent"
65
+ optional :intent_detection_confidence, :float, 12
66
+ optional :diagnostic_info, :message, 14, "google.protobuf.Struct"
67
+ optional :sentiment_analysis_result, :message, 17, "google.cloud.dialogflow.v2.SentimentAnalysisResult"
68
+ end
69
+ add_message "google.cloud.dialogflow.v2.StreamingDetectIntentRequest" do
70
+ optional :session, :string, 1
71
+ optional :query_params, :message, 2, "google.cloud.dialogflow.v2.QueryParameters"
72
+ optional :query_input, :message, 3, "google.cloud.dialogflow.v2.QueryInput"
73
+ optional :single_utterance, :bool, 4
74
+ optional :output_audio_config, :message, 5, "google.cloud.dialogflow.v2.OutputAudioConfig"
75
+ optional :output_audio_config_mask, :message, 7, "google.protobuf.FieldMask"
76
+ optional :input_audio, :bytes, 6
77
+ end
78
+ add_message "google.cloud.dialogflow.v2.StreamingDetectIntentResponse" do
79
+ optional :response_id, :string, 1
80
+ optional :recognition_result, :message, 2, "google.cloud.dialogflow.v2.StreamingRecognitionResult"
81
+ optional :query_result, :message, 3, "google.cloud.dialogflow.v2.QueryResult"
82
+ optional :webhook_status, :message, 4, "google.rpc.Status"
83
+ optional :output_audio, :bytes, 5
84
+ optional :output_audio_config, :message, 6, "google.cloud.dialogflow.v2.OutputAudioConfig"
85
+ end
86
+ add_message "google.cloud.dialogflow.v2.StreamingRecognitionResult" do
87
+ optional :message_type, :enum, 1, "google.cloud.dialogflow.v2.StreamingRecognitionResult.MessageType"
88
+ optional :transcript, :string, 2
89
+ optional :is_final, :bool, 3
90
+ optional :confidence, :float, 4
91
+ repeated :speech_word_info, :message, 7, "google.cloud.dialogflow.v2.SpeechWordInfo"
92
+ optional :speech_end_offset, :message, 8, "google.protobuf.Duration"
93
+ end
94
+ add_enum "google.cloud.dialogflow.v2.StreamingRecognitionResult.MessageType" do
95
+ value :MESSAGE_TYPE_UNSPECIFIED, 0
96
+ value :TRANSCRIPT, 1
97
+ value :END_OF_SINGLE_UTTERANCE, 2
98
+ end
99
+ add_message "google.cloud.dialogflow.v2.TextInput" do
100
+ optional :text, :string, 1
101
+ optional :language_code, :string, 2
102
+ end
103
+ add_message "google.cloud.dialogflow.v2.EventInput" do
104
+ optional :name, :string, 1
105
+ optional :parameters, :message, 2, "google.protobuf.Struct"
106
+ optional :language_code, :string, 3
107
+ end
108
+ add_message "google.cloud.dialogflow.v2.SentimentAnalysisRequestConfig" do
109
+ optional :analyze_query_text_sentiment, :bool, 1
110
+ end
111
+ add_message "google.cloud.dialogflow.v2.SentimentAnalysisResult" do
112
+ optional :query_text_sentiment, :message, 1, "google.cloud.dialogflow.v2.Sentiment"
113
+ end
114
+ add_message "google.cloud.dialogflow.v2.Sentiment" do
115
+ optional :score, :float, 1
116
+ optional :magnitude, :float, 2
117
+ end
118
+ end
119
+ end
120
+
121
+ module Google
122
+ module Cloud
123
+ module Dialogflow
124
+ module V2
125
+ DetectIntentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DetectIntentRequest").msgclass
126
+ DetectIntentResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DetectIntentResponse").msgclass
127
+ QueryParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.QueryParameters").msgclass
128
+ QueryInput = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.QueryInput").msgclass
129
+ QueryResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.QueryResult").msgclass
130
+ StreamingDetectIntentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.StreamingDetectIntentRequest").msgclass
131
+ StreamingDetectIntentResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.StreamingDetectIntentResponse").msgclass
132
+ StreamingRecognitionResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.StreamingRecognitionResult").msgclass
133
+ StreamingRecognitionResult::MessageType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.StreamingRecognitionResult.MessageType").enummodule
134
+ TextInput = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.TextInput").msgclass
135
+ EventInput = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.EventInput").msgclass
136
+ SentimentAnalysisRequestConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SentimentAnalysisRequestConfig").msgclass
137
+ SentimentAnalysisResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SentimentAnalysisResult").msgclass
138
+ Sentiment = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Sentiment").msgclass
139
+ end
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,55 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/cloud/dialogflow/v2/session.proto for package 'google.cloud.dialogflow.v2'
3
+ # Original file comments:
4
+ # Copyright 2020 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/dialogflow/v2/session_pb'
21
+
22
+ module Google
23
+ module Cloud
24
+ module Dialogflow
25
+ module V2
26
+ module Sessions
27
+ # A session represents an interaction with a user. You retrieve user input
28
+ # and pass it to the [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or
29
+ # [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) method to determine
30
+ # user intent and respond.
31
+ class Service
32
+
33
+ include GRPC::GenericService
34
+
35
+ self.marshal_class_method = :encode
36
+ self.unmarshal_class_method = :decode
37
+ self.service_name = 'google.cloud.dialogflow.v2.Sessions'
38
+
39
+ # Processes a natural language query and returns structured, actionable data
40
+ # as a result. This method is not idempotent, because it may cause contexts
41
+ # and session entity types to be updated, which in turn might affect
42
+ # results of future queries.
43
+ rpc :DetectIntent, DetectIntentRequest, DetectIntentResponse
44
+ # Processes a natural language query in audio format in a streaming fashion
45
+ # and returns structured, actionable data as a result. This method is only
46
+ # available via the gRPC API (not REST).
47
+ rpc :StreamingDetectIntent, stream(StreamingDetectIntentRequest), stream(StreamingDetectIntentResponse)
48
+ end
49
+
50
+ Stub = Service.rpc_stub_class
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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 "google/cloud/dialogflow/v2/sessions/client"
20
+ require "google/cloud/dialogflow/v2/sessions/credentials"
@@ -0,0 +1,472 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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 "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/errors"
24
+ require "google/cloud/dialogflow/v2/version"
25
+ require "google/cloud/dialogflow/v2/session_pb"
26
+ require "google/cloud/dialogflow/v2/sessions/credentials"
27
+ require "google/cloud/dialogflow/v2/sessions/paths"
28
+
29
+
30
+ module Google
31
+ module Cloud
32
+ module Dialogflow
33
+ module V2
34
+ module Sessions
35
+ # Service that implements Sessions API.
36
+ class Client
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :sessions_stub
41
+
42
+ ##
43
+ # Configure the Sessions Client class.
44
+ #
45
+ # See {Google::Cloud::Dialogflow::V2::Sessions::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # ## Example
49
+ #
50
+ # To modify the configuration for all Sessions clients:
51
+ #
52
+ # Google::Cloud::Dialogflow::V2::Sessions::Client.configure do |config|
53
+ # config.timeout = 10_000
54
+ # end
55
+ #
56
+ # @yield [config] Configure the Client client.
57
+ # @yieldparam config [Client::Configuration]
58
+ #
59
+ # @return [Client::Configuration]
60
+ #
61
+ def self.configure
62
+ @configure ||= begin
63
+ namespace = ["Google", "Cloud", "Dialogflow", "V2"]
64
+ parent_config = while namespace.any?
65
+ parent_name = namespace.join "::"
66
+ parent_const = const_get parent_name
67
+ break parent_const.configure if parent_const&.respond_to? :configure
68
+ namespace.pop
69
+ end
70
+ default_config = Client::Configuration.new parent_config
71
+
72
+ default_config.rpcs.detect_intent.timeout = 220.0
73
+
74
+ default_config.rpcs.streaming_detect_intent.timeout = 220.0
75
+
76
+ default_config
77
+ end
78
+ yield @configure if block_given?
79
+ @configure
80
+ end
81
+
82
+ ##
83
+ # Configure the Sessions Client instance.
84
+ #
85
+ # The configuration is set to the derived mode, meaning that values can be changed,
86
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
87
+ # should be made on {Client.configure}.
88
+ #
89
+ # See {Google::Cloud::Dialogflow::V2::Sessions::Client::Configuration}
90
+ # for a description of the configuration fields.
91
+ #
92
+ # @yield [config] Configure the Client client.
93
+ # @yieldparam config [Client::Configuration]
94
+ #
95
+ # @return [Client::Configuration]
96
+ #
97
+ def configure
98
+ yield @config if block_given?
99
+ @config
100
+ end
101
+
102
+ ##
103
+ # Create a new Sessions client object.
104
+ #
105
+ # ## Examples
106
+ #
107
+ # To create a new Sessions client with the default
108
+ # configuration:
109
+ #
110
+ # client = Google::Cloud::Dialogflow::V2::Sessions::Client.new
111
+ #
112
+ # To create a new Sessions client with a custom
113
+ # configuration:
114
+ #
115
+ # client = Google::Cloud::Dialogflow::V2::Sessions::Client.new do |config|
116
+ # config.timeout = 10_000
117
+ # end
118
+ #
119
+ # @yield [config] Configure the Sessions client.
120
+ # @yieldparam config [Client::Configuration]
121
+ #
122
+ def initialize
123
+ # These require statements are intentionally placed here to initialize
124
+ # the gRPC module only when it's required.
125
+ # See https://github.com/googleapis/toolkit/issues/446
126
+ require "gapic/grpc"
127
+ require "google/cloud/dialogflow/v2/session_services_pb"
128
+
129
+ # Create the configuration object
130
+ @config = Configuration.new Client.configure
131
+
132
+ # Yield the configuration if needed
133
+ yield @config if block_given?
134
+
135
+ # Create credentials
136
+ credentials = @config.credentials
137
+ credentials ||= Credentials.default scope: @config.scope
138
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
139
+ credentials = Credentials.new credentials, scope: @config.scope
140
+ end
141
+ @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
142
+
143
+ @sessions_stub = Gapic::ServiceStub.new(
144
+ Google::Cloud::Dialogflow::V2::Sessions::Stub,
145
+ credentials: credentials,
146
+ endpoint: @config.endpoint,
147
+ channel_args: @config.channel_args,
148
+ interceptors: @config.interceptors
149
+ )
150
+ end
151
+
152
+ # Service calls
153
+
154
+ ##
155
+ # Processes a natural language query and returns structured, actionable data
156
+ # as a result. This method is not idempotent, because it may cause contexts
157
+ # and session entity types to be updated, which in turn might affect
158
+ # results of future queries.
159
+ #
160
+ # @overload detect_intent(request, options = nil)
161
+ # @param request [Google::Cloud::Dialogflow::V2::DetectIntentRequest | Hash]
162
+ # Processes a natural language query and returns structured, actionable data
163
+ # as a result. This method is not idempotent, because it may cause contexts
164
+ # and session entity types to be updated, which in turn might affect
165
+ # results of future queries.
166
+ # @param options [Gapic::CallOptions, Hash]
167
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
168
+ #
169
+ # @overload detect_intent(session: nil, query_params: nil, query_input: nil, output_audio_config: nil, output_audio_config_mask: nil, input_audio: nil)
170
+ # @param session [String]
171
+ # Required. The name of the session this query is sent to. Format:
172
+ # `projects/<Project ID>/agent/sessions/<Session ID>`. It's up to the API
173
+ # caller to choose an appropriate session ID. It can be a random number or
174
+ # some type of user identifier (preferably hashed). The length of the session
175
+ # ID must not exceed 36 bytes.
176
+ # @param query_params [Google::Cloud::Dialogflow::V2::QueryParameters | Hash]
177
+ # The parameters of this query.
178
+ # @param query_input [Google::Cloud::Dialogflow::V2::QueryInput | Hash]
179
+ # Required. The input specification. It can be set to:
180
+ #
181
+ # 1. an audio config
182
+ # which instructs the speech recognizer how to process the speech audio,
183
+ #
184
+ # 2. a conversational query in the form of text, or
185
+ #
186
+ # 3. an event that specifies which intent to trigger.
187
+ # @param output_audio_config [Google::Cloud::Dialogflow::V2::OutputAudioConfig | Hash]
188
+ # Instructs the speech synthesizer how to generate the output
189
+ # audio. If this field is not set and agent-level speech synthesizer is not
190
+ # configured, no output audio is generated.
191
+ # @param output_audio_config_mask [Google::Protobuf::FieldMask | Hash]
192
+ # Mask for {Google::Cloud::Dialogflow::V2::DetectIntentRequest#output_audio_config output_audio_config} indicating which settings in this
193
+ # request-level config should override speech synthesizer settings defined at
194
+ # agent-level.
195
+ #
196
+ # If unspecified or empty, {Google::Cloud::Dialogflow::V2::DetectIntentRequest#output_audio_config output_audio_config} replaces the agent-level
197
+ # config in its entirety.
198
+ # @param input_audio [String]
199
+ # The natural language speech audio to be processed. This field
200
+ # should be populated iff `query_input` is set to an input audio config.
201
+ # A single request can contain up to 1 minute of speech audio data.
202
+ #
203
+ #
204
+ # @yield [response, operation] Access the result along with the RPC operation
205
+ # @yieldparam response [Google::Cloud::Dialogflow::V2::DetectIntentResponse]
206
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
207
+ #
208
+ # @return [Google::Cloud::Dialogflow::V2::DetectIntentResponse]
209
+ #
210
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
211
+ #
212
+ def detect_intent request, options = nil
213
+ raise ArgumentError, "request must be provided" if request.nil?
214
+
215
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::DetectIntentRequest
216
+
217
+ # Converts hash and nil to an options object
218
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
219
+
220
+ # Customize the options with defaults
221
+ metadata = @config.rpcs.detect_intent.metadata.to_h
222
+
223
+ # Set x-goog-api-client and x-goog-user-project headers
224
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
225
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
226
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
227
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
228
+
229
+ header_params = {
230
+ "session" => request.session
231
+ }
232
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
233
+ metadata[:"x-goog-request-params"] ||= request_params_header
234
+
235
+ options.apply_defaults timeout: @config.rpcs.detect_intent.timeout,
236
+ metadata: metadata,
237
+ retry_policy: @config.rpcs.detect_intent.retry_policy
238
+ options.apply_defaults metadata: @config.metadata,
239
+ retry_policy: @config.retry_policy
240
+
241
+ @sessions_stub.call_rpc :detect_intent, request, options: options do |response, operation|
242
+ yield response, operation if block_given?
243
+ return response
244
+ end
245
+ rescue GRPC::BadStatus => e
246
+ raise Google::Cloud::Error.from_error(e)
247
+ end
248
+
249
+ ##
250
+ # Processes a natural language query in audio format in a streaming fashion
251
+ # and returns structured, actionable data as a result. This method is only
252
+ # available via the gRPC API (not REST).
253
+ #
254
+ # @param request [Gapic::StreamInput, Enumerable<Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest | Hash>]
255
+ # An enumerable of {Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest} instances.
256
+ # @param options [Gapic::CallOptions, Hash]
257
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
258
+ #
259
+ # @yield [response, operation] Access the result along with the RPC operation
260
+ # @yieldparam response [Enumerable<Google::Cloud::Dialogflow::V2::StreamingDetectIntentResponse>]
261
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
262
+ #
263
+ # @return [Enumerable<Google::Cloud::Dialogflow::V2::StreamingDetectIntentResponse>]
264
+ #
265
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
266
+ #
267
+ def streaming_detect_intent request, options = nil
268
+ unless request.is_a? Enumerable
269
+ raise ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
270
+ request = request.to_enum
271
+ end
272
+
273
+ request = request.lazy.map do |req|
274
+ Gapic::Protobuf.coerce req, to: Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest
275
+ end
276
+
277
+ # Converts hash and nil to an options object
278
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
279
+
280
+ # Customize the options with defaults
281
+ metadata = @config.rpcs.streaming_detect_intent.metadata.to_h
282
+
283
+ # Set x-goog-api-client and x-goog-user-project headers
284
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
285
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
286
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
287
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
288
+
289
+ options.apply_defaults timeout: @config.rpcs.streaming_detect_intent.timeout,
290
+ metadata: metadata,
291
+ retry_policy: @config.rpcs.streaming_detect_intent.retry_policy
292
+ options.apply_defaults metadata: @config.metadata,
293
+ retry_policy: @config.retry_policy
294
+
295
+ @sessions_stub.call_rpc :streaming_detect_intent, request, options: options do |response, operation|
296
+ yield response, operation if block_given?
297
+ return response
298
+ end
299
+ rescue GRPC::BadStatus => e
300
+ raise Google::Cloud::Error.from_error(e)
301
+ end
302
+
303
+ ##
304
+ # Configuration class for the Sessions API.
305
+ #
306
+ # This class represents the configuration for Sessions,
307
+ # providing control over timeouts, retry behavior, logging, transport
308
+ # parameters, and other low-level controls. Certain parameters can also be
309
+ # applied individually to specific RPCs. See
310
+ # {Google::Cloud::Dialogflow::V2::Sessions::Client::Configuration::Rpcs}
311
+ # for a list of RPCs that can be configured independently.
312
+ #
313
+ # Configuration can be applied globally to all clients, or to a single client
314
+ # on construction.
315
+ #
316
+ # # Examples
317
+ #
318
+ # To modify the global config, setting the timeout for detect_intent
319
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
320
+ #
321
+ # Google::Cloud::Dialogflow::V2::Sessions::Client.configure do |config|
322
+ # config.timeout = 10_000
323
+ # config.rpcs.detect_intent.timeout = 20_000
324
+ # end
325
+ #
326
+ # To apply the above configuration only to a new client:
327
+ #
328
+ # client = Google::Cloud::Dialogflow::V2::Sessions::Client.new do |config|
329
+ # config.timeout = 10_000
330
+ # config.rpcs.detect_intent.timeout = 20_000
331
+ # end
332
+ #
333
+ # @!attribute [rw] endpoint
334
+ # The hostname or hostname:port of the service endpoint.
335
+ # Defaults to `"dialogflow.googleapis.com"`.
336
+ # @return [String]
337
+ # @!attribute [rw] credentials
338
+ # Credentials to send with calls. You may provide any of the following types:
339
+ # * (`String`) The path to a service account key file in JSON format
340
+ # * (`Hash`) A service account key as a Hash
341
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
342
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
343
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
344
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
345
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
346
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
347
+ # * (`nil`) indicating no credentials
348
+ # @return [Object]
349
+ # @!attribute [rw] scope
350
+ # The OAuth scopes
351
+ # @return [Array<String>]
352
+ # @!attribute [rw] lib_name
353
+ # The library name as recorded in instrumentation and logging
354
+ # @return [String]
355
+ # @!attribute [rw] lib_version
356
+ # The library version as recorded in instrumentation and logging
357
+ # @return [String]
358
+ # @!attribute [rw] channel_args
359
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
360
+ # `GRPC::Core::Channel` object is provided as the credential.
361
+ # @return [Hash]
362
+ # @!attribute [rw] interceptors
363
+ # An array of interceptors that are run before calls are executed.
364
+ # @return [Array<GRPC::ClientInterceptor>]
365
+ # @!attribute [rw] timeout
366
+ # The call timeout in milliseconds.
367
+ # @return [Numeric]
368
+ # @!attribute [rw] metadata
369
+ # Additional gRPC headers to be sent with the call.
370
+ # @return [Hash{Symbol=>String}]
371
+ # @!attribute [rw] retry_policy
372
+ # The retry policy. The value is a hash with the following keys:
373
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
374
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
375
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
376
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
377
+ # trigger a retry.
378
+ # @return [Hash]
379
+ #
380
+ class Configuration
381
+ extend Gapic::Config
382
+
383
+ config_attr :endpoint, "dialogflow.googleapis.com", String
384
+ config_attr :credentials, nil do |value|
385
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
386
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
387
+ allowed.any? { |klass| klass === value }
388
+ end
389
+ config_attr :scope, nil, String, Array, nil
390
+ config_attr :lib_name, nil, String, nil
391
+ config_attr :lib_version, nil, String, nil
392
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
393
+ config_attr :interceptors, nil, Array, nil
394
+ config_attr :timeout, nil, Numeric, nil
395
+ config_attr :metadata, nil, Hash, nil
396
+ config_attr :retry_policy, nil, Hash, Proc, nil
397
+
398
+ # @private
399
+ def initialize parent_config = nil
400
+ @parent_config = parent_config unless parent_config.nil?
401
+
402
+ yield self if block_given?
403
+ end
404
+
405
+ ##
406
+ # Configurations for individual RPCs
407
+ # @return [Rpcs]
408
+ #
409
+ def rpcs
410
+ @rpcs ||= begin
411
+ parent_rpcs = nil
412
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
413
+ Rpcs.new parent_rpcs
414
+ end
415
+ end
416
+
417
+ ##
418
+ # Configuration RPC class for the Sessions API.
419
+ #
420
+ # Includes fields providing the configuration for each RPC in this service.
421
+ # Each configuration object is of type `Gapic::Config::Method` and includes
422
+ # the following configuration fields:
423
+ #
424
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
425
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
426
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
427
+ # include the following keys:
428
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
429
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
430
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
431
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
432
+ # trigger a retry.
433
+ #
434
+ class Rpcs
435
+ ##
436
+ # RPC-specific configuration for `detect_intent`
437
+ # @return [Gapic::Config::Method]
438
+ #
439
+ attr_reader :detect_intent
440
+ ##
441
+ # RPC-specific configuration for `streaming_detect_intent`
442
+ # @return [Gapic::Config::Method]
443
+ #
444
+ attr_reader :streaming_detect_intent
445
+
446
+ # @private
447
+ def initialize parent_rpcs = nil
448
+ detect_intent_config = parent_rpcs&.detect_intent if parent_rpcs&.respond_to? :detect_intent
449
+ @detect_intent = Gapic::Config::Method.new detect_intent_config
450
+ streaming_detect_intent_config = parent_rpcs&.streaming_detect_intent if parent_rpcs&.respond_to? :streaming_detect_intent
451
+ @streaming_detect_intent = Gapic::Config::Method.new streaming_detect_intent_config
452
+
453
+ yield self if block_given?
454
+ end
455
+ end
456
+ end
457
+ end
458
+ end
459
+ end
460
+ end
461
+ end
462
+ end
463
+
464
+ # rubocop:disable Lint/HandleExceptions
465
+
466
+ # Once client is loaded, load helpers.rb if it exists.
467
+ begin
468
+ require "google/cloud/dialogflow/v2/sessions/helpers"
469
+ rescue LoadError
470
+ end
471
+
472
+ # rubocop:enable Lint/HandleExceptions