google-cloud-dialogflow 0.13.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) 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 +445 -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 +374 -506
  9. data/lib/google/cloud/dialogflow/version.rb +1 -1
  10. metadata +62 -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 -115
  14. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +0 -109
  15. data/lib/google/cloud/dialogflow/v2/agents_client.rb +0 -760
  16. data/lib/google/cloud/dialogflow/v2/agents_client_config.json +0 -66
  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 -76
  20. data/lib/google/cloud/dialogflow/v2/contexts_client.rb +0 -519
  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 -233
  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 -482
  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/longrunning/operations.rb +0 -51
  31. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/any.rb +0 -131
  32. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/duration.rb +0 -91
  33. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/field_mask.rb +0 -222
  34. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/struct.rb +0 -74
  35. data/lib/google/cloud/dialogflow/v2/doc/google/rpc/status.rb +0 -39
  36. data/lib/google/cloud/dialogflow/v2/doc/google/type/latlng.rb +0 -31
  37. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +0 -125
  38. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +0 -106
  39. data/lib/google/cloud/dialogflow/v2/entity_types_client.rb +0 -994
  40. data/lib/google/cloud/dialogflow/v2/entity_types_client_config.json +0 -76
  41. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +0 -367
  42. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +0 -94
  43. data/lib/google/cloud/dialogflow/v2/intents_client.rb +0 -760
  44. data/lib/google/cloud/dialogflow/v2/intents_client_config.json +0 -61
  45. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +0 -65
  46. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +0 -94
  47. data/lib/google/cloud/dialogflow/v2/session_entity_types_client.rb +0 -504
  48. data/lib/google/cloud/dialogflow/v2/session_entity_types_client_config.json +0 -51
  49. data/lib/google/cloud/dialogflow/v2/session_pb.rb +0 -138
  50. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +0 -57
  51. data/lib/google/cloud/dialogflow/v2/sessions_client.rb +0 -326
  52. data/lib/google/cloud/dialogflow/v2/sessions_client_config.json +0 -36
  53. 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 ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
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,537 +14,403 @@
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! :endpoint, "dialogflow.googleapis.com", match: ::String
33
+ config.add_field! :credentials, nil, match: [::String, ::Hash, ::Google::Auth::Credentials]
34
+ config.add_field! :scope, nil, match: [::Array, ::String]
35
+ config.add_field! :lib_name, nil, match: ::String
36
+ config.add_field! :lib_version, nil, match: ::String
37
+ config.add_field! :interceptors, nil, match: ::Array
38
+ config.add_field! :timeout, nil, match: ::Numeric
39
+ config.add_field! :metadata, nil, match: ::Hash
40
+ config.add_field! :retry_policy, nil, match: [::Hash, ::Proc]
41
+ config.add_field! :quota_project, nil, match: ::String
42
+ end
18
43
 
19
44
  module Google
20
45
  module Cloud
21
- # rubocop:disable LineLength
22
-
23
- ##
24
- # # Ruby Client for Dialogflow API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
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
46
  module Dialogflow
80
- # rubocop:enable LineLength
47
+ ##
48
+ # Create a new client object for Agents.
49
+ #
50
+ # By default, this returns an instance of
51
+ # [Google::Cloud::Dialogflow::V2::Agents::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Agents/Client.html)
52
+ # for version V2 of the API.
53
+ # However, you can specify specify a different API version by passing it in the
54
+ # `version` parameter. If the Agents service is
55
+ # supported by that API version, and the corresponding gem is available, the
56
+ # appropriate versioned client will be returned.
57
+ #
58
+ # ## About Agents
59
+ #
60
+ # Agents are best described as Natural Language Understanding (NLU) modules
61
+ # that transform user requests into actionable data. You can include agents
62
+ # in your app, product, or service to determine user intent and respond to the
63
+ # user in a natural way.
64
+ #
65
+ # After you create an agent, you can add Intents, Contexts,
66
+ # Entity Types, Webhooks, and so on to
67
+ # manage the flow of a conversation and match user input to predefined intents
68
+ # and actions.
69
+ #
70
+ # You can create an agent using both Dialogflow Standard Edition and
71
+ # Dialogflow Enterprise Edition. For details, see
72
+ # [Dialogflow
73
+ # Editions](https://cloud.google.com/dialogflow/docs/editions).
74
+ #
75
+ # You can save your agent for backup or versioning by exporting the agent by
76
+ # using the ExportAgent method. You can import a saved
77
+ # agent by using the ImportAgent method.
78
+ #
79
+ # Dialogflow provides several
80
+ # [prebuilt
81
+ # agents](https://cloud.google.com/dialogflow/docs/agents-prebuilt)
82
+ # for common conversation scenarios such as determining a date and time,
83
+ # converting currency, and so on.
84
+ #
85
+ # For more information about agents, see the
86
+ # [Dialogflow
87
+ # documentation](https://cloud.google.com/dialogflow/docs/agents-overview).
88
+ #
89
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
90
+ # Defaults to `:v2`.
91
+ # @return [Agents::Client] A client object for the specified version.
92
+ #
93
+ def self.agents version: :v2, &block
94
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
81
95
 
