class Google::Cloud::Dialogflow::V2::Agents::Client

Client for the Agents service.

Service for managing {::Google::Cloud::Dialogflow::V2::Agent Agents}.

Attributes

agents_stub[R]

@private

operations_client[R]

Get the associated client for long-running operations.

@return [::Google::Cloud::Dialogflow::V2::Agents::Operations]

Public Class Methods

configure() { |configure| ... } click to toggle source

Configure the Agents Client class.

See {::Google::Cloud::Dialogflow::V2::Agents::Client::Configuration} for a description of the configuration fields.

@example

# Modify the configuration for all Agents clients
::Google::Cloud::Dialogflow::V2::Agents::Client.configure do |config|
  config.timeout = 10.0
end

@yield [config] Configure the Client client. @yieldparam config [Client::Configuration]

@return [Client::Configuration]

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 56
def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Dialogflow", "V2"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.timeout = 60.0
    default_config.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end
new() { |config| ... } click to toggle source

Create a new Agents client object.

@example

# Create a client using the default configuration
client = ::Google::Cloud::Dialogflow::V2::Agents::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Dialogflow::V2::Agents::Client.new do |config|
  config.timeout = 10.0
end

@yield [config] Configure the Agents client. @yieldparam config [Client::Configuration]

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 114
def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/cloud/dialogflow/v2/agent_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
                           !@config.endpoint.split(".").first.include?("-")
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @operations_client = Operations.new do |config|
    config.credentials = credentials
    config.endpoint = @config.endpoint
  end

  @agents_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::Dialogflow::V2::Agents::Stub,
    credentials:  credentials,
    endpoint:     @config.endpoint,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors
  )
end

Public Instance Methods

configure() { |config| ... } click to toggle source

Configure the Agents Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on {Client.configure}.

See {::Google::Cloud::Dialogflow::V2::Agents::Client::Configuration} for a description of the configuration fields.

@yield [config] Configure the Client client. @yieldparam config [Client::Configuration]

@return [Client::Configuration]

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 93
def configure
  yield @config if block_given?
  @config
end
delete_agent(request, options = nil) { |response, operation| ... } click to toggle source

Deletes the specified agent.

@overload delete_agent(request, options = nil)

Pass arguments to `delete_agent` via a request object, either of type
{::Google::Cloud::Dialogflow::V2::DeleteAgentRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dialogflow::V2::DeleteAgentRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload delete_agent(parent: nil)

Pass arguments to `delete_agent` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project that the agent to delete is associated with.
  Format: `projects/<Project ID>`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Protobuf::Empty]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 337
def delete_agent request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::DeleteAgentRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.delete_agent.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_agent.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.delete_agent.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @agents_stub.call_rpc :delete_agent, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
export_agent(request, options = nil) { |response, operation| ... } click to toggle source

Exports the specified agent to a ZIP file.

This method is a [long-running operation](cloud.google.com/dialogflow/es/docs/how/long-running-operations). The returned `Operation` type has the following method-specific fields:

@overload export_agent(request, options = nil)

