google-cloud-dialogflow 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +8 -0
  3. data/LICENSE +201 -0
  4. data/README.md +32 -0
  5. data/lib/google/cloud/dialogflow.rb +452 -0
  6. data/lib/google/cloud/dialogflow/credentials.rb +30 -0
  7. data/lib/google/cloud/dialogflow/v2.rb +454 -0
  8. data/lib/google/cloud/dialogflow/v2/agent_pb.rb +87 -0
  9. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +104 -0
  10. data/lib/google/cloud/dialogflow/v2/agents_client.rb +639 -0
  11. data/lib/google/cloud/dialogflow/v2/agents_client_config.json +56 -0
  12. data/lib/google/cloud/dialogflow/v2/context_pb.rb +59 -0
  13. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +71 -0
  14. data/lib/google/cloud/dialogflow/v2/contexts_client.rb +445 -0
  15. data/lib/google/cloud/dialogflow/v2/contexts_client_config.json +56 -0
  16. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/agent.rb +223 -0
  17. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/context.rb +115 -0
  18. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/entity_type.rb +290 -0
  19. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/intent.rb +714 -0
  20. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session.rb +451 -0
  21. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session_entity_type.rb +134 -0
  22. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/any.rb +124 -0
  23. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/field_mask.rb +223 -0
  24. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/struct.rb +73 -0
  25. data/lib/google/cloud/dialogflow/v2/doc/google/rpc/status.rb +83 -0
  26. data/lib/google/cloud/dialogflow/v2/doc/google/type/latlng.rb +64 -0
  27. data/lib/google/cloud/dialogflow/v2/doc/overview.rb +55 -0
  28. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +120 -0
  29. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +105 -0
  30. data/lib/google/cloud/dialogflow/v2/entity_types_client.rb +900 -0
  31. data/lib/google/cloud/dialogflow/v2/entity_types_client_config.json +76 -0
  32. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +274 -0
  33. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +91 -0
  34. data/lib/google/cloud/dialogflow/v2/intents_client.rb +684 -0
  35. data/lib/google/cloud/dialogflow/v2/intents_client_config.json +61 -0
  36. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +61 -0
  37. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +64 -0
  38. data/lib/google/cloud/dialogflow/v2/session_entity_types_client.rb +413 -0
  39. data/lib/google/cloud/dialogflow/v2/session_entity_types_client_config.json +51 -0
  40. data/lib/google/cloud/dialogflow/v2/session_pb.rb +127 -0
  41. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +55 -0
  42. data/lib/google/cloud/dialogflow/v2/sessions_client.rb +286 -0
  43. data/lib/google/cloud/dialogflow/v2/sessions_client_config.json +36 -0
  44. data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +42 -0
  45. metadata +142 -0