82
- FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("dialogflow"))
96
+ package_name = Google::Cloud::Dialogflow
97
+ .constants
98
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
99
+ .first
100
+ package_module = Google::Cloud::Dialogflow.const_get package_name
101
+ package_module.const_get(:Agents).const_get(:Client).new(&block)
102
+ end
103
+
104
+ ##
105
+ # Create a new client object for Contexts.
106
+ #
107
+ # By default, this returns an instance of
108
+ # [Google::Cloud::Dialogflow::V2::Contexts::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Contexts/Client.html)
109
+ # for version V2 of the API.
110
+ # However, you can specify specify a different API version by passing it in the
111
+ # `version` parameter. If the Contexts service is
112
+ # supported by that API version, and the corresponding gem is available, the
113
+ # appropriate versioned client will be returned.
114
+ #
115
+ # ## About Contexts
116
+ #
117
+ # A context represents additional information included with user input or with
118
+ # an intent returned by the Dialogflow API. Contexts are helpful for
119
+ # differentiating user input which may be vague or have a different meaning
120
+ # depending on additional details from your application such as user setting
121
+ # and preferences, previous user input, where the user is in your application,
122
+ # geographic location, and so on.
123
+ #
124
+ # You can include contexts as input parameters of a
125
+ # DetectIntent (or
126
+ # StreamingDetectIntent) request,
127
+ # or as output contexts included in the returned intent.
128
+ # Contexts expire when an intent is matched, after the number of `DetectIntent`
129
+ # requests specified by the `lifespan_count` parameter, or after 20 minutes
130
+ # if no intents are matched for a `DetectIntent` request.
131
+ #
132
+ # For more information about contexts, see the
133
+ # [Dialogflow
134
+ # documentation](https://cloud.google.com/dialogflow/docs/contexts-overview).
135
+ #
136
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
137
+ # Defaults to `:v2`.
138
+ # @return [Contexts::Client] A client object for the specified version.
139
+ #
140
+ def self.contexts version: :v2, &block
141
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
83
142
 
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) }
143
+ package_name = Google::Cloud::Dialogflow
144
+ .constants
145
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
146
+ .first
147
+ package_module = Google::Cloud::Dialogflow.const_get package_name
148
+ package_module.const_get(:Contexts).const_get(:Client).new(&block)
149
+ end
89
150
 
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
151
+ ##
152
+ # Create a new client object for EntityTypes.
153
+ #
154
+ # By default, this returns an instance of
155
+ # [Google::Cloud::Dialogflow::V2::EntityTypes::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/EntityTypes/Client.html)
156
+ # for version V2 of the API.
157
+ # However, you can specify specify a different API version by passing it in the
158
+ # `version` parameter. If the EntityTypes service is
159
+ # supported by that API version, and the corresponding gem is available, the
160
+ # appropriate versioned client will be returned.
161
+ #
162
+ # ## About EntityTypes
163
+ #
164
+ # Entities are extracted from user input and represent parameters that are
165
+ # meaningful to your application. For example, a date range, a proper name
166
+ # such as a geographic location or landmark, and so on. Entities represent
167
+ # actionable data for your application.
168
+ #
169
+ # When you define an entity, you can also include synonyms that all map to
170
+ # that entity. For example, "soft drink", "soda", "pop", and so on.
171
+ #
172
+ # There are three types of entities:
173
+ #
174
+ # * **System** - entities that are defined by the Dialogflow API for common
175
+ # data types such as date, time, currency, and so on. A system entity is
176
+ # represented by the `EntityType` type.
177
+ #
178
+ # * **Custom** - entities that are defined by you that represent
179
+ # actionable data that is meaningful to your application. For example,
180
+ # you could define a `pizza.sauce` entity for red or white pizza sauce,
181
+ # a `pizza.cheese` entity for the different types of cheese on a pizza,
182
+ # a `pizza.topping` entity for different toppings, and so on. A custom
183
+ # entity is represented by the `EntityType` type.
184
+ #
185
+ # * **User** - entities that are built for an individual user such as
186
+ # favorites, preferences, playlists, and so on. A user entity is
187
+ # represented by the SessionEntityType type.
188
+ #
189
+ # For more information about entity types, see the
190
+ # [Dialogflow
191
+ # documentation](https://cloud.google.com/dialogflow/docs/entities-overview).
192
+ #
193
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
194
+ # Defaults to `:v2`.
195
+ # @return [EntityTypes::Client] A client object for the specified version.
196
+ #
197
+ def self.entity_types version: :v2, &block
198
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
163
199
 
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
200
+ package_name = Google::Cloud::Dialogflow
201
+ .constants
202
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
203
+ .first
204
+ package_module = Google::Cloud::Dialogflow.const_get package_name
205
+ package_module.const_get(:EntityTypes).const_get(:Client).new(&block)
171
206
  end
