# frozen_string_literal: true # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Auto-generated by gapic-generator-ruby. DO NOT EDIT! # Require this file early so that the version constant gets defined before # requiring "google/cloud". This is because google-cloud-core will load the # entrypoint (gem name) file, which in turn re-requires this file (hence # causing a require cycle) unless the version constant is already defined. require "google/cloud/dialogflow/version" require "googleauth" gem "google-cloud-core" require "google/cloud" unless defined? ::Google::Cloud.new require "google/cloud/config" # Set the default configuration ::Google::Cloud.configure.add_config! :dialogflow do |config| config.add_field! :credentials, nil, match: [::String, ::Hash, ::Google::Auth::Credentials] config.add_field! :lib_name, nil, match: ::String config.add_field! :lib_version, nil, match: ::String config.add_field! :interceptors, nil, match: ::Array config.add_field! :timeout, nil, match: ::Numeric config.add_field! :metadata, nil, match: ::Hash config.add_field! :retry_policy, nil, match: [::Hash, ::Proc] end module Google module Cloud module Dialogflow ## # Create a new client object for Agents. # # By default, this returns an instance of # [Google::Cloud::Dialogflow::V2::Agents::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Agents/Client.html) # for version V2 of the API. # However, you can specify specify a different API version by passing it in the # `version` parameter. If the Agents service is # supported by that API version, and the corresponding gem is available, the # appropriate versioned client will be returned. # # ## About Agents # # Agents are best described as Natural Language Understanding (NLU) modules # that transform user requests into actionable data. You can include agents # in your app, product, or service to determine user intent and respond to the # user in a natural way. # # After you create an agent, you can add Intents, Contexts, # Entity Types, Webhooks, and so on to # manage the flow of a conversation and match user input to predefined intents # and actions. # # You can create an agent using both Dialogflow Standard Edition and # Dialogflow Enterprise Edition. For details, see # [Dialogflow # Editions](https://cloud.google.com/dialogflow/docs/editions). # # You can save your agent for backup or versioning by exporting the agent by # using the ExportAgent method. You can import a saved # agent by using the ImportAgent method. # # Dialogflow provides several # [prebuilt # agents](https://cloud.google.com/dialogflow/docs/agents-prebuilt) # for common conversation scenarios such as determining a date and time, # converting currency, and so on. # # For more information about agents, see the # [Dialogflow # documentation](https://cloud.google.com/dialogflow/docs/agents-overview). # # @param version [::String, ::Symbol] The API version to connect to. Optional. # Defaults to `:v2`. # @return [Agents::Client] A client object for the specified version. # def self.agents version: :v2, &block require "google/cloud/dialogflow/#{version.to_s.downcase}" package_name = Google::Cloud::Dialogflow .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first package_module = Google::Cloud::Dialogflow.const_get package_name package_module.const_get(:Agents).const_get(:Client).new(&block) end ## # Create a new client object for Contexts. # # By default, this returns an instance of # [Google::Cloud::Dialogflow::V2::Contexts::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Contexts/Client.html) # for version V2 of the API. # However, you can specify specify a different API version by passing it in the # `version` parameter. If the Contexts service is # supported by that API version, and the corresponding gem is available, the # appropriate versioned client will be returned. # # ## About Contexts # # A context represents additional information included with user input or with # an intent returned by the Dialogflow API. Contexts are helpful for # differentiating user input which may be vague or have a different meaning # depending on additional details from your application such as user setting # and preferences, previous user input, where the user is in your application, # geographic location, and so on. # # You can include contexts as input parameters of a # DetectIntent (or # StreamingDetectIntent) request, # or as output contexts included in the returned intent. # Contexts expire when an intent is matched, after the number of `DetectIntent` # requests specified by the `lifespan_count` parameter, or after 20 minutes # if no intents are matched for a `DetectIntent` request. # # For more information about contexts, see the # [Dialogflow # documentation](https://cloud.google.com/dialogflow/docs/contexts-overview). # # @param version [::String, ::Symbol] The API version to connect to. Optional. # Defaults to `:v2`. # @return [Contexts::Client] A client object for the specified version. # def self.contexts version: :v2, &block require "google/cloud/dialogflow/#{version.to_s.downcase}" package_name = Google::Cloud::Dialogflow .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first package_module = Google::Cloud::Dialogflow.const_get package_name package_module.const_get(:Contexts).const_get(:Client).new(&block) end ## # Create a new client object for EntityTypes. # # By default, this returns an instance of # [Google::Cloud::Dialogflow::V2::EntityTypes::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/EntityTypes/Client.html) # for version V2 of the API. # However, you can specify specify a different API version by passing it in the # `version` parameter. If the EntityTypes service is # supported by that API version, and the corresponding gem is available, the # appropriate versioned client will be returned. # # ## About EntityTypes # # Entities are extracted from user input and represent parameters that are # meaningful to your application. For example, a date range, a proper name # such as a geographic location or landmark, and so on. Entities represent # actionable data for your application. # # When you define an entity, you can also include synonyms that all map to # that entity. For example, "soft drink", "soda", "pop", and so on. # # There are three types of entities: # # * **System** - entities that are defined by the Dialogflow API for common # data types such as date, time, currency, and so on. A system entity is # represented by the `EntityType` type. # # * **Custom** - entities that are defined by you that represent # actionable data that is meaningful to your application. For example, # you could define a `pizza.sauce` entity for red or white pizza sauce, # a `pizza.cheese` entity for the different types of cheese on a pizza, # a `pizza.topping` entity for different toppings, and so on. A custom # entity is represented by the `EntityType` type. # # * **User** - entities that are built for an individual user such as # favorites, preferences, playlists, and so on. A user entity is # represented by the SessionEntityType type. # # For more information about entity types, see the # [Dialogflow # documentation](https://cloud.google.com/dialogflow/docs/entities-overview). # # @param version [::String, ::Symbol] The API version to connect to. Optional. # Defaults to `:v2`. # @return [EntityTypes::Client] A client object for the specified version. # def self.entity_types version: :v2, &block require "google/cloud/dialogflow/#{version.to_s.downcase}" package_name = Google::Cloud::Dialogflow .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first package_module = Google::Cloud::Dialogflow.const_get package_name package_module.const_get(:EntityTypes).const_get(:Client).new(&block) end ## # Create a new client object for Environments. # # By default, this returns an instance of # [Google::Cloud::Dialogflow::V2::Environments::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Environments/Client.html) # for version V2 of the API. # However, you can specify specify a different API version by passing it in the # `version` parameter. If the Environments service is # supported by that API version, and the corresponding gem is available, the # appropriate versioned client will be returned. # # ## About Environments # # Manages agent environments. # # @param version [::String, ::Symbol] The API version to connect to. Optional. # Defaults to `:v2`. # @return [Environments::Client] A client object for the specified version. # def self.environments version: :v2, &block require "google/cloud/dialogflow/#{version.to_s.downcase}" package_name = Google::Cloud::Dialogflow .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first package_module = Google::Cloud::Dialogflow.const_get package_name package_module.const_get(:Environments).const_get(:Client).new(&block) end ## # Create a new client object for Intents. # # By default, this returns an instance of # [Google::Cloud::Dialogflow::V2::Intents::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Intents/Client.html) # for version V2 of the API. # However, you can specify specify a different API version by passing it in the # `version` parameter. If the Intents service is # supported by that API version, and the corresponding gem is available, the # appropriate versioned client will be returned. # # ## About Intents # # An intent represents a mapping between input from a user and an action to # be taken by your application. When you pass user input to the # DetectIntent (or # StreamingDetectIntent) method, the # Dialogflow API analyzes the input and searches # for a matching intent. If no match is found, the Dialogflow API returns a # fallback intent (`is_fallback` = true). # # You can provide additional information for the Dialogflow API to use to # match user input to an intent by adding the following to your intent. # # * **Contexts** - provide additional context for intent analysis. For # example, if an intent is related to an object in your application that # plays music, you can provide a context to determine when to match the # intent if the user input is "turn it off". You can include a context # that matches the intent when there is previous user input of # "play music", and not when there is previous user input of # "turn on the light". # # * **Events** - allow for matching an intent by using an event name # instead of user input. Your application can provide an event name and # related parameters to the Dialogflow API to match an intent. For # example, when your application starts, you can send a welcome event # with a user name parameter to the Dialogflow API to match an intent with # a personalized welcome message for the user. # # * **Training phrases** - provide examples of user input to train the # Dialogflow API agent to better match intents. # # For more information about intents, see the # [Dialogflow # documentation](https://cloud.google.com/dialogflow/docs/intents-overview). # # @param version [::String, ::Symbol] The API version to connect to. Optional. # Defaults to `:v2`. # @return [Intents::Client] A client object for the specified version. # def self.intents version: :v2, &block require "google/cloud/dialogflow/#{version.to_s.downcase}" package_name = Google::Cloud::Dialogflow .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first package_module = Google::Cloud::Dialogflow.const_get package_name package_module.const_get(:Intents).const_get(:Client).new(&block) end ## # Create a new client object for SessionEntityTypes. # # By default, this returns an instance of # [Google::Cloud::Dialogflow::V2::SessionEntityTypes::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/SessionEntityTypes/Client.html) # for version V2 of the API. # However, you can specify specify a different API version by passing it in the # `version` parameter. If the SessionEntityTypes service is # supported by that API version, and the corresponding gem is available, the # appropriate versioned client will be returned. # # ## About SessionEntityTypes # # Entities are extracted from user input and represent parameters that are # meaningful to your application. For example, a date range, a proper name # such as a geographic location or landmark, and so on. Entities represent # actionable data for your application. # # Session entity types are referred to as **User** entity types and are # entities that are built for an individual user such as # favorites, preferences, playlists, and so on. You can redefine a session # entity type at the session level. # # Session entity methods do not work with Google Assistant integration. # Contact Dialogflow support if you need to use session entities # with Google Assistant integration. # # For more information about entity types, see the # [Dialogflow # documentation](https://cloud.google.com/dialogflow/docs/entities-overview). # # @param version [::String, ::Symbol] The API version to connect to. Optional. # Defaults to `:v2`. # @return [SessionEntityTypes::Client] A client object for the specified version. # def self.session_entity_types version: :v2, &block require "google/cloud/dialogflow/#{version.to_s.downcase}" package_name = Google::Cloud::Dialogflow .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first package_module = Google::Cloud::Dialogflow.const_get package_name package_module.const_get(:SessionEntityTypes).const_get(:Client).new(&block) end ## # Create a new client object for Sessions. # # By default, this returns an instance of # [Google::Cloud::Dialogflow::V2::Sessions::Client](https://googleapis.dev/ruby/google-cloud-dialogflow-v2/latest/Google/Cloud/Dialogflow/V2/Sessions/Client.html) # for version V2 of the API. # However, you can specify specify a different API version by passing it in the # `version` parameter. If the Sessions service is # supported by that API version, and the corresponding gem is available, the # appropriate versioned client will be returned. # # ## About Sessions # # A session represents an interaction with a user. You retrieve user input # and pass it to the DetectIntent (or # StreamingDetectIntent) method to determine # user intent and respond. # # @param version [::String, ::Symbol] The API version to connect to. Optional. # Defaults to `:v2`. # @return [Sessions::Client] A client object for the specified version. # def self.sessions version: :v2, &block require "google/cloud/dialogflow/#{version.to_s.downcase}" package_name = Google::Cloud::Dialogflow .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first package_module = Google::Cloud::Dialogflow.const_get package_name package_module.const_get(:Sessions).const_get(:Client).new(&block) end ## # Configure the google-cloud-dialogflow library. # # The following configuration parameters are supported: # # * `credentials` (*type:* `String, Hash, Google::Auth::Credentials`) - # The path to the keyfile as a String, the contents of the keyfile as a # Hash, or a Google::Auth::Credentials object. # * `lib_name` (*type:* `String`) - # The library name as recorded in instrumentation and logging. # * `lib_version` (*type:* `String`) - # The library version as recorded in instrumentation and logging. # * `interceptors` (*type:* `Array`) - # An array of interceptors that are run before calls are executed. # * `timeout` (*type:* `Integer`) - # Default timeout in milliseconds. # * `metadata` (*type:* `Hash{Symbol=>String}`) - # Additional gRPC headers to be sent with the call. # * `retry_policy` (*type:* `Hash`) - # The retry policy. The value is a hash with the following keys: # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. # * `:retry_codes` (*type:* `Array`) - # The error codes that should trigger a retry. # # @return [::Google::Cloud::Config] The default configuration used by this library # def self.configure yield ::Google::Cloud.configure.dialogflow if block_given? ::Google::Cloud.configure.dialogflow end end end end