Reference documentation and code samples for the Dialogflow V2 API class Google::Cloud::Dialogflow::V2::Documents::Client.
Client for the Documents service.
Service for managing knowledge Documents.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the Documents Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all Documents clients ::Google::Cloud::Dialogflow::V2::Documents::Client.configure do |config| config.timeout = 10.0 end
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the Documents 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.
- (config) — Configure the Client client.
- config (Client::Configuration)
#create_document
def create_document(request, options = nil) -> ::Gapic::Operation
def create_document(parent: nil, document: nil) -> ::Gapic::Operation
Creates a new document.
This method is a long-running
operation.
The returned Operation
type has the following method-specific fields:
metadata
: KnowledgeOperationMetadataresponse
: Document
def create_document(request, options = nil) -> ::Gapic::Operation
create_document
via a request object, either of type
CreateDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::Dialogflow::V2::CreateDocumentRequest, ::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_document(parent: nil, document: nil) -> ::Gapic::Operation
create_document
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).
-
parent (::String) — Required. The knowledge base to create a document for.
Format:
projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base ID>
. - document (::Google::Cloud::Dialogflow::V2::Document, ::Hash) — Required. The document to create.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/dialogflow/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Dialogflow::V2::Documents::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Dialogflow::V2::CreateDocumentRequest.new # Call the create_document method. result = client.create_document 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
#delete_document
def delete_document(request, options = nil) -> ::Gapic::Operation
def delete_document(name: nil) -> ::Gapic::Operation
Deletes the specified document.
This method is a long-running
operation.
The returned Operation
type has the following method-specific fields:
metadata
: KnowledgeOperationMetadataresponse
: An Empty message
def delete_document(request, options = nil) -> ::Gapic::Operation
delete_document
via a request object, either of type
Google::Cloud::Dialogflow::V2::DeleteDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::Dialogflow::V2::DeleteDocumentRequest, ::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_document(name: nil) -> ::Gapic::Operation
delete_document
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).
-
name (::String) — Required. The name of the document to delete.
Format:
projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>
.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/dialogflow/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Dialogflow::V2::Documents::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Dialogflow::V2::DeleteDocumentRequest.new # Call the delete_document method. result = client.delete_document 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
#export_document
def export_document(request, options = nil) -> ::Gapic::Operation
def export_document(name: nil, gcs_destination: nil, export_full_content: nil, smart_messaging_partial_update: nil) -> ::Gapic::Operation
Exports a smart messaging candidate document into the specified destination.
This method is a long-running
operation.
The returned Operation
type has the following method-specific fields:
metadata
: KnowledgeOperationMetadataresponse
: Document
def export_document(request, options = nil) -> ::Gapic::Operation
export_document
via a request object, either of type
ExportDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::Dialogflow::V2::ExportDocumentRequest, ::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_document(name: nil, gcs_destination: nil, export_full_content: nil, smart_messaging_partial_update: nil) -> ::Gapic::Operation
export_document
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).
-
name (::String) — Required. The name of the document to export.
Format:
projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>
. - gcs_destination (::Google::Cloud::Dialogflow::V2::GcsDestination, ::Hash) — Cloud Storage file path to export the document.
- export_full_content (::Boolean) — When enabled, export the full content of the document including empirical probability.
- smart_messaging_partial_update (::Boolean) — When enabled, export the smart messaging allowlist document for partial update.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/dialogflow/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Dialogflow::V2::Documents::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Dialogflow::V2::ExportDocumentRequest.new # Call the export_document method. result = client.export_document 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_document
def get_document(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Document
def get_document(name: nil) -> ::Google::Cloud::Dialogflow::V2::Document
Retrieves the specified document.
def get_document(request, options = nil) -> ::Google::Cloud::Dialogflow::V2::Document
get_document
via a request object, either of type
GetDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::Dialogflow::V2::GetDocumentRequest, ::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_document(name: nil) -> ::Google::Cloud::Dialogflow::V2::Document
get_document
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).
-
name (::String) — Required. The name of the document to retrieve.
Format
projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>
.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Dialogflow::V2::Document)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/dialogflow/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Dialogflow::V2::Documents::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Dialogflow::V2::GetDocumentRequest.new # Call the get_document method. result = client.get_document request # The returned object is of type Google::Cloud::Dialogflow::V2::Document. p result
#import_documents
def import_documents(request, options = nil) -> ::Gapic::Operation
def import_documents(parent: nil, gcs_source: nil, document_template: nil, import_gcs_custom_metadata: nil) -> ::Gapic::Operation
Creates documents by importing data from external sources. Dialogflow supports up to 350 documents in each request. If you try to import more, Dialogflow will return an error.
This method is a long-running
operation.
The returned Operation
type has the following method-specific fields:
metadata
: KnowledgeOperationMetadataresponse
: ImportDocumentsResponse
def import_documents(request, options = nil) -> ::Gapic::Operation
import_documents
via a request object, either of type
ImportDocumentsRequest or an equivalent Hash.
- request (::Google::Cloud::Dialogflow::V2::ImportDocumentsRequest, ::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_documents(parent: nil, gcs_source: nil, document_template: nil, import_gcs_custom_metadata: nil) -> ::Gapic::Operation
import_documents
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).
-
parent (::String) — Required. The knowledge base to import documents into.
Format:
projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base ID>
. -
gcs_source (::Google::Cloud::Dialogflow::V2::GcsSources, ::Hash) — Optional. The Google Cloud Storage location for the documents.
The path can include a wildcard.
These URIs may have the forms
gs://<bucket-name>/<object-name>
.gs://<bucket-name>/<object-path>/*.<extension>
. - document_template (::Google::Cloud::Dialogflow::V2::ImportDocumentTemplate, ::Hash) — Required. Document template used for importing all the documents.
- import_gcs_custom_metadata (::Boolean) — Whether to import custom metadata from Google Cloud Storage. Only valid when the document source is Google Cloud Storage URI.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/dialogflow/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Dialogflow::V2::Documents::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Dialogflow::V2::ImportDocumentsRequest.new # Call the import_documents method. result = client.import_documents 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 Documents client object.
- (config) — Configure the Documents client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::Dialogflow::V2::Documents::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Dialogflow::V2::Documents::Client.new do |config| config.timeout = 10.0 end
#list_documents
def list_documents(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Document>
def list_documents(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Document>
Returns the list of all documents of the knowledge base.
def list_documents(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Document>
list_documents
via a request object, either of type
ListDocumentsRequest or an equivalent Hash.
- request (::Google::Cloud::Dialogflow::V2::ListDocumentsRequest, ::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_documents(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Document>
list_documents
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).
-
parent (::String) — Required. The knowledge base to list all documents for.
Format:
projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base 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 documents returned by the list method.
The expression has the following syntax:
The following fields and operators are supported:
- knowledge_types with has(:) operator
- display_name with has(:) operator
- state with equals(=) operator
Examples:
- "knowledge_types:FAQ" matches documents with FAQ knowledge type.
- "display_name:customer" matches documents whose display name contains "customer".
- "state=ACTIVE" matches documents with ACTIVE state.
- "knowledge_types:FAQ AND state=ACTIVE" matches all active FAQ documents.
For more information about filtering, see API Filtering.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Document>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Document>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/dialogflow/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Dialogflow::V2::Documents::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Dialogflow::V2::ListDocumentsRequest.new # Call the list_documents method. result = client.list_documents 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::Document. p item end
#location_client
def location_client() -> Google::Cloud::Location::Locations::Client
Get the associated client for mix-in of the Locations.
- (Google::Cloud::Location::Locations::Client)
#logger
def logger() -> Logger
The logger used for request/response debug logging.
- (Logger)
#operations_client
def operations_client() -> ::Google::Cloud::Dialogflow::V2::Documents::Operations
Get the associated client for long-running operations.
#reload_document
def reload_document(request, options = nil) -> ::Gapic::Operation
def reload_document(name: nil, content_uri: nil, import_gcs_custom_metadata: nil, smart_messaging_partial_update: nil) -> ::Gapic::Operation
Reloads the specified document from its specified source, content_uri or content. The previously loaded content of the document will be deleted. Note: Even when the content of the document has not changed, there still may be side effects because of internal implementation changes.
This method is a long-running
operation.
The returned Operation
type has the following method-specific fields:
metadata
: KnowledgeOperationMetadataresponse
: Document
Note: The projects.agent.knowledgeBases.documents
resource is deprecated;
only use projects.knowledgeBases.documents
.
def reload_document(request, options = nil) -> ::Gapic::Operation
reload_document
via a request object, either of type
ReloadDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::Dialogflow::V2::ReloadDocumentRequest, ::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 reload_document(name: nil, content_uri: nil, import_gcs_custom_metadata: nil, smart_messaging_partial_update: nil) -> ::Gapic::Operation
reload_document
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).
-
name (::String) — Required. The name of the document to reload.
Format:
projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>
-
content_uri (::String) — Optional. The path of gcs source file for reloading document content. For
now, only gcs uri is supported.
For documents stored in Google Cloud Storage, these URIs must have the form
gs://<bucket-name>/<object-name>
. - import_gcs_custom_metadata (::Boolean) — Optional. Whether to import custom metadata from Google Cloud Storage. Only valid when the document source is Google Cloud Storage URI.
- smart_messaging_partial_update (::Boolean) — Optional. When enabled, the reload request is to apply partial update to the smart messaging allowlist.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/dialogflow/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Dialogflow::V2::Documents::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Dialogflow::V2::ReloadDocumentRequest.new # Call the reload_document method. result = client.reload_document 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
- (String)
#update_document
def update_document(request, options = nil) -> ::Gapic::Operation
def update_document(document: nil, update_mask: nil) -> ::Gapic::Operation
Updates the specified document.
This method is a long-running
operation.
The returned Operation
type has the following method-specific fields:
metadata
: KnowledgeOperationMetadataresponse
: Document
def update_document(request, options = nil) -> ::Gapic::Operation
update_document
via a request object, either of type
UpdateDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::Dialogflow::V2::UpdateDocumentRequest, ::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_document(document: nil, update_mask: nil) -> ::Gapic::Operation
update_document
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).
- document (::Google::Cloud::Dialogflow::V2::Document, ::Hash) — Required. The document to update.
-
update_mask (::Google::Protobuf::FieldMask, ::Hash) — Optional. Not specified means
update all
. Currently, onlydisplay_name
can be updated, an InvalidArgument will be returned for attempting to update other fields.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/dialogflow/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Dialogflow::V2::Documents::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Dialogflow::V2::UpdateDocumentRequest.new # Call the update_document method. result = client.update_document 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