172
207
 
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
208
+ ##
209
+ # Create a new client object for Environments.
210
+ #
211
+ # By default, this returns an instance of
212
+ # [Google::Cloud::Dialogflow::V2::Environments::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Environments/Client.html)
213
+ # for version V2 of the API.
214
+ # However, you can specify specify a different API version by passing it in the
215
+ # `version` parameter. If the Environments service is
216
+ # supported by that API version, and the corresponding gem is available, the
217
+ # appropriate versioned client will be returned.
218
+ #
219
+ # ## About Environments
220
+ #
221
+ # Manages agent environments.
222
+ #
223
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
224
+ # Defaults to `:v2`.
225
+ # @return [Environments::Client] A client object for the specified version.
226
+ #
227
+ def self.environments version: :v2, &block
228
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
236
229
 
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
230
+ package_name = Google::Cloud::Dialogflow
231
+ .constants
232
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
233
+ .first
234
+ package_module = Google::Cloud::Dialogflow.const_get package_name
235
+ package_module.const_get(:Environments).const_get(:Client).new(&block)
244
236
  end
245
237
 
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
238
+ ##
239
+ # Create a new client object for Intents.
240
+ #
241
+ # By default, this returns an instance of
242
+ # [Google::Cloud::Dialogflow::V2::Intents::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Intents/Client.html)
243
+ # for version V2 of the API.
244
+ # However, you can specify specify a different API version by passing it in the
245
+ # `version` parameter. If the Intents service is
246
+ # supported by that API version, and the corresponding gem is available, the
247
+ # appropriate versioned client will be returned.
248
+ #
249
+ # ## About Intents
250
+ #
251
+ # An intent represents a mapping between input from a user and an action to
252
+ # be taken by your application. When you pass user input to the
253
+ # DetectIntent (or
254
+ # StreamingDetectIntent) method, the
255
+ # Dialogflow API analyzes the input and searches
256
+ # for a matching intent. If no match is found, the Dialogflow API returns a
257
+ # fallback intent (`is_fallback` = true).
258
+ #
259
+ # You can provide additional information for the Dialogflow API to use to
260
+ # match user input to an intent by adding the following to your intent.
261
+ #
262
+ # * **Contexts** - provide additional context for intent analysis. For
263
+ # example, if an intent is related to an object in your application that
264
+ # plays music, you can provide a context to determine when to match the
265
+ # intent if the user input is "turn it off". You can include a context
266
+ # that matches the intent when there is previous user input of
267
+ # "play music", and not when there is previous user input of
268
+ # "turn on the light".
269
+ #
270
+ # * **Events** - allow for matching an intent by using an event name
271
+ # instead of user input. Your application can provide an event name and
272
+ # related parameters to the Dialogflow API to match an intent. For
273
+ # example, when your application starts, you can send a welcome event
274
+ # with a user name parameter to the Dialogflow API to match an intent with
275
+ # a personalized welcome message for the user.
276
+ #
277
+ # * **Training phrases** - provide examples of user input to train the
278
+ # Dialogflow API agent to better match intents.
279
+ #
280
+ # For more information about intents, see the
281
+ # [Dialogflow
282
+ # documentation](https://cloud.google.com/dialogflow/docs/intents-overview).
283
+ #
284
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
285
+ # Defaults to `:v2`.
286
+ # @return [Intents::Client] A client object for the specified version.
287
+ #
288
+ def self.intents version: :v2, &block
289
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
319
290
 
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
291
+ package_name = Google::Cloud::Dialogflow
292
+ .constants
293
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
294
+ .first
295
+ package_module = Google::Cloud::Dialogflow.const_get package_name
296
+ package_module.const_get(:Intents).const_get(:Client).new(&block)
327
297
  end
