google-cloud-dialogflow 0.1.0 → 0.2.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.
@@ -25,7 +25,7 @@ require "pathname"
25
25
  require "google/gax"
26
26
 
27
27
  require "google/cloud/dialogflow/v2/session_pb"
28
- require "google/cloud/dialogflow/credentials"
28
+ require "google/cloud/dialogflow/v2/credentials"
29
29
 
30
30
  module Google
31
31
  module Cloud
@@ -47,6 +47,9 @@ module Google
47
47
  # The default port of the service.
48
48
  DEFAULT_SERVICE_PORT = 443
49
49
 
50
+ # The default set of gRPC interceptors.
51
+ GRPC_INTERCEPTORS = []
52
+
50
53
  DEFAULT_TIMEOUT = 30
51
54
 
52
55
  # The scopes needed to make gRPC calls to all of the methods defined in
@@ -97,11 +100,18 @@ module Google
97
100
  # or the specified config is missing data points.
98
101
  # @param timeout [Numeric]
99
102
  # The default timeout, in seconds, for calls made through this client.
103
+ # @param metadata [Hash]
104
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
105
+ # @param exception_transformer [Proc]
106
+ # An optional proc that intercepts any exceptions raised during an API call to inject
107
+ # custom error handling.
100
108
  def initialize \
101
109
  credentials: nil,
102
110
  scopes: ALL_SCOPES,
103
111
  client_config: {},
104
112
  timeout: DEFAULT_TIMEOUT,
113
+ metadata: nil,
114
+ exception_transformer: nil,
105
115
  lib_name: nil,
106
116
  lib_version: ""
107
117
  # These require statements are intentionally placed here to initialize
@@ -110,10 +120,10 @@ module Google
110
120
  require "google/gax/grpc"
111
121
  require "google/cloud/dialogflow/v2/session_services_pb"
112
122
 
113
- credentials ||= Google::Cloud::Dialogflow::Credentials.default
123
+ credentials ||= Google::Cloud::Dialogflow::V2::Credentials.default
114
124
 
115
125
  if credentials.is_a?(String) || credentials.is_a?(Hash)
116
- updater_proc = Google::Cloud::Dialogflow::Credentials.new(credentials).updater_proc
126
+ updater_proc = Google::Cloud::Dialogflow::V2::Credentials.new(credentials).updater_proc
117
127
  end
118
128
  if credentials.is_a?(GRPC::Core::Channel)
119
129
  channel = credentials
@@ -137,6 +147,7 @@ module Google
137
147
  google_api_client.freeze
138
148
 
139
149
  headers = { :"x-goog-api-client" => google_api_client }
150
+ headers.merge!(metadata) unless metadata.nil?
140
151
  client_config_file = Pathname.new(__dir__).join(
141
152
  "sessions_client_config.json"
142
153
  )
@@ -148,13 +159,14 @@ module Google
148
159
  Google::Gax::Grpc::STATUS_CODE_NAMES,
149
160
  timeout,
150
161
  errors: Google::Gax::Grpc::API_ERRORS,
151
- kwargs: headers
162
+ metadata: headers
152
163
  )
153
164
  end
154
165
 
155
166
  # Allow overriding the service path/port in subclasses.
156
167
  service_path = self.class::SERVICE_ADDRESS
157
168
  port = self.class::DEFAULT_SERVICE_PORT
169
+ interceptors = self.class::GRPC_INTERCEPTORS
158
170
  @sessions_stub = Google::Gax::Grpc.create_stub(
159
171
  service_path,
160
172
  port,
@@ -162,16 +174,19 @@ module Google
162
174
  channel: channel,
163
175
  updater_proc: updater_proc,
164
176
  scopes: scopes,
177
+ interceptors: interceptors,
165
178
  &Google::Cloud::Dialogflow::V2::Sessions::Stub.method(:new)
166
179
  )
167
180
 
168
181
  @detect_intent = Google::Gax.create_api_call(
169
182
  @sessions_stub.method(:detect_intent),
170
- defaults["detect_intent"]
183
+ defaults["detect_intent"],
184
+ exception_transformer: exception_transformer
171
185
  )
172
186
  @streaming_detect_intent = Google::Gax.create_api_call(
173
187
  @sessions_stub.method(:streaming_detect_intent),
174
- defaults["streaming_detect_intent"]
188
+ defaults["streaming_detect_intent"],
189
+ exception_transformer: exception_transformer
175
190
  )
176
191
  end
177
192
 
@@ -210,12 +225,15 @@ module Google
210
225
  # @param options [Google::Gax::CallOptions]
211
226
  # Overrides the default settings for this call, e.g, timeout,
212
227
  # retries, etc.