Pass arguments to `export_agent` via a request object, either of type
{::Google::Cloud::Dialogflow::V2::ExportAgentRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dialogflow::V2::ExportAgentRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload export_agent(parent: nil, agent_uri: nil)

Pass arguments to `export_agent` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project that the agent to export is associated with.
  Format: `projects/<Project ID>`.
@param agent_uri [::String]
  Required. The [Google Cloud Storage](https://cloud.google.com/storage/docs/)
  URI to export the agent to.
  The format of this URI must be `gs://<bucket-name>/<object-name>`.
  If left unspecified, the serialized agent is returned inline.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 583
def export_agent request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::ExportAgentRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.export_agent.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.export_agent.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.export_agent.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @agents_stub.call_rpc :export_agent, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
get_agent(request, options = nil) { |response, operation| ... } click to toggle source

Retrieves the specified agent.

@overload get_agent(request, options = nil)

Pass arguments to `get_agent` via a request object, either of type
{::Google::Cloud::Dialogflow::V2::GetAgentRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dialogflow::V2::GetAgentRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload get_agent(parent: nil)

Pass arguments to `get_agent` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project that the agent to fetch is associated with.
  Format: `projects/<Project ID>`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Dialogflow::V2::Agent] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Dialogflow::V2::Agent]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 194
def get_agent request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::GetAgentRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.get_agent.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_agent.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.get_agent.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @agents_stub.call_rpc :get_agent, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
get_validation_result(request, options = nil) { |response, operation| ... } click to toggle source

Gets agent validation result. Agent validation is performed during training time and is updated automatically when training is completed.

@overload get_validation_result(request, options = nil)

Pass arguments to `get_validation_result` via a request object, either of type
{::Google::Cloud::Dialogflow::V2::GetValidationResultRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dialogflow::V2::GetValidationResultRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload get_validation_result(parent: nil, language_code: nil)

Pass arguments to `get_validation_result` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project that the agent is associated with.
  Format: `projects/<Project ID>`.
@param language_code [::String]
  Optional. The language for which you want a validation result. If not
  specified, the agent's default language is used. [Many
  languages](https://cloud.google.com/dialogflow/docs/reference/language)
  are supported. Note: languages must be enabled in the agent before they can
  be used.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Dialogflow::V2::ValidationResult] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Dialogflow::V2::ValidationResult]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 857
def get_validation_result request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::GetValidationResultRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.get_validation_result.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_validation_result.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.get_validation_result.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @agents_stub.call_rpc :get_validation_result, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
import_agent(request, options = nil) { |response, operation| ... } click to toggle source

Imports the specified agent from a ZIP file.

