Dialogflow V2 API - Class Google::Cloud::Dialogflow::V2::KnowledgeBases::Client (v0.32.2)

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

Client for the KnowledgeBases service.

Service for managing KnowledgeBases.

Inherits

  • Object

Methods

.configure

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

Configure the KnowledgeBases 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 KnowledgeBases clients
::Google::Cloud::Dialogflow::V2::KnowledgeBases::Client.configure do |config|
  config.timeout = 10.0
end

#configure

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

Configure the KnowledgeBases 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

#create_knowledge_base

def create_knowledge_base(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase
def create_knowledge_base(parent: nil, knowledge_base: nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase

Creates a knowledge base.

Overloads
def create_knowledge_base(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase
Pass arguments to create_knowledge_base via a request object, either of type CreateKnowledgeBaseRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::CreateKnowledgeBaseRequest, ::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 create_knowledge_base(parent: nil, knowledge_base: nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase
Pass arguments to create_knowledge_base 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 create a knowledge base for. Format: projects/<Project ID>/locations/<Location ID>.
  • knowledge_base (::Google::Cloud::Dialogflow::V2::KnowledgeBase, ::Hash) — Required. The knowledge base to create.
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::KnowledgeBases::Client.new

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

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

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

#delete_knowledge_base

def delete_knowledge_base(request, options = nil) -> ::Google::Protobuf::Empty
def delete_knowledge_base(name: nil, force: nil) -> ::Google::Protobuf::Empty

Deletes the specified knowledge base.

Overloads
def delete_knowledge_base(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_knowledge_base via a request object, either of type DeleteKnowledgeBaseRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::DeleteKnowledgeBaseRequest, ::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_knowledge_base(name: nil, force: nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_knowledge_base 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
  • name (::String) — Required. The name of the knowledge base to delete. Format: projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base ID>.
  • force (::Boolean) — Optional. Force deletes the knowledge base. When set to true, any documents in the knowledge base are also deleted.
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::KnowledgeBases::Client.new

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

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

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

#get_knowledge_base

def get_knowledge_base(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase
def get_knowledge_base(name: nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase

Retrieves the specified knowledge base.

Overloads
def get_knowledge_base(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase
Pass arguments to get_knowledge_base via a request object, either of type GetKnowledgeBaseRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::GetKnowledgeBaseRequest, ::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_knowledge_base(name: nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase
Pass arguments to get_knowledge_base 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
  • name (::String) — Required. The name of the knowledge base to retrieve. Format projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base 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::KnowledgeBases::Client.new

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

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

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

#initialize

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

Create a new KnowledgeBases client object.

Yields
  • (config) — Configure the KnowledgeBases client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Dialogflow::V2::KnowledgeBases::Client.new

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

#list_knowledge_bases

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

Returns the list of all knowledge bases of the specified agent.

Overloads
def list_knowledge_bases(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::KnowledgeBase>
Pass arguments to list_knowledge_bases via a request object, either of type ListKnowledgeBasesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::ListKnowledgeBasesRequest, ::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 list_knowledge_bases(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::KnowledgeBase>
Pass arguments to list_knowledge_bases 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 of knowledge bases for. Format: projects/<Project ID>/locations/<Location ID>.
  • page_size (::Integer) — The maximum number of items to return in a single page. By default 10 and at most 100.
  • page_token (::String) — The next_page_token value returned from a previous list request.
  • filter (::String) — The filter expression used to filter knowledge bases returned by the list method. The expression has the following syntax:

    The following fields and operators are supported:

    • display_name with has(:) operator
    • language_code with equals(=) operator

    Examples:

    • 'language_code=en-us' matches knowledge bases with en-us language code.
    • 'display_name:articles' matches knowledge bases whose display name contains "articles".
    • 'display_name:"Best Articles"' matches knowledge bases whose display name contains "Best Articles".
    • 'language_code=en-gb AND display_name=articles' matches all knowledge bases whose display name contains "articles" and whose language code is "en-gb".

    Note: An empty filter string (i.e. "") is a no-op and will result in no filtering.

    For more information about filtering, see API Filtering.

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::KnowledgeBases::Client.new

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

# Call the list_knowledge_bases method.
result = client.list_knowledge_bases 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::KnowledgeBase.
  p item
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)

#universe_domain

def universe_domain() -> String

The effective universe domain

Returns
  • (String)

#update_knowledge_base

def update_knowledge_base(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase
def update_knowledge_base(knowledge_base: nil, update_mask: nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase

Updates the specified knowledge base.

Overloads
def update_knowledge_base(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase
Pass arguments to update_knowledge_base via a request object, either of type UpdateKnowledgeBaseRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Dialogflow::V2::UpdateKnowledgeBaseRequest, ::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 update_knowledge_base(knowledge_base: nil, update_mask: nil) -> ::Google::Cloud::Dialogflow::V2::KnowledgeBase
Pass arguments to update_knowledge_base 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::KnowledgeBases::Client.new

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

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

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