228
+ # @yield [result, operation] Access the result along with the RPC operation
229
+ # @yieldparam result [Google::Cloud::Dialogflow::V2::DetectIntentResponse]
230
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
213
231
  # @return [Google::Cloud::Dialogflow::V2::DetectIntentResponse]
214
232
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
215
233
  # @example
216
- # require "google/cloud/dialogflow/v2"
234
+ # require "google/cloud/dialogflow"
217
235
  #
218
- # sessions_client = Google::Cloud::Dialogflow::V2::Sessions.new
236
+ # sessions_client = Google::Cloud::Dialogflow::Sessions.new(version: :v2)
219
237
  # formatted_session = Google::Cloud::Dialogflow::V2::SessionsClient.session_path("[PROJECT]", "[SESSION]")
220
238
  #
221
239
  # # TODO: Initialize +query_input+:
@@ -227,7 +245,8 @@ module Google
227
245
  query_input,
228
246
  query_params: nil,
229
247
  input_audio: nil,
230
- options: nil
248
+ options: nil,
249
+ &block
231
250
  req = {
232
251
  session: session,
233
252
  query_input: query_input,
@@ -235,7 +254,7 @@ module Google
235
254
  input_audio: input_audio
236
255
  }.delete_if { |_, v| v.nil? }
237
256
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DetectIntentRequest)
238
- @detect_intent.call(req, options)
257
+ @detect_intent.call(req, options, &block)
239
258
  end
240
259
 
241
260
  # Processes a natural language query in audio format in a streaming fashion
@@ -258,9 +277,9 @@ module Google
258
277
  # This method interface might change in the future.
259
278
  #
260
279
  # @example
261
- # require "google/cloud/dialogflow/v2"
280
+ # require "google/cloud/dialogflow"
262
281
  #
263
- # sessions_client = Google::Cloud::Dialogflow::V2::Sessions.new
282
+ # sessions_client = Google::Cloud::Dialogflow::Sessions.new(version: :v2)
264
283
  #
265
284
  # # TODO: Initialize +session+:
266
285
  # session = ''
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-dialogflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-17 00:00:00.000000000 Z
11
+ date: 2018-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-gax
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: redcarpet
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rubocop
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.9'
69
97
  description: google-cloud-dialogflow is the official library for Dialogflow API.
70
98
  email: googleapis-packages@google.com
71
99
  executables: []
@@ -76,7 +104,6 @@ files:
76
104
  - LICENSE
77
105
  - README.md
78
106
  - lib/google/cloud/dialogflow.rb
79
- - lib/google/cloud/dialogflow/credentials.rb
80
107
  - lib/google/cloud/dialogflow/v2.rb
81
108
  - lib/google/cloud/dialogflow/v2/agent_pb.rb
82
109
  - lib/google/cloud/dialogflow/v2/agent_services_pb.rb
@@ -86,13 +113,16 @@ files:
86
113
  - lib/google/cloud/dialogflow/v2/context_services_pb.rb
87
114
  - lib/google/cloud/dialogflow/v2/contexts_client.rb
88
115
  - lib/google/cloud/dialogflow/v2/contexts_client_config.json
116
+ - lib/google/cloud/dialogflow/v2/credentials.rb
89
117
  - lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/agent.rb
90
118
  - lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/context.rb
91
119
  - lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/entity_type.rb
92
120
  - lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/intent.rb
93
121
  - lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session.rb
94
122
  - lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session_entity_type.rb
123
+ - lib/google/cloud/dialogflow/v2/doc/google/longrunning/operations.rb
95
124
  - lib/google/cloud/dialogflow/v2/doc/google/protobuf/any.rb
125
+ - lib/google/cloud/dialogflow/v2/doc/google/protobuf/empty.rb
96
126
  - lib/google/cloud/dialogflow/v2/doc/google/protobuf/field_mask.rb
97
127
  - lib/google/cloud/dialogflow/v2/doc/google/protobuf/struct.rb
98
128
  - lib/google/cloud/dialogflow/v2/doc/google/rpc/status.rb
@@ -115,7 +145,7 @@ files:
115
145
  - lib/google/cloud/dialogflow/v2/sessions_client.rb
116
146
  - lib/google/cloud/dialogflow/v2/sessions_client_config.json
117
147
  - lib/google/cloud/dialogflow/v2/webhook_pb.rb
118
- homepage: https://github.com/googleapis/googleapis
148
+ homepage: https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/master/google-cloud-dialogflow
119
149
  licenses:
120
150
  - Apache-2.0
121
151
  metadata: {}
@@ -135,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
165
  version: '0'
136
166
  requirements: []
137
167
  rubyforge_project:
138
- rubygems_version: 2.7.6
168
+ rubygems_version: 2.7.7
139
169
  signing_key:
140
170
  specification_version: 4
141
171
  summary: API Client library for Dialogflow API