Dialogflow V2 API - Class Google::Cloud::Dialogflow::V2::Agents::Client (v1.2.0)

Reference documentation and code samples for the Dialogflow V2 API class Google::Cloud::Dialogflow::V2::Agents::Client.

Client for the Agents service.

Service for managing Agents.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the Agents Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all Agents clients
::Google::Cloud::Dialogflow::V2::Agents::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

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 Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#delete_agent

def delete_agent(request, options = nil) -> ::Google::Protobuf::Empty
def delete_agent(parent: nil) -> ::Google::Protobuf::Empty

Deletes the specified agent.

Overloads
def delete_agent(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_agent via a request object, either of type DeleteAgentRequest or an equivalent Hash.
Parameters
  • 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.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def delete_agent(parent: nil) -> ::Google::Protobuf::Empty
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).
Parameter
  • parent (::String) — Required. The project that the agent to delete is associated with. Format: projects/<Project ID>.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Agents::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::DeleteAgentRequest.new

# Call the delete_agent method.
result = client.delete_agent request

# The returned object is of type Google::Protobuf::Empty.
p result

#export_agent

def export_agent(request, options = nil) -> ::Gapic::Operation
def export_agent(parent: nil, agent_uri: nil) -> ::Gapic::Operation

Exports the specified agent to a ZIP file.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

Overloads
def export_agent(request, options = nil) -> ::Gapic::Operation
Pass arguments to export_agent via a request object, either of type ExportAgentRequest or an equivalent Hash.
Parameters
  • 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.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def export_agent(parent: nil, agent_uri: nil) -> ::Gapic::Operation
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).
Parameters
  • parent (::String) — Required. The project that the agent to export is associated with. Format: projects/<Project ID>.
  • agent_uri (::String) — Required. The Google Cloud Storage 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.

    Dialogflow performs a write operation for the Cloud Storage object on the caller's behalf, so your request authentication must have write permissions for the object. For more information, see Dialogflow access control.

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Agents::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::ExportAgentRequest.new

# Call the export_agent method.
result = client.export_agent request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#get_agent

def get_agent(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Agent
def get_agent(parent: nil) -> ::Google::Cloud::Dialogflow::V2::Agent

Retrieves the specified agent.

Overloads
def get_agent(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Agent
Pass arguments to get_agent via a request object, either of type GetAgentRequest or an equivalent Hash.
Parameters
  • 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.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_agent(parent: nil) -> ::Google::Cloud::Dialogflow::V2::Agent
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).
Parameter
  • parent (::String) — Required. The project that the agent to fetch is associated with. Format: projects/<Project ID>.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Agents::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::GetAgentRequest.new

# Call the get_agent method.
result = client.get_agent request

# The returned object is of type Google::Cloud::Dialogflow::V2::Agent.
p result

#get_validation_result

def get_validation_result(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::ValidationResult
def get_validation_result(parent: nil, language_code: nil) -> ::Google::Cloud::Dialogflow::V2::ValidationResult

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

Overloads
def get_validation_result(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::ValidationResult
Pass arguments to get_validation_result via a request object, either of type GetValidationResultRequest or an equivalent Hash.
Parameters
  • 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.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_validation_result(parent: nil, language_code: nil) -> ::Google::Cloud::Dialogflow::V2::ValidationResult
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).
Parameters
  • parent (::String) — Required. The project that the agent is associated with. Format: projects/<Project ID>.
  • 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 are supported. Note: languages must be enabled in the agent before they can be used.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Agents::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::GetValidationResultRequest.new

# Call the get_validation_result method.
result = client.get_validation_result request

# The returned object is of type Google::Cloud::Dialogflow::V2::ValidationResult.
p result

#import_agent

def import_agent(request, options = nil) -> ::Gapic::Operation
def import_agent(parent: nil, agent_uri: nil, agent_content: nil) -> ::Gapic::Operation

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 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 TrainAgent and wait for the operation it returns in order to train explicitly.

This method is a long-running operation. 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.

Overloads
def import_agent(request, options = nil) -> ::Gapic::Operation
Pass arguments to import_agent via a request object, either of type ImportAgentRequest or an equivalent Hash.
Parameters
  • 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.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def import_agent(parent: nil, agent_uri: nil, agent_content: nil) -> ::Gapic::Operation
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).
Parameters
  • parent (::String) — Required. The project that the agent to import is associated with. Format: projects/<Project ID>.
  • agent_uri (::String) — The URI to a Google Cloud Storage file containing the agent to import. Note: The URI must start with "gs://".

    Dialogflow performs a read operation for the Cloud Storage object on the caller's behalf, so your request authentication must have read permissions for the object. For more information, see Dialogflow access control.

  • agent_content (::String) — Zip compressed raw byte content for agent.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Agents::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::ImportAgentRequest.new

# Call the import_agent method.
result = client.import_agent request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#initialize

def initialize() { |config| ... } -> Client

Create a new Agents client object.

Yields
  • (config) — Configure the Agents client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
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

#location_client

def location_client() -> Google::Cloud::Location::Locations::Client

Get the associated client for mix-in of the Locations.

Returns
  • (Google::Cloud::Location::Locations::Client)

#operations_client

def operations_client() -> ::Google::Cloud::Dialogflow::V2::Agents::Operations

Get the associated client for long-running operations.

#restore_agent

def restore_agent(request, options = nil) -> ::Gapic::Operation
def restore_agent(parent: nil, agent_uri: nil, agent_content: nil) -> ::Gapic::Operation

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 TrainAgent and wait for the operation it returns in order to train explicitly.

This method is a long-running operation. 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.

Overloads
def restore_agent(request, options = nil) -> ::Gapic::Operation
Pass arguments to restore_agent via a request object, either of type RestoreAgentRequest or an equivalent Hash.
Parameters
  • 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.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def restore_agent(parent: nil, agent_uri: nil, agent_content: nil) -> ::Gapic::Operation
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).
Parameters
  • parent (::String) — Required. The project that the agent to restore is associated with. Format: projects/<Project ID>.
  • agent_uri (::String) — The URI to a Google Cloud Storage file containing the agent to restore. Note: The URI must start with "gs://".

    Dialogflow performs a read operation for the Cloud Storage object on the caller's behalf, so your request authentication must have read permissions for the object. For more information, see Dialogflow access control.

  • agent_content (::String) — Zip compressed raw byte content for agent.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Agents::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::RestoreAgentRequest.new