Uploads new intents and entity types without deleting the existing ones. Intents and entity types with the same name are replaced with the new versions from {::Google::Cloud::Dialogflow::V2::ImportAgentRequest ImportAgentRequest}. After the import, the imported draft agent will be trained automatically (unless disabled in agent settings). However, once the import is done, training may not be completed yet. Please call {::Google::Cloud::Dialogflow::V2::Agents::Client#train_agent TrainAgent} and wait for the operation it returns in order to train explicitly.

This method is a [long-running operation](cloud.google.com/dialogflow/es/docs/how/long-running-operations). The returned `Operation` type has the following method-specific fields:

The operation only tracks when importing is complete, not when it is done training.

Note: You should always train an agent prior to sending it queries. See the [training documentation](cloud.google.com/dialogflow/es/docs/training).

@overload import_agent(request, options = nil)

Pass arguments to `import_agent` via a request object, either of type
{::Google::Cloud::Dialogflow::V2::ImportAgentRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dialogflow::V2::ImportAgentRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload import_agent(parent: nil, agent_uri: nil, agent_content: nil)

Pass arguments to `import_agent` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project that the agent to import is associated with.
  Format: `projects/<Project ID>`.
@param agent_uri [::String]
  The URI to a Google Cloud Storage file containing the agent to import.
  Note: The URI must start with "gs://".
@param agent_content [::String]
  Zip compressed raw byte content for agent.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 682
def import_agent request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::ImportAgentRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.import_agent.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.import_agent.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.import_agent.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @agents_stub.call_rpc :import_agent, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
restore_agent(request, options = nil) { |response, operation| ... } click to toggle source

Restores the specified agent from a ZIP file.

Replaces the current agent version with a new one. All the intents and entity types in the older version are deleted. After the restore, the restored draft agent will be trained automatically (unless disabled in agent settings). However, once the restore is done, training may not be completed yet. Please call {::Google::Cloud::Dialogflow::V2::Agents::Client#train_agent TrainAgent} and wait for the operation it returns in order to train explicitly.

This method is a [long-running operation](cloud.google.com/dialogflow/es/docs/how/long-running-operations). The returned `Operation` type has the following method-specific fields:

The operation only tracks when restoring is complete, not when it is done training.

Note: You should always train an agent prior to sending it queries. See the [training documentation](cloud.google.com/dialogflow/es/docs/training).

@overload restore_agent(request, options = nil)

Pass arguments to `restore_agent` via a request object, either of type
{::Google::Cloud::Dialogflow::V2::RestoreAgentRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dialogflow::V2::RestoreAgentRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload restore_agent(parent: nil, agent_uri: nil, agent_content: nil)

Pass arguments to `restore_agent` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project that the agent to restore is associated with.
  Format: `projects/<Project ID>`.
@param agent_uri [::String]
  The URI to a Google Cloud Storage file containing the agent to restore.
  Note: The URI must start with "gs://".
@param agent_content [::String]
  Zip compressed raw byte content for agent.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 780
def restore_agent request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::RestoreAgentRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.restore_agent.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.restore_agent.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.restore_agent.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @agents_stub.call_rpc :restore_agent, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
search_agents(request, options = nil) { |response, operation| ... } click to toggle source

Returns the list of agents.

Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id “-”. Refer to [List Sub-Collections](cloud.google.com/apis/design/design_patterns#list_sub-collections).

@overload search_agents(request, options = nil)

Pass arguments to `search_agents` via a request object, either of type
{::Google::Cloud::Dialogflow::V2::SearchAgentsRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dialogflow::V2::SearchAgentsRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload search_agents(parent: nil, page_size: nil, page_token: nil)

Pass arguments to `search_agents` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project to list agents from.
  Format: `projects/<Project ID or '-'>`.
@param page_size [::Integer]
  Optional. The maximum number of items to return in a single page. By
  default 100 and at most 1000.
@param page_token [::String]
  The next_page_token value returned from a previous list request.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Agent>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Agent>]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 417
def search_agents request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::SearchAgentsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.search_agents.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.search_agents.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.search_agents.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @agents_stub.call_rpc :search_agents, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @agents_stub, :search_agents, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
set_agent(request, options = nil) { |response, operation| ... } click to toggle source

Creates/updates the specified agent.

Note: You should always train an agent prior to sending it queries. See the [training documentation](cloud.google.com/dialogflow/es/docs/training).

@overload set_agent(request, options = nil)

Pass arguments to `set_agent` via a request object, either of type
{::Google::Cloud::Dialogflow::V2::SetAgentRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dialogflow::V2::SetAgentRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload set_agent(agent: nil, update_mask: nil)

Pass arguments to `set_agent` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param agent [::Google::Cloud::Dialogflow::V2::Agent, ::Hash]
  Required. The agent to update.
@param update_mask [::Google::Protobuf::FieldMask, ::Hash]
  Optional. The mask to control which fields get updated.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Dialogflow::V2::Agent] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::Dialogflow::V2::Agent]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 268
def set_agent request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::SetAgentRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.set_agent.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "agent.parent" => request.agent.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.set_agent.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.set_agent.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @agents_stub.call_rpc :set_agent, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
train_agent(request, options = nil) { |response, operation| ... } click to toggle source

Trains the specified agent.

This method is a [long-running operation](cloud.google.com/dialogflow/es/docs/how/long-running-operations). The returned `Operation` type has the following method-specific fields:

Note: You should always train an agent prior to sending it queries. See the [training documentation](cloud.google.com/dialogflow/es/docs/training).

@overload train_agent(request, options = nil)

Pass arguments to `train_agent` via a request object, either of type
{::Google::Cloud::Dialogflow::V2::TrainAgentRequest} or an equivalent Hash.

@param request [::Google::Cloud::Dialogflow::V2::TrainAgentRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload train_agent(parent: nil)

Pass arguments to `train_agent` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param parent [::String]
  Required. The project that the agent to train is associated with.
  Format: `projects/<Project ID>`.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/dialogflow/v2/agents/client.rb, line 500
def train_agent request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::TrainAgentRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.train_agent.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.train_agent.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.train_agent.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @agents_stub.call_rpc :train_agent, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end