lib/google/cloud/dialogflow/v2/intents_client.rb in google-cloud-dialogflow-0.2.3 vs lib/google/cloud/dialogflow/v2/intents_client.rb in google-cloud-dialogflow-0.3.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright 2018 Google LLC +# Copyright 2019 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 # @@ -46,11 +46,11 @@ # 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 + # 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 @@ -62,11 +62,12 @@ # # * **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://dialogflow.com/docs/intents). + # [Dialogflow + # documentation](https://cloud.google.com/dialogflow-enterprise/docs/intents-overview). # # @!attribute [r] intents_stub # @return [Google::Cloud::Dialogflow::V2::Intents::Stub] class IntentsClient # @private @@ -93,43 +94,46 @@ private_constant :PAGE_DESCRIPTORS # The scopes needed to make gRPC calls to all of the methods defined in # this service. ALL_SCOPES = [ - "https://www.googleapis.com/auth/cloud-platform" + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow" ].freeze # @private class OperationsClient < Google::Longrunning::OperationsClient self::SERVICE_ADDRESS = IntentsClient::SERVICE_ADDRESS self::GRPC_INTERCEPTORS = IntentsClient::GRPC_INTERCEPTORS end - PROJECT_AGENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new( - "projects/{project}/agent" + AGENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new( + "projects/{project}/agents/{agent}" ) - private_constant :PROJECT_AGENT_PATH_TEMPLATE + private_constant :AGENT_PATH_TEMPLATE INTENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/agent/intents/{intent}" ) private_constant :INTENT_PATH_TEMPLATE - AGENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new( - "projects/{project}/agents/{agent}" + PROJECT_AGENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new( + "projects/{project}/agent" ) - private_constant :AGENT_PATH_TEMPLATE + private_constant :PROJECT_AGENT_PATH_TEMPLATE - # Returns a fully-qualified project_agent resource name string. + # Returns a fully-qualified agent resource name string. # @param project [String] + # @param agent [String] # @return [String] - def self.project_agent_path project - PROJECT_AGENT_PATH_TEMPLATE.render( - :"project" => project + def self.agent_path project, agent + AGENT_PATH_TEMPLATE.render( + :"project" => project, + :"agent" => agent ) end # Returns a fully-qualified intent resource name string. # @param project [String] @@ -140,18 +144,16 @@ :"project" => project, :"intent" => intent ) end - # Returns a fully-qualified agent resource name string. + # Returns a fully-qualified project_agent resource name string. # @param project [String] - # @param agent [String] # @return [String] - def self.agent_path project, agent - AGENT_PATH_TEMPLATE.render( - :"project" => project, - :"agent" => agent + def self.project_agent_path project + PROJECT_AGENT_PATH_TEMPLATE.render( + :"project" => project ) end # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc] # Provides the means for authenticating requests made by the client. This parameter can @@ -266,41 +268,62 @@ ) @list_intents = Google::Gax.create_api_call( @intents_stub.method(:list_intents), defaults["list_intents"], - exception_transformer: exception_transformer + exception_transformer: exception_transformer, + params_extractor: proc do |request| + {'parent' => request.parent} + end ) @get_intent = Google::Gax.create_api_call( @intents_stub.method(:get_intent), defaults["get_intent"], - exception_transformer: exception_transformer + exception_transformer: exception_transformer, + params_extractor: proc do |request| + {'name' => request.name} + end ) @create_intent = Google::Gax.create_api_call( @intents_stub.method(:create_intent), defaults["create_intent"], - exception_transformer: exception_transformer + exception_transformer: exception_transformer, + params_extractor: proc do |request| + {'parent' => request.parent} + end ) @update_intent = Google::Gax.create_api_call( @intents_stub.method(:update_intent), defaults["update_intent"], - exception_transformer: exception_transformer + exception_transformer: exception_transformer, + params_extractor: proc do |request| + {'intent.name' => request.intent.name} + end ) @delete_intent = Google::Gax.create_api_call( @intents_stub.method(:delete_intent), defaults["delete_intent"], - exception_transformer: exception_transformer + exception_transformer: exception_transformer, + params_extractor: proc do |request| + {'name' => request.name} + end ) @batch_update_intents = Google::Gax.create_api_call( @intents_stub.method(:batch_update_intents), defaults["batch_update_intents"], - exception_transformer: exception_transformer + exception_transformer: exception_transformer, + params_extractor: proc do |request| + {'parent' => request.parent} + end ) @batch_delete_intents = Google::Gax.create_api_call( @intents_stub.method(:batch_delete_intents), defaults["batch_delete_intents"], - exception_transformer: exception_transformer + exception_transformer: exception_transformer, + params_extractor: proc do |request| + {'parent' => request.parent} + end ) end # Service calls @@ -310,13 +333,14 @@ # Required. The agent to list all intents from. # Format: `projects/<Project ID>/agent`. # @param language_code [String] # Optional. The language to list training phrases, parameters and rich # messages for. If not specified, the agent's default language is used. - # [More than a dozen - # languages](https://dialogflow.com/docs/reference/language) are supported. - # Note: languages must be enabled in the agent before they can be used. + # [Many + # languages](https://cloud.google.com/dialogflow-enterprise/docs/reference/language) + # are supported. Note: languages must be enabled in the agent before they can + # be used. # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView] # Optional. The resource view to apply to the returned intent. # @param page_size [Integer] # The maximum number of resources contained in the underlying API # response. If page streaming is performed per-resource, this @@ -377,13 +401,14 @@ # Required. The name of the intent. # Format: `projects/<Project ID>/agent/intents/<Intent ID>`. # @param language_code [String] # Optional. The language to retrieve training phrases, parameters and rich # messages for. If not specified, the agent's default language is used. - # [More than a dozen - # languages](https://dialogflow.com/docs/reference/language) are supported. - # Note: languages must be enabled in the agent, before they can be used. + # [Many + # languages](https://cloud.google.com/dialogflow-enterprise/docs/reference/language) + # are supported. Note: languages must be enabled in the agent before they can + # be used. # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView] # Optional. The resource view to apply to the returned intent. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. @@ -424,13 +449,14 @@ # A hash of the same form as `Google::Cloud::Dialogflow::V2::Intent` # can also be provided. # @param language_code [String] # Optional. The language of training phrases, parameters and rich messages # defined in `intent`. If not specified, the agent's default language is - # used. [More than a dozen - # languages](https://dialogflow.com/docs/reference/language) are supported. - # Note: languages must be enabled in the agent, before they can be used. + # used. [Many + # languages](https://cloud.google.com/dialogflow-enterprise/docs/reference/language) + # are supported. Note: languages must be enabled in the agent before they can + # be used. # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView] # Optional. The resource view to apply to the returned intent. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. @@ -468,19 +494,19 @@ # Updates the specified intent. # # @param intent [Google::Cloud::Dialogflow::V2::Intent | Hash] # Required. The intent to update. - # Format: `projects/<Project ID>/agent/intents/<Intent ID>`. # A hash of the same form as `Google::Cloud::Dialogflow::V2::Intent` # can also be provided. # @param language_code [String] # Optional. The language of training phrases, parameters and rich messages # defined in `intent`. If not specified, the agent's default language is - # used. [More than a dozen - # languages](https://dialogflow.com/docs/reference/language) are supported. - # Note: languages must be enabled in the agent, before they can be used. + # used. [Many + # languages](https://cloud.google.com/dialogflow-enterprise/docs/reference/language) + # are supported. Note: languages must be enabled in the agent before they can + # be used. # @param update_mask [Google::Protobuf::FieldMask | Hash] # Optional. The mask to control which fields get updated. # A hash of the same form as `Google::Protobuf::FieldMask` # can also be provided. # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView] @@ -520,14 +546,15 @@ }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::UpdateIntentRequest) @update_intent.call(req, options, &block) end - # Deletes the specified intent. + # Deletes the specified intent and its direct or indirect followup intents. # # @param name [String] - # Required. The name of the intent to delete. + # Required. The name of the intent to delete. If this intent has direct or + # indirect followup intents, we also delete them. # Format: `projects/<Project ID>/agent/intents/<Intent ID>`. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation @@ -561,12 +588,13 @@ # Required. The name of the agent to update or create intents in. # Format: `projects/<Project ID>/agent`. # @param language_code [String] # Optional. The language of training phrases, parameters and rich messages # defined in `intents`. If not specified, the agent's default language is - # used. [More than a dozen - # languages](https://dialogflow.com/docs/reference/language) are supported. - # Note: languages must be enabled in the agent, before they can be used. + # used. [Many + # languages](https://cloud.google.com/dialogflow-enterprise/docs/reference/language) + # are supported. Note: languages must be enabled in the agent before they can + # be used. # @param intent_batch_uri [String] # The URI to a Google Cloud Storage file containing intents to update or # create. The file format can either be a serialized proto (of IntentBatch # type) or JSON object. Note: The URI must start with "gs://". # @param intent_batch_inline [Google::Cloud::Dialogflow::V2::IntentBatch | Hash]