328
298
 
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
299
+ ##
300
+ # Create a new client object for SessionEntityTypes.
301
+ #
302
+ # By default, this returns an instance of
303
+ # [Google::Cloud::Dialogflow::V2::SessionEntityTypes::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/SessionEntityTypes/Client.html)
304
+ # for version V2 of the API.
305
+ # However, you can specify specify a different API version by passing it in the
306
+ # `version` parameter. If the SessionEntityTypes service is
307
+ # supported by that API version, and the corresponding gem is available, the
308
+ # appropriate versioned client will be returned.
309
+ #
310
+ # ## About SessionEntityTypes
311
+ #
312
+ # Entities are extracted from user input and represent parameters that are
313
+ # meaningful to your application. For example, a date range, a proper name
314
+ # such as a geographic location or landmark, and so on. Entities represent
315
+ # actionable data for your application.
316
+ #
317
+ # Session entity types are referred to as **User** entity types and are
318
+ # entities that are built for an individual user such as
319
+ # favorites, preferences, playlists, and so on. You can redefine a session
320
+ # entity type at the session level.
321
+ #
322
+ # Session entity methods do not work with Google Assistant integration.
323
+ # Contact Dialogflow support if you need to use session entities
324
+ # with Google Assistant integration.
325
+ #
326
+ # For more information about entity types, see the
327
+ # [Dialogflow
328
+ # documentation](https://cloud.google.com/dialogflow/docs/entities-overview).
329
+ #
330
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
331
+ # Defaults to `:v2`.
332
+ # @return [SessionEntityTypes::Client] A client object for the specified version.
333
+ #
334
+ def self.session_entity_types version: :v2, &block
335
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
406
336
 
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
337
+ package_name = Google::Cloud::Dialogflow
338
+ .constants
339
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
340
+ .first
341
+ package_module = Google::Cloud::Dialogflow.const_get package_name
342
+ package_module.const_get(:SessionEntityTypes).const_get(:Client).new(&block)
414
343
  end
415
344
 
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
345
+ ##
346
+ # Create a new client object for Sessions.
347
+ #
348
+ # By default, this returns an instance of
349
+ # [Google::Cloud::Dialogflow::V2::Sessions::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Sessions/Client.html)
350
+ # for version V2 of the API.
351
+ # However, you can specify specify a different API version by passing it in the
352
+ # `version` parameter. If the Sessions service is
353
+ # supported by that API version, and the corresponding gem is available, the
354
+ # appropriate versioned client will be returned.
355
+ #
356
+ # ## About Sessions
357
+ #
358
+ # A session represents an interaction with a user. You retrieve user input
359
+ # and pass it to the DetectIntent (or
360
+ # StreamingDetectIntent) method to determine
361
+ # user intent and respond.
362
+ #
363
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
364
+ # Defaults to `:v2`.
365
+ # @return [Sessions::Client] A client object for the specified version.
366
+ #
367
+ def self.sessions version: :v2, &block
368
+ require "google/cloud/dialogflow/#{version.to_s.downcase}"
478
369
 
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
370
+ package_name = Google::Cloud::Dialogflow
371
+ .constants
372
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
373
+ .first
374
+ package_module = Google::Cloud::Dialogflow.const_get package_name
375
+ package_module.const_get(:Sessions).const_get(:Client).new(&block)
486
376
  end
487
377
 
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
378
+ ##
379
+ # Configure the google-cloud-dialogflow library.
380
+ #
381
+ # The following configuration parameters are supported:
382
+ #
383
+ # * `credentials` (*type:* `String, Hash, Google::Auth::Credentials`) -
384
+ # The path to the keyfile as a String, the contents of the keyfile as a
385
+ # Hash, or a Google::Auth::Credentials object.
386
+ # * `lib_name` (*type:* `String`) -
387
+ # The library name as recorded in instrumentation and logging.
388
+ # * `lib_version` (*type:* `String`) -
389
+ # The library version as recorded in instrumentation and logging.
390
+ # * `interceptors` (*type:* `Array<GRPC::ClientInterceptor>`) -
391
+ # An array of interceptors that are run before calls are executed.
392
+ # * `timeout` (*type:* `Integer`) -
393
+ # Default timeout in milliseconds.
394
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) -
395
+ # Additional gRPC headers to be sent with the call.
396
+ # * `retry_policy` (*type:* `Hash`) -
397
+ # The retry policy. The value is a hash with the following keys:
398
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
399
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
400
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
401
+ # * `:retry_codes` (*type:* `Array<String>`) -
402
+ # The error codes that should trigger a retry.
403
+ #
404
+ # @return [::Google::Cloud::Config] The default configuration used by this library
405
+ #
406
+ def self.configure
407
+ yield ::Google::Cloud.configure.dialogflow if block_given?
537
408
 
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
409
+ ::Google::Cloud.configure.dialogflow
545
410
  end
546
411
  end
547
412
  end
548
413
  end
414
+
415
+ helper_path = ::File.join __dir__, "dialogflow", "helpers.rb"
416
+ require "google/cloud/dialogflow/helpers" if ::File.file? helper_path