google-cloud-dialogflow 0.15.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +397 -0
  6. data/README.md +35 -25
  7. data/lib/{google/cloud/dialogflow/v2/doc/google/protobuf/empty.rb → google-cloud-dialogflow.rb} +4 -14
  8. data/lib/google/cloud/dialogflow.rb +368 -506
  9. data/lib/google/cloud/dialogflow/version.rb +1 -1
  10. metadata +88 -83
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/dialogflow/v2.rb +0 -598
  13. data/lib/google/cloud/dialogflow/v2/agent_pb.rb +0 -121
  14. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +0 -111
  15. data/lib/google/cloud/dialogflow/v2/agents_client.rb +0 -810
  16. data/lib/google/cloud/dialogflow/v2/agents_client_config.json +0 -71
  17. data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +0 -96
  18. data/lib/google/cloud/dialogflow/v2/context_pb.rb +0 -63
  19. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +0 -75
  20. data/lib/google/cloud/dialogflow/v2/contexts_client.rb +0 -522
  21. data/lib/google/cloud/dialogflow/v2/contexts_client_config.json +0 -56
  22. data/lib/google/cloud/dialogflow/v2/credentials.rb +0 -42
  23. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/agent.rb +0 -247
  24. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/audio_config.rb +0 -341
  25. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/context.rb +0 -116
  26. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/entity_type.rb +0 -305
  27. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/intent.rb +0 -937
  28. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session.rb +0 -498
  29. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session_entity_type.rb +0 -130
  30. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/validation_result.rb +0 -71
  31. data/lib/google/cloud/dialogflow/v2/doc/google/longrunning/operations.rb +0 -51
  32. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/any.rb +0 -131
  33. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/duration.rb +0 -91
  34. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/field_mask.rb +0 -222
  35. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/struct.rb +0 -74
  36. data/lib/google/cloud/dialogflow/v2/doc/google/rpc/status.rb +0 -39
  37. data/lib/google/cloud/dialogflow/v2/doc/google/type/latlng.rb +0 -31
  38. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +0 -125
  39. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +0 -105
  40. data/lib/google/cloud/dialogflow/v2/entity_types_client.rb +0 -997
  41. data/lib/google/cloud/dialogflow/v2/entity_types_client_config.json +0 -76
  42. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +0 -367
  43. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +0 -93
  44. data/lib/google/cloud/dialogflow/v2/intents_client.rb +0 -763
  45. data/lib/google/cloud/dialogflow/v2/intents_client_config.json +0 -61
  46. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +0 -65
  47. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +0 -93
  48. data/lib/google/cloud/dialogflow/v2/session_entity_types_client.rb +0 -507
  49. data/lib/google/cloud/dialogflow/v2/session_entity_types_client_config.json +0 -51
  50. data/lib/google/cloud/dialogflow/v2/session_pb.rb +0 -141
  51. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +0 -56
  52. data/lib/google/cloud/dialogflow/v2/sessions_client.rb +0 -340
  53. data/lib/google/cloud/dialogflow/v2/sessions_client_config.json +0 -36
  54. data/lib/google/cloud/dialogflow/v2/validation_result_pb.rb +0 -36
  55. data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +0 -46
data/README.md CHANGED
@@ -1,42 +1,52 @@
1
- # Ruby Client for Dialogflow API
1
+ # Ruby Client for the Dialogflow API
2
2
 
3
- [Dialogflow API][Product Documentation]:
4
- Builds conversational interfaces (for example, chatbots, and voice-powered
5
- apps and devices).
6
- - [Client Library Documentation][]
7
- - [Product Documentation][]
3
+ API Client library for the Dialogflow API
8
4
 
9
- ## Quick Start
10
- In order to use this library, you first need to go through the following
11
- steps:
5
+ Dialogflow is an end-to-end, build-once deploy-everywhere development suite for creating conversational interfaces for websites, mobile applications, popular messaging platforms, and IoT devices. You can use it to build interfaces (such as chatbots and conversational IVR) that enable natural and rich interactions between your users and your business.
12
6
 