# Call the restore_agent method.
result = client.restore_agent request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#search_agents

def search_agents(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Agent>
def search_agents(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Agent>

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.

Overloads
def search_agents(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Agent>
Pass arguments to search_agents via a request object, either of type SearchAgentsRequest or an equivalent Hash.
Parameters
  • 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.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def search_agents(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Agent>
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).
Parameters
  • parent (::String) — Required. The project to list agents from. Format: projects/<Project ID or '-'>.
  • page_size (::Integer) — Optional. The maximum number of items to return in a single page. By default 100 and at most 1000.
  • page_token (::String) — The next_page_token value returned from a previous list request.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Agents::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::SearchAgentsRequest.new

# Call the search_agents method.
result = client.search_agents request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Dialogflow::V2::Agent.
  p item
end

#set_agent

def set_agent(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Agent
def set_agent(agent: nil, update_mask: nil) -> ::Google::Cloud::Dialogflow::V2::Agent

Creates/updates the specified agent.

Note: You should always train an agent prior to sending it queries. See the training documentation.

Overloads
def set_agent(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Agent
Pass arguments to set_agent via a request object, either of type SetAgentRequest or an equivalent Hash.
Parameters
  • 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.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def set_agent(agent: nil, update_mask: nil) -> ::Google::Cloud::Dialogflow::V2::Agent
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).
Parameters
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Agents::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::SetAgentRequest.new

# Call the set_agent method.
result = client.set_agent request

# The returned object is of type Google::Cloud::Dialogflow::V2::Agent.
p result

#train_agent

def train_agent(request, options = nil) -> ::Gapic::Operation
def train_agent(parent: nil) -> ::Gapic::Operation

Trains the specified agent.

This method is a long-running operation. 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.

Overloads
def train_agent(request, options = nil) -> ::Gapic::Operation
Pass arguments to train_agent via a request object, either of type TrainAgentRequest or an equivalent Hash.
Parameters
  • 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.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def train_agent(parent: nil) -> ::Gapic::Operation
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).
Parameter
  • parent (::String) — Required. The project that the agent to train is associated with. Format: projects/<Project ID>.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/dialogflow/v2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dialogflow::V2::Agents::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dialogflow::V2::TrainAgentRequest.new

# Call the train_agent method.
result = client.train_agent request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#universe_domain

def universe_domain() -> String

The effective universe domain

Returns
  • (String)