@@ -0,0 +1,56 @@
1
+ {
2
+ "interfaces": {
3
+ "google.cloud.dialogflow.v2.Agents": {
4
+ "retry_codes": {
5
+ "idempotent": [
6
+ "DEADLINE_EXCEEDED",
7
+ "UNAVAILABLE"
8
+ ],
9
+ "non_idempotent": []
10
+ },
11
+ "retry_params": {
12
+ "default": {
13
+ "initial_retry_delay_millis": 100,
14
+ "retry_delay_multiplier": 1.3,
15
+ "max_retry_delay_millis": 60000,
16
+ "initial_rpc_timeout_millis": 20000,
17
+ "rpc_timeout_multiplier": 1.0,
18
+ "max_rpc_timeout_millis": 20000,
19
+ "total_timeout_millis": 600000
20
+ }
21
+ },
22
+ "methods": {
23
+ "GetAgent": {
24
+ "timeout_millis": 60000,
25
+ "retry_codes_name": "idempotent",
26
+ "retry_params_name": "default"
27
+ },
28
+ "SearchAgents": {
29
+ "timeout_millis": 60000,
30
+ "retry_codes_name": "idempotent",
31
+ "retry_params_name": "default"
32
+ },
33
+ "TrainAgent": {
34
+ "timeout_millis": 60000,
35
+ "retry_codes_name": "idempotent",
36
+ "retry_params_name": "default"
37
+ },
38
+ "ExportAgent": {
39
+ "timeout_millis": 60000,
40
+ "retry_codes_name": "idempotent",
41
+ "retry_params_name": "default"
42
+ },
43
+ "ImportAgent": {
44
+ "timeout_millis": 60000,
45
+ "retry_codes_name": "non_idempotent",
46
+ "retry_params_name": "default"
47
+ },
48
+ "RestoreAgent": {
49
+ "timeout_millis": 60000,
50
+ "retry_codes_name": "idempotent",
51
+ "retry_params_name": "default"
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,59 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/dialogflow/v2/context.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/annotations_pb'
7
+ require 'google/protobuf/empty_pb'
8
+ require 'google/protobuf/field_mask_pb'
9
+ require 'google/protobuf/struct_pb'
10
+ Google::Protobuf::DescriptorPool.generated_pool.build do
11
+ add_message "google.cloud.dialogflow.v2.Context" do
12
+ optional :name, :string, 1
13
+ optional :lifespan_count, :int32, 2
14
+ optional :parameters, :message, 3, "google.protobuf.Struct"
15
+ end
16
+ add_message "google.cloud.dialogflow.v2.ListContextsRequest" do
17
+ optional :parent, :string, 1
18
+ optional :page_size, :int32, 2
19
+ optional :page_token, :string, 3
20
+ end
21
+ add_message "google.cloud.dialogflow.v2.ListContextsResponse" do
22
+ repeated :contexts, :message, 1, "google.cloud.dialogflow.v2.Context"
23
+ optional :next_page_token, :string, 2
24
+ end
25
+ add_message "google.cloud.dialogflow.v2.GetContextRequest" do
26
+ optional :name, :string, 1
27
+ end
28
+ add_message "google.cloud.dialogflow.v2.CreateContextRequest" do
29
+ optional :parent, :string, 1
30
+ optional :context, :message, 2, "google.cloud.dialogflow.v2.Context"
31
+ end
32
+ add_message "google.cloud.dialogflow.v2.UpdateContextRequest" do
33
+ optional :context, :message, 1, "google.cloud.dialogflow.v2.Context"
34
+ optional :update_mask, :message, 2, "google.protobuf.FieldMask"
35
+ end
36
+ add_message "google.cloud.dialogflow.v2.DeleteContextRequest" do
37
+ optional :name, :string, 1
38
+ end
39
+ add_message "google.cloud.dialogflow.v2.DeleteAllContextsRequest" do
40
+ optional :parent, :string, 1
41
+ end
42
+ end
43
+
44
+ module Google
45
+ module Cloud
46
+ module Dialogflow
47
+ module V2
48
+ Context = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Context").msgclass
49
+ ListContextsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListContextsRequest").msgclass
50
+ ListContextsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListContextsResponse").msgclass
51
+ GetContextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.GetContextRequest").msgclass
52
+ CreateContextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.CreateContextRequest").msgclass
53
+ UpdateContextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.UpdateContextRequest").msgclass
54
+ DeleteContextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteContextRequest").msgclass
55
+ DeleteAllContextsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteAllContextsRequest").msgclass
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,71 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/cloud/dialogflow/v2/context.proto for package 'google.cloud.dialogflow.v2'
3
+ # Original file comments:
4
+ # Copyright 2018 Google Inc.
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/context_pb'
21
+
22
+ module Google
23
+ module Cloud
24
+ module Dialogflow
25
+ module V2
26
+ module Contexts
27
+ # A context represents additional information included with user input or with
28
+ # an intent returned by the Dialogflow API. Contexts are helpful for
29
+ # differentiating user input which may be vague or have a different meaning
30
+ # depending on additional details from your application such as user setting
31
+ # and preferences, previous user input, where the user is in your application,
32
+ # geographic location, and so on.
33
+ #
34
+ # You can include contexts as input parameters of a
35
+ # [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or
36
+ # [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) request,
37
+ # or as output contexts included in the returned intent.
38
+ # Contexts expire when an intent is matched, after the number of `DetectIntent`
39
+ # requests specified by the `lifespan_count` parameter, or after 10 minutes
40
+ # if no intents are matched for a `DetectIntent` request.
41
+ #
42
+ # For more information about contexts, see the
43
+ # [Dialogflow documentation](https://dialogflow.com/docs/contexts).
44
+ class Service
45
+
46
+ include GRPC::GenericService
47
+
48
+ self.marshal_class_method = :encode
49
+ self.unmarshal_class_method = :decode
50
+ self.service_name = 'google.cloud.dialogflow.v2.Contexts'
51
+
52
+ # Returns the list of all contexts in the specified session.
53
+ rpc :ListContexts, ListContextsRequest, ListContextsResponse
54
+ # Retrieves the specified context.
55
+ rpc :GetContext, GetContextRequest, Context
56
+ # Creates a context.
57
+ rpc :CreateContext, CreateContextRequest, Context
58
+ # Updates the specified context.
59
+ rpc :UpdateContext, UpdateContextRequest, Context
60
+ # Deletes the specified context.
61
+ rpc :DeleteContext, DeleteContextRequest, Google::Protobuf::Empty
62
+ # Deletes all active contexts in the specified session.
63
+ rpc :DeleteAllContexts, DeleteAllContextsRequest, Google::Protobuf::Empty
64
+ end
65
+
66
+ Stub = Service.rpc_stub_class
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,445 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # EDITING INSTRUCTIONS
16
+ # This file was generated from the file
17
+ # https://github.com/googleapis/googleapis/blob/master/google/cloud/dialogflow/v2/context.proto,
18
+ # and updates to that file get reflected here through a refresh process.
19
+ # For the short term, the refresh process will only be runnable by Google
20
+ # engineers.
21
+
22
+ require "json"
23
+ require "pathname"
24
+
25
+ require "google/gax"
26
+
27
+ require "google/cloud/dialogflow/v2/context_pb"
28
+ require "google/cloud/dialogflow/credentials"
29
+
30
+ module Google
31
+ module Cloud
32
+ module Dialogflow
33
+ module V2
34
+ # A context represents additional information included with user input or with
35
+ # an intent returned by the Dialogflow API. Contexts are helpful for
36
+ # differentiating user input which may be vague or have a different meaning
37
+ # depending on additional details from your application such as user setting
38
+ # and preferences, previous user input, where the user is in your application,
39
+ # geographic location, and so on.
40
+ #
41
+ # You can include contexts as input parameters of a
42
+ # {Google::Cloud::Dialogflow::V2::Sessions::DetectIntent DetectIntent} (or
43
+ # {Google::Cloud::Dialogflow::V2::Sessions::StreamingDetectIntent StreamingDetectIntent}) request,
44
+ # or as output contexts included in the returned intent.
45
+ # Contexts expire when an intent is matched, after the number of +DetectIntent+
46
+ # requests specified by the +lifespan_count+ parameter, or after 10 minutes
47
+ # if no intents are matched for a +DetectIntent+ request.
48
+ #
49
+ # For more information about contexts, see the
50
+ # [Dialogflow documentation](https://dialogflow.com/docs/contexts).
51
+ #
52
+ # @!attribute [r] contexts_stub
53
+ # @return [Google::Cloud::Dialogflow::V2::Contexts::Stub]
54
+ class ContextsClient
55
+ attr_reader :contexts_stub
56
+
57
+ # The default address of the service.
58
+ SERVICE_ADDRESS = "dialogflow.googleapis.com".freeze
59
+
60
+ # The default port of the service.
61
+ DEFAULT_SERVICE_PORT = 443
62
+
63
+ DEFAULT_TIMEOUT = 30
64
+
65
+ PAGE_DESCRIPTORS = {
66
+ "list_contexts" => Google::Gax::PageDescriptor.new(
67
+ "page_token",
68
+ "next_page_token",
69
+ "contexts")
70
+ }.freeze
71
+
72
+ private_constant :PAGE_DESCRIPTORS
73
+
74
+ # The scopes needed to make gRPC calls to all of the methods defined in
75
+ # this service.
76
+ ALL_SCOPES = [
77
+ "https://www.googleapis.com/auth/cloud-platform"
78
+ ].freeze
79
+
80
+
81
+ SESSION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
82
+ "projects/{project}/agent/sessions/{session}"
83
+ )
84
+
85
+ private_constant :SESSION_PATH_TEMPLATE
86
+
87
+ CONTEXT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
88
+ "projects/{project}/agent/sessions/{session}/contexts/{context}"
89
+ )
90
+
91
+ private_constant :CONTEXT_PATH_TEMPLATE
92
+
93
+ # Returns a fully-qualified session resource name string.
94
+ # @param project [String]
95
+ # @param session [String]
96
+ # @return [String]
97
+ def self.session_path project, session
98
+ SESSION_PATH_TEMPLATE.render(
99
+ :"project" => project,
100
+ :"session" => session
101
+ )
102
+ end
103
+
104
+ # Returns a fully-qualified context resource name string.
105
+ # @param project [String]
106
+ # @param session [String]
107
+ # @param context [String]
108
+ # @return [String]
109
+ def self.context_path project, session, context
110
+ CONTEXT_PATH_TEMPLATE.render(
111
+ :"project" => project,
112
+ :"session" => session,
113
+ :"context" => context
114
+ )
115
+ end
116
+
117
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
118
+ # Provides the means for authenticating requests made by the client. This parameter can
119
+ # be many types.
120
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
121
+ # authenticating requests made by this client.
122
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
123
+ # credentials for this client.
124
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
125
+ # credentials for this client.
126
+ # A `GRPC::Core::Channel` will be used to make calls through.
127
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
128
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
129
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
130
+ # metadata for requests, generally, to give OAuth credentials.
131
+ # @param scopes [Array<String>]
132
+ # The OAuth scopes for this service. This parameter is ignored if
133
+ # an updater_proc is supplied.
134
+ # @param client_config [Hash]
135
+ # A Hash for call options for each method. See
136
+ # Google::Gax#construct_settings for the structure of
137
+ # this data. Falls back to the default config if not specified
138
+ # or the specified config is missing data points.
139
+ # @param timeout [Numeric]
140
+ # The default timeout, in seconds, for calls made through this client.
141
+ def initialize \
142
+ credentials: nil,
143
+ scopes: ALL_SCOPES,
144
+ client_config: {},
145
+ timeout: DEFAULT_TIMEOUT,
146
+ lib_name: nil,
147
+ lib_version: ""
148
+ # These require statements are intentionally placed here to initialize
149
+ # the gRPC module only when it's required.
150
+ # See https://github.com/googleapis/toolkit/issues/446
151
+ require "google/gax/grpc"
152
+ require "google/cloud/dialogflow/v2/context_services_pb"
153
+
154
+ credentials ||= Google::Cloud::Dialogflow::Credentials.default
155
+
156
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
157
+ updater_proc = Google::Cloud::Dialogflow::Credentials.new(credentials).updater_proc
158
+ end
159
+ if credentials.is_a?(GRPC::Core::Channel)
160
+ channel = credentials
161
+ end
162
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
163
+ chan_creds = credentials
164
+ end
165
+ if credentials.is_a?(Proc)
166
+ updater_proc = credentials
167
+ end
168
+ if credentials.is_a?(Google::Auth::Credentials)
169
+ updater_proc = credentials.updater_proc
170
+ end
171
+
172
+ package_version = Gem.loaded_specs['google-cloud-dialogflow'].version.version
173
+
174
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
175
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
176
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
177
+ google_api_client << " grpc/#{GRPC::VERSION}"
178
+ google_api_client.freeze
179
+
180
+ headers = { :"x-goog-api-client" => google_api_client }
181
+ client_config_file = Pathname.new(__dir__).join(
182
+ "contexts_client_config.json"
183
+ )
184
+ defaults = client_config_file.open do |f|
185
+ Google::Gax.construct_settings(
186
+ "google.cloud.dialogflow.v2.Contexts",
187
+ JSON.parse(f.read),
188
+ client_config,
189
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
190
+ timeout,
191
+ page_descriptors: PAGE_DESCRIPTORS,
192
+ errors: Google::Gax::Grpc::API_ERRORS,
193
+ kwargs: headers
194
+ )
195
+ end
196
+
197
+ # Allow overriding the service path/port in subclasses.
198
+ service_path = self.class::SERVICE_ADDRESS
199
+ port = self.class::DEFAULT_SERVICE_PORT
200
+ @contexts_stub = Google::Gax::Grpc.create_stub(
201
+ service_path,
202
+ port,
203
+ chan_creds: chan_creds,
204
+ channel: channel,
205
+ updater_proc: updater_proc,
206
+ scopes: scopes,
207
+ &Google::Cloud::Dialogflow::V2::Contexts::Stub.method(:new)
208
+ )
209
+
210
+ @list_contexts = Google::Gax.create_api_call(
211
+ @contexts_stub.method(:list_contexts),
212
+ defaults["list_contexts"]
213
+ )
214
+ @get_context = Google::Gax.create_api_call(
215
+ @contexts_stub.method(:get_context),
216
+ defaults["get_context"]
217
+ )
218
+ @create_context = Google::Gax.create_api_call(
219
+ @contexts_stub.method(:create_context),
220
+ defaults["create_context"]
221
+ )
222
+ @update_context = Google::Gax.create_api_call(
223
+ @contexts_stub.method(:update_context),
224
+ defaults["update_context"]
225
+ )
226
+ @delete_context = Google::Gax.create_api_call(
227
+ @contexts_stub.method(:delete_context),
228
+ defaults["delete_context"]
229
+ )
230
+ @delete_all_contexts = Google::Gax.create_api_call(
231
+ @contexts_stub.method(:delete_all_contexts),
232
+ defaults["delete_all_contexts"]
233
+ )
234
+ end
235
+
236
+ # Service calls
237
+
238
+ # Returns the list of all contexts in the specified session.
239
+ #
240
+ # @param parent [String]
241
+ # Required. The session to list all contexts from.
242
+ # Format: +projects/<Project ID>/agent/sessions/<Session ID>+.
243
+ # @param page_size [Integer]
244
+ # The maximum number of resources contained in the underlying API
245
+ # response. If page streaming is performed per-resource, this
246
+ # parameter does not affect the return value. If page streaming is
247
+ # performed per-page, this determines the maximum number of
248
+ # resources in a page.
249
+ # @param options [Google::Gax::CallOptions]
250
+ # Overrides the default settings for this call, e.g, timeout,
251
+ # retries, etc.
252
+ # @return [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Context>]
253
+ # An enumerable of Google::Cloud::Dialogflow::V2::Context instances.
254
+ # See Google::Gax::PagedEnumerable documentation for other
255
+ # operations such as per-page iteration or access to the response
256
+ # object.
257
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
258
+ # @example
259
+ # require "google/cloud/dialogflow/v2"
260
+ #
261
+ # contexts_client = Google::Cloud::Dialogflow::V2::Contexts.new
262
+ # formatted_parent = Google::Cloud::Dialogflow::V2::ContextsClient.session_path("[PROJECT]", "[SESSION]")
263
+ #
264
+ # # Iterate over all results.
265
+ # contexts_client.list_contexts(formatted_parent).each do |element|
266
+ # # Process element.
267
+ # end
268
+ #
269
+ # # Or iterate over results one page at a time.
270
+ # contexts_client.list_contexts(formatted_parent).each_page do |page|
271
+ # # Process each page at a time.
272
+ # page.each do |element|
273
+ # # Process element.
274
+ # end
275
+ # end
276
+
277
+ def list_contexts \
278
+ parent,
279
+ page_size: nil,
280
+ options: nil
281
+ req = {
282
+ parent: parent,
283
+ page_size: page_size
284
+ }.delete_if { |_, v| v.nil? }
285
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::ListContextsRequest)
286
+ @list_contexts.call(req, options)
287
+ end
288
+
289
+ # Retrieves the specified context.
290
+ #
291
+ # @param name [String]
292
+ # Required. The name of the context. Format:
293
+ # +projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>+.
294
+ # @param options [Google::Gax::CallOptions]
295
+ # Overrides the default settings for this call, e.g, timeout,
296
+ # retries, etc.
297
+ # @return [Google::Cloud::Dialogflow::V2::Context]
298
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
299
+ # @example
300
+ # require "google/cloud/dialogflow/v2"
301
+ #
302
+ # contexts_client = Google::Cloud::Dialogflow::V2::Contexts.new
303
+ # formatted_name = Google::Cloud::Dialogflow::V2::ContextsClient.context_path("[PROJECT]", "[SESSION]", "[CONTEXT]")
304
+ # response = contexts_client.get_context(formatted_name)
305
+
306
+ def get_context \
307
+ name,
308
+ options: nil
309
+ req = {
310
+ name: name
311
+ }.delete_if { |_, v| v.nil? }
312
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetContextRequest)
313
+ @get_context.call(req, options)
314
+ end
315
+
316
+ # Creates a context.
317
+ #
318
+ # @param parent [String]
319
+ # Required. The session to create a context for.
320
+ # Format: +projects/<Project ID>/agent/sessions/<Session ID>+.
321
+ # @param context [Google::Cloud::Dialogflow::V2::Context | Hash]
322
+ # Required. The context to create.
323
+ # A hash of the same form as `Google::Cloud::Dialogflow::V2::Context`
324
+ # can also be provided.
325
+ # @param options [Google::Gax::CallOptions]
326
+ # Overrides the default settings for this call, e.g, timeout,
327
+ # retries, etc.
328
+ # @return [Google::Cloud::Dialogflow::V2::Context]
329
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
330
+ # @example
331
+ # require "google/cloud/dialogflow/v2"
332
+ #
333
+ # contexts_client = Google::Cloud::Dialogflow::V2::Contexts.new
334
+ # formatted_parent = Google::Cloud::Dialogflow::V2::ContextsClient.session_path("[PROJECT]", "[SESSION]")
335
+ #
336
+ # # TODO: Initialize +context+:
337
+ # context = {}
338
+ # response = contexts_client.create_context(formatted_parent, context)
339
+
340
+ def create_context \
341
+ parent,
342
+ context,
343
+ options: nil
344
+ req = {
345
+ parent: parent,
346
+ context: context
347
+ }.delete_if { |_, v| v.nil? }
348
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::CreateContextRequest)
349
+ @create_context.call(req, options)
350
+ end
351
+
352
+ # Updates the specified context.
353
+ #
354
+ # @param context [Google::Cloud::Dialogflow::V2::Context | Hash]
355
+ # Required. The context to update.
356
+ # A hash of the same form as `Google::Cloud::Dialogflow::V2::Context`
357
+ # can also be provided.
358
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
359
+ # Optional. The mask to control which fields get updated.
360
+ # A hash of the same form as `Google::Protobuf::FieldMask`
361
+ # can also be provided.
362
+ # @param options [Google::Gax::CallOptions]
363
+ # Overrides the default settings for this call, e.g, timeout,
364
+ # retries, etc.
365
+ # @return [Google::Cloud::Dialogflow::V2::Context]
366
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
367
+ # @example
368
+ # require "google/cloud/dialogflow/v2"
369
+ #
370
+ # contexts_client = Google::Cloud::Dialogflow::V2::Contexts.new
371
+ #
372
+ # # TODO: Initialize +context+:
373
+ # context = {}
374
+ # response = contexts_client.update_context(context)
375
+
376
+ def update_context \
377
+ context,
378
+ update_mask: nil,
379
+ options: nil
380
+ req = {
381
+ context: context,
382
+ update_mask: update_mask
383
+ }.delete_if { |_, v| v.nil? }
384
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::UpdateContextRequest)
385
+ @update_context.call(req, options)
386
+ end
387
+
388
+ # Deletes the specified context.
389
+ #
390
+ # @param name [String]
391
+ # Required. The name of the context to delete. Format:
392
+ # +projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>+.
393
+ # @param options [Google::Gax::CallOptions]
394
+ # Overrides the default settings for this call, e.g, timeout,
395
+ # retries, etc.
396
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
397
+ # @example
398
+ # require "google/cloud/dialogflow/v2"
399
+ #
400
+ # contexts_client = Google::Cloud::Dialogflow::V2::Contexts.new
401
+ # formatted_name = Google::Cloud::Dialogflow::V2::ContextsClient.context_path("[PROJECT]", "[SESSION]", "[CONTEXT]")
402
+ # contexts_client.delete_context(formatted_name)
403
+
404
+ def delete_context \
405
+ name,
406
+ options: nil
407
+ req = {
408
+ name: name
409
+ }.delete_if { |_, v| v.nil? }
410
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteContextRequest)
411
+ @delete_context.call(req, options)
412
+ nil
413
+ end
414
+
415
+ # Deletes all active contexts in the specified session.
416
+ #
417
+ # @param parent [String]
418
+ # Required. The name of the session to delete all contexts from. Format:
419
+ # +projects/<Project ID>/agent/sessions/<Session ID>+.
420
+ # @param options [Google::Gax::CallOptions]
421
+ # Overrides the default settings for this call, e.g, timeout,
422
+ # retries, etc.
423
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
424
+ # @example
425
+ # require "google/cloud/dialogflow/v2"
426
+ #
427
+ # contexts_client = Google::Cloud::Dialogflow::V2::Contexts.new
428
+ # formatted_parent = Google::Cloud::Dialogflow::V2::ContextsClient.session_path("[PROJECT]", "[SESSION]")
429
+ # contexts_client.delete_all_contexts(formatted_parent)
430
+
431
+ def delete_all_contexts \
432
+ parent,
433
+ options: nil
434
+ req = {
435
+ parent: parent
436
+ }.delete_if { |_, v| v.nil? }
437
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest)
438
+ @delete_all_contexts.call(req, options)
439
+ nil
440
+ end
441
+ end
442
+ end
443
+ end
444
+ end
445
+ end