13
- 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
14
- 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
15
- 3. [Enable the Dialogflow API.](https://console.cloud.google.com/apis/library/dialogflow.googleapis.com)
16
- 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-dialogflow/latest/file.AUTHENTICATION.html)
7
+ Actual client classes for the various versions of this API are defined in
8
+ _versioned_ client gems, with names of the form `google-cloud-dialogflow-v*`.
9
+ The gem `google-cloud-dialogflow` is a convenience wrapper library that brings the
10
+ verisoned gems in as dependencies, and provides high-level methods for
11
+ constructing clients.
12
+
13
+ View the [Client Library Documentation](https://googleapis.dev/ruby/google-cloud-dialogflow/latest)
14
+ for this library, google-cloud-dialogflow, to see the convenience methods for
15
+ constructing client objects. Reference documentation for the client objects
16
+ themselves can be found in the client library documentation for the versioned
17
+ client gems:
18
+ [google-cloud-dialogflow-v2](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest).
19
+
20
+ See also the [Product Documentation](https://cloud.google.com/dialogflow)
21
+ for more usage information.
22
+
23
+ ## Quick Start
17
24
 
18
- ### Installation
19
25
  ```
20
26
  $ gem install google-cloud-dialogflow
21
27
  ```
22
28
 
23
- ### Next Steps
24
- - Read the [Client Library Documentation][] for Dialogflow API
25
- to see other available methods on the client.
26
- - Read the [Dialogflow API Product documentation][Product Documentation]
27
- to learn more about the product and see How-to Guides.
28
- - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
29
- to see the full list of Cloud APIs that we cover.
29
+ In order to use this library, you first need to go through the following steps:
30
+
31
+ 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
32
+ 1. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
33
+ 1. [Enable the API.](https://console.cloud.google.com/apis/library/dialogflow.googleapis.com)
34
+ 1. {file:AUTHENTICATION.md Set up authentication.}
35
+
36
+ ## Migrating from 0.x versions
30
37
 
31
- [Client Library Documentation]: https://googleapis.dev/ruby/google-cloud-dialogflow/latest
32
- [Product Documentation]: https://cloud.google.com/dialogflow
38
+ The 1.0 release of the google-cloud-dialogflow client is a significant upgrade
39
+ based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
40
+ and includes substantial interface changes. Existing code written for earlier
41
+ versions of this library will likely require updates to use this version.
42
+ See the {file:MIGRATING.md MIGRATING.md} document for more information.
33
43
 
34
44
  ## Enabling Logging
35
45
 
36
46
  To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
37
- The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
47
+ The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
38
48
  or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
39
- that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
49
+ that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
40
50
  and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
41
51
 
42
52
  Configuring a Ruby stdlib logger:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2020 Google LLC
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,18 +14,6 @@
12
14
  # See the License for the specific language governing permissions and
13
15
  # limitations under the License.
14
16
 
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
15
18
 
16
- module Google
17
- module Protobuf
18
- # A generic empty message that you can re-use to avoid defining duplicated
19
- # empty messages in your APIs. A typical example is to use it as the request
20
- # or the response type of an API method. For instance:
21
- #
22
- # service Foo {
23
- # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
24
- # }
25
- #
26
- # The JSON representation for `Empty` is empty JSON object `{}`.
27
- class Empty; end
28
- end
29
- end
19
+ require "google/cloud/dialogflow" unless defined? Google::Cloud::Dialogflow::VERSION
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2020 Google LLC
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,536 +14,396 @@
12
14
  # See the License for the specific language governing permissions and
13
15
  # limitations under the License.
14
16
 
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ # Require this file early so that the version constant gets defined before
20
+ # requiring "google/cloud". This is because google-cloud-core will load the
21
+ # entrypoint (gem name) file, which in turn re-requires this file (hence
22
+ # causing a require cycle) unless the version constant is already defined.
23
+ require "google/cloud/dialogflow/version"
15
24
 
16
- require "google/gax"
17
- require "pathname"
25
+ require "googleauth"
26
+ gem "google-cloud-core"
27
+ require "google/cloud" unless defined? ::Google::Cloud.new
28
+ require "google/cloud/config"
29
+
30
+ # Set the default configuration
31
+ ::Google::Cloud.configure.add_config! :dialogflow do |config|
32
+ config.add_field! :credentials, nil, match: [::String, ::Hash, ::Google::Auth::Credentials]
33
+ config.add_field! :lib_name, nil, match: ::String
34
+ config.add_field! :lib_version, nil, match: ::String
35
+ config.add_field! :interceptors, nil, match: ::Array
36
+ config.add_field! :timeout, nil, match: ::Numeric
37
+ config.add_field! :metadata, nil, match: ::Hash
38
+ config.add_field! :retry_policy, nil, match: [::Hash, ::Proc]
39
+ end
18
40
 
19
41
  module Google
20
42
  module Cloud
21
- # rubocop:disable LineLength
22
-
23
- ##
24
- # # Ruby Client for Dialogflow API
25
- #
26
- # [Dialogflow API][Product Documentation]:
27
- # Builds conversational interfaces (for example, chatbots, and voice-powered
28
- # apps and devices).
29
- # - [Product Documentation][]
30
- #
31
- # ## Quick Start
32
- # In order to use this library, you first need to go through the following
33
- # steps:
34
- #
35
- # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
36
- # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
37
- # 3. [Enable the Dialogflow API.](https://console.cloud.google.com/apis/library/dialogflow.googleapis.com)
38
- # 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-dialogflow/latest/file.AUTHENTICATION.html)
39
- #
40
- # ### Installation
41
- # ```
42
- # $ gem install google-cloud-dialogflow
43
- # ```
44
- #
45
- # ### Next Steps
46
- # - Read the [Dialogflow API Product documentation][Product Documentation]
47
- # to learn more about the product and see How-to Guides.
48
- # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
49
- # to see the full list of Cloud APIs that we cover.
50
- #
51
- # [Product Documentation]: https://cloud.google.com/dialogflow
52
- #
53
- # ## Enabling Logging
54
- #
55
- # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
56
- # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
57
- # or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
58
- # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
59
- # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
60
- #
61
- # Configuring a Ruby stdlib logger:
62
- #
63
- # ```ruby
64
- # require "logger"
65
- #
66
- # module MyLogger
67
- # LOGGER = Logger.new $stderr, level: Logger::WARN
68
- # def logger
69
- # LOGGER
70
- # end
71
- # end
72
- #
73
- # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
74
- # module GRPC
75
- # extend MyLogger
76
- # end
77
- # ```
78
- #
79
43
  module Dialogflow
80
- # rubocop:enable LineLength
44
+ ##
45
+ # Create a new client object for Agents.
46
+ #
47
+ # By default, this returns an instance of
48
+ # [Google::Cloud::Dialogflow::V2::Agents::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Agents/Client.html)
49
+ # for version V2 of the API.
50
+ # However, you can specify specify a different API version by passing it in the
51
+ # `version` parameter. If the Agents service is
52
+ # supported by that API version, and the corresponding gem is available, the
53
+ # appropriate versioned client will be returned.
54
+ #
55
+ # ## About Agents
56
+ #
57
+ # Agents are best described as Natural Language Understanding (NLU) modules
58
+ # that transform user requests into actionable data. You can include agents
59
+ # in your app, product, or service to determine user intent and respond to the
60
+ # user in a natural way.
61
+ #
62
+ # After you create an agent, you can add Intents, Contexts,
63
+ # Entity Types, Webhooks, and so on to
64
+ # manage the flow of a conversation and match user input to predefined intents
65
+ # and actions.
66
+ #
67
+ # You can create an agent using both Dialogflow Standard Edition and
68
+ # Dialogflow Enterprise Edition. For details, see
69
+ # [Dialogflow
70
+ # Editions](https://cloud.google.com/dialogflow/docs/editions).
71
+ #
72
+ # You can save your agent for backup or versioning by exporting the agent by
73
+ # using the ExportAgent method. You can import a saved
74
+ # agent by using the ImportAgent method.
75
+ #
76
+ # Dialogflow provides several
77
+ # [prebuilt
78
+ # agents](https://cloud.google.com/dialogflow/docs/agents-prebuilt)
79
+ # for common conversation scenarios such as determining a date and time,
80
+ # converting currency, and so on.
81
+ #
82
+ # For more information about agents, see the
83
+ # [Dialogflow
84
+ # documentation](https://cloud.google.com/dialogflow/docs/agents-overview).
85
+ #
86
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
87
+ # Defaults to `:v2`.
88
+ # @return [Agents::Client] A client object for the specified version.
89
+ #
90
+ def self.agents version: :v2, &block
91
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
92
+
93
+ package_name = Google::Cloud::Dialogflow
94
+ .constants
95
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
96
+ .first
97
+ package_module = Google::Cloud::Dialogflow.const_get package_name
98
+ package_module.const_get(:Agents).const_get(:Client).new(&block)
99
+ end
81
100
 
82
- FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("dialogflow"))
101
+ ##
102
+ # Create a new client object for Contexts.
103
+ #
104
+ # By default, this returns an instance of
105
+ # [Google::Cloud::Dialogflow::V2::Contexts::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Contexts/Client.html)
106
+ # for version V2 of the API.
107
+ # However, you can specify specify a different API version by passing it in the
108
+ # `version` parameter. If the Contexts service is
109
+ # supported by that API version, and the corresponding gem is available, the
110
+ # appropriate versioned client will be returned.
111
+ #
112
+ # ## About Contexts
113
+ #
114
+ # A context represents additional information included with user input or with
115
+ # an intent returned by the Dialogflow API. Contexts are helpful for
116
+ # differentiating user input which may be vague or have a different meaning
117
+ # depending on additional details from your application such as user setting
118
+ # and preferences, previous user input, where the user is in your application,
119
+ # geographic location, and so on.
120
+ #
121
+ # You can include contexts as input parameters of a
122
+ # DetectIntent (or
123
+ # StreamingDetectIntent) request,
124
+ # or as output contexts included in the returned intent.
125
+ # Contexts expire when an intent is matched, after the number of `DetectIntent`
126
+ # requests specified by the `lifespan_count` parameter, or after 20 minutes
127
+ # if no intents are matched for a `DetectIntent` request.
128
+ #
129
+ # For more information about contexts, see the
130
+ # [Dialogflow
131
+ # documentation](https://cloud.google.com/dialogflow/docs/contexts-overview).
132
+ #
133
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
134
+ # Defaults to `:v2`.
135
+ # @return [Contexts::Client] A client object for the specified version.
136
+ #
137
+ def self.contexts version: :v2, &block
138
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
83
139
 
84
- AVAILABLE_VERSIONS = Dir["#{FILE_DIR}/*"]
85
- .select { |file| File.directory?(file) }
86
- .select { |dir| Google::Gax::VERSION_MATCHER.match(File.basename(dir)) }
87
- .select { |dir| File.exist?(dir + ".rb") }
88
- .map { |dir| File.basename(dir) }
140
+ package_name = Google::Cloud::Dialogflow
141
+ .constants
142
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
143
+ .first
144
+ package_module = Google::Cloud::Dialogflow.const_get package_name
145
+ package_module.const_get(:Contexts).const_get(:Client).new(&block)
146
+ end
89
147
 
90
- module Agents
91
- ##
92
- # Agents are best described as Natural Language Understanding (NLU) modules
93
- # that transform user requests into actionable data. You can include agents
94
- # in your app, product, or service to determine user intent and respond to the
95
- # user in a natural way.
96
- #
97
- # After you create an agent, you can add {Google::Cloud::Dialogflow::V2::Intents Intents}, {Google::Cloud::Dialogflow::V2::Contexts Contexts},
98
- # {Google::Cloud::Dialogflow::V2::EntityTypes Entity Types}, {Google::Cloud::Dialogflow::V2::WebhookRequest Webhooks}, and so on to
99
- # manage the flow of a conversation and match user input to predefined intents
100
- # and actions.
101
- #
102
- # You can create an agent using both Dialogflow Standard Edition and
103
- # Dialogflow Enterprise Edition. For details, see
104
- # [Dialogflow
105
- # Editions](https://cloud.google.com/dialogflow/docs/editions).
106
- #
107
- # You can save your agent for backup or versioning by exporting the agent by
108
- # using the {Google::Cloud::Dialogflow::V2::Agents::ExportAgent ExportAgent} method. You can import a saved
109
- # agent by using the {Google::Cloud::Dialogflow::V2::Agents::ImportAgent ImportAgent} method.
110
- #
111
- # Dialogflow provides several
112
- # [prebuilt
113
- # agents](https://cloud.google.com/dialogflow/docs/agents-prebuilt)
114
- # for common conversation scenarios such as determining a date and time,
115
- # converting currency, and so on.
116
- #
117
- # For more information about agents, see the
118
- # [Dialogflow
119
- # documentation](https://cloud.google.com/dialogflow/docs/agents-overview).
120
- #
121
- # @param version [Symbol, String]
122
- # The major version of the service to be used. By default :v2
123
- # is used.
124
- # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
125
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
126
- # Provides the means for authenticating requests made by the client. This parameter can
127
- # be many types.
128
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
129
- # authenticating requests made by this client.
130
- # A `String` will be treated as the path to the keyfile to be used for the construction of
131
- # credentials for this client.
132
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
133
- # credentials for this client.
134
- # A `GRPC::Core::Channel` will be used to make calls through.
135
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
136
- # should already be composed with a `GRPC::Core::CallCredentials` object.
137
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
138
- # metadata for requests, generally, to give OAuth credentials.
139
- # @param scopes [Array<String>]
140
- # The OAuth scopes for this service. This parameter is ignored if
141
- # an updater_proc is supplied.
142
- # @param client_config [Hash]
143
- # A Hash for call options for each method. See
144
- # Google::Gax#construct_settings for the structure of
145
- # this data. Falls back to the default config if not specified
146
- # or the specified config is missing data points.
147
- # @param timeout [Numeric]
148
- # The default timeout, in seconds, for calls made through this client.
149
- # @param metadata [Hash]
150
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
151
- # @param service_address [String]
152
- # Override for the service hostname, or `nil` to leave as the default.
153
- # @param service_port [Integer]
154
- # Override for the service port, or `nil` to leave as the default.
155
- # @param exception_transformer [Proc]
156
- # An optional proc that intercepts any exceptions raised during an API call to inject
157
- # custom error handling.
158
- def self.new(*args, version: :v2, **kwargs)
159
- unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
160
- raise "The version: #{version} is not available. The available versions " \
161
- "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
162
- end
148
+ ##
149
+ # Create a new client object for EntityTypes.
150
+ #
151
+ # By default, this returns an instance of
152
+ # [Google::Cloud::Dialogflow::V2::EntityTypes::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/EntityTypes/Client.html)
153
+ # for version V2 of the API.
154
+ # However, you can specify specify a different API version by passing it in the
155
+ # `version` parameter. If the EntityTypes service is
156
+ # supported by that API version, and the corresponding gem is available, the
157
+ # appropriate versioned client will be returned.
158
+ #
159
+ # ## About EntityTypes
160
+ #
161
+ # Entities are extracted from user input and represent parameters that are
162
+ # meaningful to your application. For example, a date range, a proper name
163
+ # such as a geographic location or landmark, and so on. Entities represent
164
+ # actionable data for your application.
165
+ #
166
+ # When you define an entity, you can also include synonyms that all map to
167
+ # that entity. For example, "soft drink", "soda", "pop", and so on.
168
+ #
169
+ # There are three types of entities:
170
+ #
171
+ # * **System** - entities that are defined by the Dialogflow API for common
172
+ # data types such as date, time, currency, and so on. A system entity is
173
+ # represented by the `EntityType` type.
174
+ #
175
+ # * **Custom** - entities that are defined by you that represent
176
+ # actionable data that is meaningful to your application. For example,
177
+ # you could define a `pizza.sauce` entity for red or white pizza sauce,
178
+ # a `pizza.cheese` entity for the different types of cheese on a pizza,
179
+ # a `pizza.topping` entity for different toppings, and so on. A custom
180
+ # entity is represented by the `EntityType` type.
181
+ #
182
+ # * **User** - entities that are built for an individual user such as
183
+ # favorites, preferences, playlists, and so on. A user entity is
184
+ # represented by the SessionEntityType type.
185
+ #
186
+ # For more information about entity types, see the
187
+ # [Dialogflow
188
+ # documentation](https://cloud.google.com/dialogflow/docs/entities-overview).
189
+ #
190
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
191
+ # Defaults to `:v2`.
192
+ # @return [EntityTypes::Client] A client object for the specified version.
193
+ #
194
+ def self.entity_types version: :v2, &block
195
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
163
196
 
164
- require "#{FILE_DIR}/#{version.to_s.downcase}"
165
- version_module = Google::Cloud::Dialogflow
166
- .constants
167
- .select {|sym| sym.to_s.downcase == version.to_s.downcase}
168
- .first
169
- Google::Cloud::Dialogflow.const_get(version_module)::Agents.new(*args, **kwargs)
170
- end
197
+ package_name = Google::Cloud::Dialogflow
198
+ .constants
199
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
200
+ .first
201
+ package_module = Google::Cloud::Dialogflow.const_get package_name
202
+ package_module.const_get(:EntityTypes).const_get(:Client).new(&block)
171
203
  end
172
204
 
173
- module Contexts
174
- ##
175
- # A context represents additional information included with user input or with
176
- # an intent returned by the Dialogflow API. Contexts are helpful for
177
- # differentiating user input which may be vague or have a different meaning
178
- # depending on additional details from your application such as user setting
179
- # and preferences, previous user input, where the user is in your application,
180
- # geographic location, and so on.
181
- #
182
- # You can include contexts as input parameters of a
183
- # {Google::Cloud::Dialogflow::V2::Sessions::DetectIntent DetectIntent} (or
184
- # {Google::Cloud::Dialogflow::V2::Sessions::StreamingDetectIntent StreamingDetectIntent}) request,
185
- # or as output contexts included in the returned intent.
186
- # Contexts expire when an intent is matched, after the number of `DetectIntent`
187
- # requests specified by the `lifespan_count` parameter, or after 20 minutes
188
- # if no intents are matched for a `DetectIntent` request.
189
- #
190
- # For more information about contexts, see the
191
- # [Dialogflow
192
- # documentation](https://cloud.google.com/dialogflow/docs/contexts-overview).
193
- #
194
- # @param version [Symbol, String]
195
- # The major version of the service to be used. By default :v2
196
- # is used.
197
- # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
198
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
199
- # Provides the means for authenticating requests made by the client. This parameter can
200
- # be many types.
201
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
202
- # authenticating requests made by this client.
203
- # A `String` will be treated as the path to the keyfile to be used for the construction of
204
- # credentials for this client.
205
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
206
- # credentials for this client.
207
- # A `GRPC::Core::Channel` will be used to make calls through.
208
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
209
- # should already be composed with a `GRPC::Core::CallCredentials` object.
210
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
211
- # metadata for requests, generally, to give OAuth credentials.
212
- # @param scopes [Array<String>]
213
- # The OAuth scopes for this service. This parameter is ignored if
214
- # an updater_proc is supplied.
215
- # @param client_config [Hash]
216
- # A Hash for call options for each method. See
217
- # Google::Gax#construct_settings for the structure of
218
- # this data. Falls back to the default config if not specified
219
- # or the specified config is missing data points.
220
- # @param timeout [Numeric]
221
- # The default timeout, in seconds, for calls made through this client.
222
- # @param metadata [Hash]
223
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
224
- # @param service_address [String]
225
- # Override for the service hostname, or `nil` to leave as the default.
226
- # @param service_port [Integer]
227
- # Override for the service port, or `nil` to leave as the default.
228
- # @param exception_transformer [Proc]
229
- # An optional proc that intercepts any exceptions raised during an API call to inject
230
- # custom error handling.
231
- def self.new(*args, version: :v2, **kwargs)
232
- unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
233
- raise "The version: #{version} is not available. The available versions " \
234
- "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
235
- end
205
+ ##
206
+ # Create a new client object for Environments.
207
+ #
208
+ # By default, this returns an instance of
209
+ # [Google::Cloud::Dialogflow::V2::Environments::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Environments/Client.html)
210
+ # for version V2 of the API.
211
+ # However, you can specify specify a different API version by passing it in the
212
+ # `version` parameter. If the Environments service is
213
+ # supported by that API version, and the corresponding gem is available, the
214
+ # appropriate versioned client will be returned.
215
+ #
216
+ # ## About Environments
217
+ #
218
+ # Manages agent environments.
219
+ #
220
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
221
+ # Defaults to `:v2`.
222
+ # @return [Environments::Client] A client object for the specified version.
223
+ #
224
+ def self.environments version: :v2, &block
225
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
236
226
 
237
- require "#{FILE_DIR}/#{version.to_s.downcase}"
238
- version_module = Google::Cloud::Dialogflow
239
- .constants
240
- .select {|sym| sym.to_s.downcase == version.to_s.downcase}
241
- .first
242
- Google::Cloud::Dialogflow.const_get(version_module)::Contexts.new(*args, **kwargs)
243
- end
227
+ package_name = Google::Cloud::Dialogflow
228
+ .constants
229
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
230
+ .first
231
+ package_module = Google::Cloud::Dialogflow.const_get package_name
232
+ package_module.const_get(:Environments).const_get(:Client).new(&block)
244
233
  end
245
234
 
246
- module EntityTypes
247
- ##
248
- # Entities are extracted from user input and represent parameters that are
249
- # meaningful to your application. For example, a date range, a proper name
250
- # such as a geographic location or landmark, and so on. Entities represent
251
- # actionable data for your application.
252
- #
253
- # When you define an entity, you can also include synonyms that all map to
254
- # that entity. For example, "soft drink", "soda", "pop", and so on.
255
- #
256
- # There are three types of entities:
257
- #
258
- # * **System** - entities that are defined by the Dialogflow API for common
259
- # data types such as date, time, currency, and so on. A system entity is
260
- # represented by the `EntityType` type.
261
- #
262
- # * **Custom** - entities that are defined by you that represent
263
- # actionable data that is meaningful to your application. For example,
264
- # you could define a `pizza.sauce` entity for red or white pizza sauce,
265
- # a `pizza.cheese` entity for the different types of cheese on a pizza,
266
- # a `pizza.topping` entity for different toppings, and so on. A custom
267
- # entity is represented by the `EntityType` type.
268
- #
269
- # * **User** - entities that are built for an individual user such as
270
- # favorites, preferences, playlists, and so on. A user entity is
271
- # represented by the {Google::Cloud::Dialogflow::V2::SessionEntityType SessionEntityType} type.
272
- #
273
- # For more information about entity types, see the
274
- # [Dialogflow
275
- # documentation](https://cloud.google.com/dialogflow/docs/entities-overview).
276
- #
277
- # @param version [Symbol, String]
278
- # The major version of the service to be used. By default :v2
279
- # is used.
280
- # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
281
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
282
- # Provides the means for authenticating requests made by the client. This parameter can
283
- # be many types.
284
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
285
- # authenticating requests made by this client.
286
- # A `String` will be treated as the path to the keyfile to be used for the construction of
287
- # credentials for this client.
288
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
289
- # credentials for this client.
290
- # A `GRPC::Core::Channel` will be used to make calls through.
291
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
292
- # should already be composed with a `GRPC::Core::CallCredentials` object.
293
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
294
- # metadata for requests, generally, to give OAuth credentials.
295
- # @param scopes [Array<String>]
296
- # The OAuth scopes for this service. This parameter is ignored if
297
- # an updater_proc is supplied.
298
- # @param client_config [Hash]
299
- # A Hash for call options for each method. See
300
- # Google::Gax#construct_settings for the structure of
301
- # this data. Falls back to the default config if not specified
302
- # or the specified config is missing data points.
303
- # @param timeout [Numeric]
304
- # The default timeout, in seconds, for calls made through this client.
305
- # @param metadata [Hash]
306
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
307
- # @param service_address [String]
308
- # Override for the service hostname, or `nil` to leave as the default.
309
- # @param service_port [Integer]
310
- # Override for the service port, or `nil` to leave as the default.
311
- # @param exception_transformer [Proc]
312
- # An optional proc that intercepts any exceptions raised during an API call to inject
313
- # custom error handling.
314
- def self.new(*args, version: :v2, **kwargs)
315
- unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
316
- raise "The version: #{version} is not available. The available versions " \
317
- "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
318
- end
235
+ ##
236
+ # Create a new client object for Intents.
237
+ #
238
+ # By default, this returns an instance of
239
+ # [Google::Cloud::Dialogflow::V2::Intents::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Intents/Client.html)
240
+ # for version V2 of the API.
241
+ # However, you can specify specify a different API version by passing it in the
242
+ # `version` parameter. If the Intents service is
243
+ # supported by that API version, and the corresponding gem is available, the
244
+ # appropriate versioned client will be returned.
245
+ #
246
+ # ## About Intents
247
+ #
248
+ # An intent represents a mapping between input from a user and an action to
249
+ # be taken by your application. When you pass user input to the
250
+ # DetectIntent (or
251
+ # StreamingDetectIntent) method, the
252
+ # Dialogflow API analyzes the input and searches
253
+ # for a matching intent. If no match is found, the Dialogflow API returns a
254
+ # fallback intent (`is_fallback` = true).
255
+ #
256
+ # You can provide additional information for the Dialogflow API to use to
257
+ # match user input to an intent by adding the following to your intent.
258
+ #
259
+ # * **Contexts** - provide additional context for intent analysis. For
260
+ # example, if an intent is related to an object in your application that
261
+ # plays music, you can provide a context to determine when to match the
262
+ # intent if the user input is "turn it off". You can include a context
263
+ # that matches the intent when there is previous user input of
264
+ # "play music", and not when there is previous user input of
265
+ # "turn on the light".
266
+ #
267
+ # * **Events** - allow for matching an intent by using an event name
268
+ # instead of user input. Your application can provide an event name and
269
+ # related parameters to the Dialogflow API to match an intent. For
270
+ # example, when your application starts, you can send a welcome event
271
+ # with a user name parameter to the Dialogflow API to match an intent with
272
+ # a personalized welcome message for the user.
273
+ #
274
+ # * **Training phrases** - provide examples of user input to train the
275
+ # Dialogflow API agent to better match intents.
276
+ #
277
+ # For more information about intents, see the
278
+ # [Dialogflow
279
+ # documentation](https://cloud.google.com/dialogflow/docs/intents-overview).
280
+ #
281
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
282
+ # Defaults to `:v2`.
283
+ # @return [Intents::Client] A client object for the specified version.
284
+ #
285
+ def self.intents version: :v2, &block
286
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
319
287
 
320
- require "#{FILE_DIR}/#{version.to_s.downcase}"
321
- version_module = Google::Cloud::Dialogflow
322
- .constants
323
- .select {|sym| sym.to_s.downcase == version.to_s.downcase}
324
- .first
325
- Google::Cloud::Dialogflow.const_get(version_module)::EntityTypes.new(*args, **kwargs)
326
- end
288
+ package_name = Google::Cloud::Dialogflow
289
+ .constants
290
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
291
+ .first
292
+ package_module = Google::Cloud::Dialogflow.const_get package_name
293
+ package_module.const_get(:Intents).const_get(:Client).new(&block)
327
294
  end
328
295
 
329
- module Intents
330
- ##
331
- # An intent represents a mapping between input from a user and an action to
332
- # be taken by your application. When you pass user input to the
333
- # {Google::Cloud::Dialogflow::V2::Sessions::DetectIntent DetectIntent} (or
334
- # {Google::Cloud::Dialogflow::V2::Sessions::StreamingDetectIntent StreamingDetectIntent}) method, the
335
- # Dialogflow API analyzes the input and searches
336
- # for a matching intent. If no match is found, the Dialogflow API returns a
337
- # fallback intent (`is_fallback` = true).
338
- #
339
- # You can provide additional information for the Dialogflow API to use to
340
- # match user input to an intent by adding the following to your intent.
341
- #
342
- # * **Contexts** - provide additional context for intent analysis. For
343
- # example, if an intent is related to an object in your application that
344
- # plays music, you can provide a context to determine when to match the
345
- # intent if the user input is "turn it off". You can include a context
346
- # that matches the intent when there is previous user input of
347
- # "play music", and not when there is previous user input of
348
- # "turn on the light".
349
- #
350
- # * **Events** - allow for matching an intent by using an event name
351
- # instead of user input. Your application can provide an event name and
352
- # related parameters to the Dialogflow API to match an intent. For
353
- # example, when your application starts, you can send a welcome event
354
- # with a user name parameter to the Dialogflow API to match an intent with
355
- # a personalized welcome message for the user.
356
- #
357
- # * **Training phrases** - provide examples of user input to train the
358
- # Dialogflow API agent to better match intents.
359
- #
360
- # For more information about intents, see the
361
- # [Dialogflow
362
- # documentation](https://cloud.google.com/dialogflow/docs/intents-overview).
363
- #
364
- # @param version [Symbol, String]
365
- # The major version of the service to be used. By default :v2
366
- # is used.
367
- # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
368
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
369
- # Provides the means for authenticating requests made by the client. This parameter can
370
- # be many types.
371
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
372
- # authenticating requests made by this client.
373
- # A `String` will be treated as the path to the keyfile to be used for the construction of
374
- # credentials for this client.
375
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
376
- # credentials for this client.
377
- # A `GRPC::Core::Channel` will be used to make calls through.
378
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
379
- # should already be composed with a `GRPC::Core::CallCredentials` object.
380
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
381
- # metadata for requests, generally, to give OAuth credentials.
382
- # @param scopes [Array<String>]
383
- # The OAuth scopes for this service. This parameter is ignored if
384
- # an updater_proc is supplied.
385
- # @param client_config [Hash]
386
- # A Hash for call options for each method. See
387
- # Google::Gax#construct_settings for the structure of
388
- # this data. Falls back to the default config if not specified
389
- # or the specified config is missing data points.
390
- # @param timeout [Numeric]
391
- # The default timeout, in seconds, for calls made through this client.
392
- # @param metadata [Hash]
393
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
394
- # @param service_address [String]
395
- # Override for the service hostname, or `nil` to leave as the default.
396
- # @param service_port [Integer]
397
- # Override for the service port, or `nil` to leave as the default.
398
- # @param exception_transformer [Proc]
399
- # An optional proc that intercepts any exceptions raised during an API call to inject
400
- # custom error handling.
401
- def self.new(*args, version: :v2, **kwargs)
402
- unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
403
- raise "The version: #{version} is not available. The available versions " \
404
- "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
405
- end
296
+ ##
297
+ # Create a new client object for SessionEntityTypes.
298
+ #
299
+ # By default, this returns an instance of
300
+ # [Google::Cloud::Dialogflow::V2::SessionEntityTypes::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/SessionEntityTypes/Client.html)
301
+ # for version V2 of the API.
302
+ # However, you can specify specify a different API version by passing it in the
303
+ # `version` parameter. If the SessionEntityTypes service is
304
+ # supported by that API version, and the corresponding gem is available, the
305
+ # appropriate versioned client will be returned.
306
+ #
307
+ # ## About SessionEntityTypes
308
+ #
309
+ # Entities are extracted from user input and represent parameters that are
310
+ # meaningful to your application. For example, a date range, a proper name
311
+ # such as a geographic location or landmark, and so on. Entities represent
312
+ # actionable data for your application.
313
+ #
314
+ # Session entity types are referred to as **User** entity types and are
315
+ # entities that are built for an individual user such as
316
+ # favorites, preferences, playlists, and so on. You can redefine a session
317
+ # entity type at the session level.
318
+ #
319
+ # Session entity methods do not work with Google Assistant integration.
320
+ # Contact Dialogflow support if you need to use session entities
321
+ # with Google Assistant integration.
322
+ #
323
+ # For more information about entity types, see the
324
+ # [Dialogflow
325
+ # documentation](https://cloud.google.com/dialogflow/docs/entities-overview).
326
+ #
327
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
328
+ # Defaults to `:v2`.
329
+ # @return [SessionEntityTypes::Client] A client object for the specified version.
330
+ #
331
+ def self.session_entity_types version: :v2, &block
332
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
406
333
 
407
- require "#{FILE_DIR}/#{version.to_s.downcase}"
408
- version_module = Google::Cloud::Dialogflow
409
- .constants
410
- .select {|sym| sym.to_s.downcase == version.to_s.downcase}
411
- .first
412
- Google::Cloud::Dialogflow.const_get(version_module)::Intents.new(*args, **kwargs)
413
- end
334
+ package_name = Google::Cloud::Dialogflow
335
+ .constants
336
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
337
+ .first
338
+ package_module = Google::Cloud::Dialogflow.const_get package_name
339
+ package_module.const_get(:SessionEntityTypes).const_get(:Client).new(&block)
414
340
  end
415
341
 
416
- module SessionEntityTypes
417
- ##
418
- # Entities are extracted from user input and represent parameters that are
419
- # meaningful to your application. For example, a date range, a proper name
420
- # such as a geographic location or landmark, and so on. Entities represent
421
- # actionable data for your application.
422
- #
423
- # Session entity types are referred to as **User** entity types and are
424
- # entities that are built for an individual user such as
425
- # favorites, preferences, playlists, and so on. You can redefine a session
426
- # entity type at the session level.
427
- #
428
- # Session entity methods do not work with Google Assistant integration.
429
- # Contact Dialogflow support if you need to use session entities
430
- # with Google Assistant integration.
431
- #
432
- # For more information about entity types, see the
433
- # [Dialogflow
434
- # documentation](https://cloud.google.com/dialogflow/docs/entities-overview).
435
- #
436
- # @param version [Symbol, String]
437
- # The major version of the service to be used. By default :v2
438
- # is used.
439
- # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
440
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
441
- # Provides the means for authenticating requests made by the client. This parameter can
442
- # be many types.
443
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
444
- # authenticating requests made by this client.
445
- # A `String` will be treated as the path to the keyfile to be used for the construction of
446
- # credentials for this client.
447
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
448
- # credentials for this client.
449
- # A `GRPC::Core::Channel` will be used to make calls through.
450
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
451
- # should already be composed with a `GRPC::Core::CallCredentials` object.
452
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
453
- # metadata for requests, generally, to give OAuth credentials.
454
- # @param scopes [Array<String>]
455
- # The OAuth scopes for this service. This parameter is ignored if
456
- # an updater_proc is supplied.
457
- # @param client_config [Hash]
458
- # A Hash for call options for each method. See
459
- # Google::Gax#construct_settings for the structure of
460
- # this data. Falls back to the default config if not specified
461
- # or the specified config is missing data points.
462
- # @param timeout [Numeric]
463
- # The default timeout, in seconds, for calls made through this client.
464
- # @param metadata [Hash]
465
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
466
- # @param service_address [String]
467
- # Override for the service hostname, or `nil` to leave as the default.
468
- # @param service_port [Integer]
469
- # Override for the service port, or `nil` to leave as the default.
470
- # @param exception_transformer [Proc]
471
- # An optional proc that intercepts any exceptions raised during an API call to inject
472
- # custom error handling.
473
- def self.new(*args, version: :v2, **kwargs)
474
- unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
475
- raise "The version: #{version} is not available. The available versions " \
476
- "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
477
- end
342
+ ##
343
+ # Create a new client object for Sessions.
344
+ #
345
+ # By default, this returns an instance of
346
+ # [Google::Cloud::Dialogflow::V2::Sessions::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Sessions/Client.html)
347
+ # for version V2 of the API.
348
+ # However, you can specify specify a different API version by passing it in the
349
+ # `version` parameter. If the Sessions service is
350
+ # supported by that API version, and the corresponding gem is available, the
351
+ # appropriate versioned client will be returned.
352
+ #
353
+ # ## About Sessions
354
+ #
355
+ # A session represents an interaction with a user. You retrieve user input
356
+ # and pass it to the DetectIntent (or
357
+ # StreamingDetectIntent) method to determine
358
+ # user intent and respond.
359
+ #
360
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
361
+ # Defaults to `:v2`.
362
+ # @return [Sessions::Client] A client object for the specified version.
363
+ #
364
+ def self.sessions version: :v2, &block
365
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
478
366
 
479
- require "#{FILE_DIR}/#{version.to_s.downcase}"
480
- version_module = Google::Cloud::Dialogflow
481
- .constants
482
- .select {|sym| sym.to_s.downcase == version.to_s.downcase}
483
- .first
484
- Google::Cloud::Dialogflow.const_get(version_module)::SessionEntityTypes.new(*args, **kwargs)
485
- end
367
+ package_name = Google::Cloud::Dialogflow
368
+ .constants
369
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
370
+ .first
371
+ package_module = Google::Cloud::Dialogflow.const_get package_name
372
+ package_module.const_get(:Sessions).const_get(:Client).new(&block)
486
373
  end
487
374
 
488
- module Sessions
489
- ##
490
- # A session represents an interaction with a user. You retrieve user input
491
- # and pass it to the {Google::Cloud::Dialogflow::V2::Sessions::DetectIntent DetectIntent} (or
492
- # {Google::Cloud::Dialogflow::V2::Sessions::StreamingDetectIntent StreamingDetectIntent}) method to determine
493
- # user intent and respond.
494
- #
495
- # @param version [Symbol, String]
496
- # The major version of the service to be used. By default :v2
497
- # is used.
498
- # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
499
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
500
- # Provides the means for authenticating requests made by the client. This parameter can
501
- # be many types.
502
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
503
- # authenticating requests made by this client.
504
- # A `String` will be treated as the path to the keyfile to be used for the construction of
505
- # credentials for this client.
506
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
507
- # credentials for this client.
508
- # A `GRPC::Core::Channel` will be used to make calls through.
509
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
510
- # should already be composed with a `GRPC::Core::CallCredentials` object.
511
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
512
- # metadata for requests, generally, to give OAuth credentials.
513
- # @param scopes [Array<String>]
514
- # The OAuth scopes for this service. This parameter is ignored if
515
- # an updater_proc is supplied.
516
- # @param client_config [Hash]
517
- # A Hash for call options for each method. See
518
- # Google::Gax#construct_settings for the structure of
519
- # this data. Falls back to the default config if not specified
520
- # or the specified config is missing data points.
521
- # @param timeout [Numeric]
522
- # The default timeout, in seconds, for calls made through this client.
523
- # @param metadata [Hash]
524
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
525
- # @param service_address [String]
526
- # Override for the service hostname, or `nil` to leave as the default.
527
- # @param service_port [Integer]
528
- # Override for the service port, or `nil` to leave as the default.
529
- # @param exception_transformer [Proc]
530
- # An optional proc that intercepts any exceptions raised during an API call to inject
531
- # custom error handling.
532
- def self.new(*args, version: :v2, **kwargs)
533
- unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
534
- raise "The version: #{version} is not available. The available versions " \
535
- "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
536
- end
375
+ ##
376
+ # Configure the google-cloud-dialogflow library.
377
+ #
378
+ # The following configuration parameters are supported:
379
+ #
380
+ # * `credentials` (*type:* `String, Hash, Google::Auth::Credentials`) -
381
+ # The path to the keyfile as a String, the contents of the keyfile as a
382
+ # Hash, or a Google::Auth::Credentials object.
383
+ # * `lib_name` (*type:* `String`) -
384
+ # The library name as recorded in instrumentation and logging.
385
+ # * `lib_version` (*type:* `String`) -
386
+ # The library version as recorded in instrumentation and logging.
387
+ # * `interceptors` (*type:* `Array<GRPC::ClientInterceptor>`) -
388
+ # An array of interceptors that are run before calls are executed.
389
+ # * `timeout` (*type:* `Integer`) -
390
+ # Default timeout in milliseconds.
391
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) -
392
+ # Additional gRPC headers to be sent with the call.
393
+ # * `retry_policy` (*type:* `Hash`) -
394
+ # The retry policy. The value is a hash with the following keys:
395
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
396
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
397
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
398
+ # * `:retry_codes` (*type:* `Array<String>`) -
399
+ # The error codes that should trigger a retry.
400
+ #
401
+ # @return [::Google::Cloud::Config] The default configuration used by this library
402
+ #
403
+ def self.configure
404
+ yield ::Google::Cloud.configure.dialogflow if block_given?
537
405
 
538
- require "#{FILE_DIR}/#{version.to_s.downcase}"
539
- version_module = Google::Cloud::Dialogflow
540
- .constants
541
- .select {|sym| sym.to_s.downcase == version.to_s.downcase}
542
- .first
543
- Google::Cloud::Dialogflow.const_get(version_module)::Sessions.new(*args, **kwargs)
544
- end
406
+ ::Google::Cloud.configure.dialogflow
545
407
  end
546
408
  end
547
409
  end