Reference documentation and code samples for the Discovery Engine V1 API class Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.
Client for the DocumentService service.
Service for ingesting Document information of the customer's website.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the DocumentService Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all DocumentService clients ::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.configure do |config| config.timeout = 10.0 end
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the DocumentService 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) -> ::Google::Cloud::DiscoveryEngine::V1::Document
def create_document(parent: nil, document: nil, document_id: nil) -> ::Google::Cloud::DiscoveryEngine::V1::Document
Creates a Document.
def create_document(request, options = nil) -> ::Google::Cloud::DiscoveryEngine::V1::Document
create_document
via a request object, either of type
CreateDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::DiscoveryEngine::V1::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, document_id: nil) -> ::Google::Cloud::DiscoveryEngine::V1::Document
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 parent resource name, such as
projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}
. - document (::Google::Cloud::DiscoveryEngine::V1::Document, ::Hash) — Required. The Document to create.
-
document_id (::String) — Required. The ID to use for the
Document, which will become the
final component of the
Document.name.
If the caller does not have permission to create the Document, regardless of whether or not it exists, a
PERMISSION_DENIED
error is returned.This field must be unique among all Documents with the same parent. Otherwise, an
ALREADY_EXISTS
error is returned.This field must conform to RFC-1034 standard with a length limit of 63 characters. Otherwise, an
INVALID_ARGUMENT
error is returned.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::DiscoveryEngine::V1::Document)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/discovery_engine/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DiscoveryEngine::V1::CreateDocumentRequest.new # Call the create_document method. result = client.create_document request # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Document. p result
#delete_document
def delete_document(request, options = nil) -> ::Google::Protobuf::Empty
def delete_document(name: nil) -> ::Google::Protobuf::Empty
Deletes a Document.
def delete_document(request, options = nil) -> ::Google::Protobuf::Empty
delete_document
via a request object, either of type
Google::Cloud::DiscoveryEngine::V1::DeleteDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::DiscoveryEngine::V1::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) -> ::Google::Protobuf::Empty
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. Full resource name of
Document, such as
projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}
.If the caller does not have permission to delete the Document, regardless of whether or not it exists, a
PERMISSION_DENIED
error is returned.If the Document to delete does not exist, a
NOT_FOUND
error is returned.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Protobuf::Empty)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/discovery_engine/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DiscoveryEngine::V1::DeleteDocumentRequest.new # Call the delete_document method. result = client.delete_document request # The returned object is of type Google::Protobuf::Empty. p result
#get_document
def get_document(request, options = nil) -> ::Google::Cloud::DiscoveryEngine::V1::Document
def get_document(name: nil) -> ::Google::Cloud::DiscoveryEngine::V1::Document
Gets a Document.
def get_document(request, options = nil) -> ::Google::Cloud::DiscoveryEngine::V1::Document
get_document
via a request object, either of type
GetDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::DiscoveryEngine::V1::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::DiscoveryEngine::V1::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. Full resource name of
Document, such as
projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}
.If the caller does not have permission to access the Document, regardless of whether or not it exists, a
PERMISSION_DENIED
error is returned.If the requested Document does not exist, a
NOT_FOUND
error is returned.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::DiscoveryEngine::V1::Document)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/discovery_engine/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DiscoveryEngine::V1::GetDocumentRequest.new # Call the get_document method. result = client.get_document request # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Document. p result
#import_documents
def import_documents(request, options = nil) -> ::Gapic::Operation
def import_documents(inline_source: nil, gcs_source: nil, bigquery_source: nil, parent: nil, error_config: nil, reconciliation_mode: nil, auto_generate_ids: nil, id_field: nil) -> ::Gapic::Operation
Bulk import of multiple Documents. Request processing may be synchronous. Non-existing items will be created.
Note: It is possible for a subset of the {::Google::Cloud::DiscoveryEngine::V1::Document Document}s to be successfully updated.
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::DiscoveryEngine::V1::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(inline_source: nil, gcs_source: nil, bigquery_source: nil, parent: nil, error_config: nil, reconciliation_mode: nil, auto_generate_ids: nil, id_field: 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).
- inline_source (::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest::InlineSource, ::Hash) — The Inline source for the input content for documents.
- gcs_source (::Google::Cloud::DiscoveryEngine::V1::GcsSource, ::Hash) — Cloud Storage location for the input content.
- bigquery_source (::Google::Cloud::DiscoveryEngine::V1::BigQuerySource, ::Hash) — BigQuery input source.
-
parent (::String) — Required. The parent branch resource name, such as
projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}
. Requires create/update permission. - error_config (::Google::Cloud::DiscoveryEngine::V1::ImportErrorConfig, ::Hash) — The desired location of errors incurred during the Import.
- reconciliation_mode (::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest::ReconciliationMode) — The mode of reconciliation between existing documents and the documents to be imported. Defaults to ReconciliationMode.INCREMENTAL.
-
auto_generate_ids (::Boolean) — Whether to automatically generate IDs for the documents if absent.
If set to
true
, Document.ids are automatically generated based on the hash of the payload, where IDs may not be consistent during multiple imports. In which case ReconciliationMode.FULL is highly recommended to avoid duplicate contents. If unset or set tofalse
, Document.ids have to be specified using id_field, otherwises, documents without IDs will fail to be imported.Only set this field when using GcsSource or BigQuerySource, and when GcsSource.data_schema or BigQuerySource.data_schema is
custom
. Otherwise, an INVALID_ARGUMENT error is thrown. -
id_field (::String) — The field in the Cloud Storage and BigQuery sources that indicates the
unique IDs of the documents.
For GcsSource it is the key of the JSON field. For instance,
my_id
for JSON{"my_id": "some_uuid"}
. For BigQuerySource it is the column name of the BigQuery table where the unique ids are stored.The values of the JSON field or the BigQuery column will be used as the Document.ids. The JSON field or the BigQuery column must be of string type, and the values must be set as valid strings conform to RFC-1034 with 1-63 characters. Otherwise, documents without valid IDs will fail to be imported.
Only set this field when using GcsSource or BigQuerySource, and when GcsSource.data_schema or BigQuerySource.data_schema is
custom
. And only set this field when auto_generate_ids is unset or set asfalse
. Otherwise, an INVALID_ARGUMENT error is thrown.If it is unset, a default value
_id
is used when importing from the allowed data sources.
- (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/discovery_engine/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DiscoveryEngine::V1::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 DocumentService client object.
- (config) — Configure the DocumentService client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new # Create a client using a custom configuration client = ::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new do |config| config.timeout = 10.0 end
#list_documents
def list_documents(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document>
def list_documents(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document>
Gets a list of {::Google::Cloud::DiscoveryEngine::V1::Document Document}s.
def list_documents(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document>
list_documents
via a request object, either of type
ListDocumentsRequest or an equivalent Hash.
- request (::Google::Cloud::DiscoveryEngine::V1::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) -> ::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::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 parent branch resource name, such as
projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}
. Usedefault_branch
as the branch ID, to list documents under the default branch.If the caller does not have permission to list [Documents][]s under this branch, regardless of whether or not this branch exists, a
PERMISSION_DENIED
error is returned. -
page_size (::Integer) — Maximum number of Documents to
return. If unspecified, defaults to 100. The maximum allowed value is 1000.
Values above 1000 will be coerced to 1000.
If this field is negative, an
INVALID_ARGUMENT
error is returned. -
page_token (::String) — A page token
ListDocumentsResponse.next_page_token,
received from a previous
DocumentService.ListDocuments
call. Provide this to retrieve the subsequent page.
When paginating, all other parameters provided to DocumentService.ListDocuments must match the call that provided the page token. Otherwise, an
INVALID_ARGUMENT
error is returned.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/discovery_engine/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DiscoveryEngine::V1::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::DiscoveryEngine::V1::Document. p item end
#operations_client
def operations_client() -> ::Google::Cloud::DiscoveryEngine::V1::DocumentService::Operations
Get the associated client for long-running operations.
#purge_documents
def purge_documents(request, options = nil) -> ::Gapic::Operation
def purge_documents(parent: nil, filter: nil, force: nil) -> ::Gapic::Operation
Permanently deletes all selected Documents in a branch.
This process is asynchronous. Depending on the number of Documents to be deleted, this operation can take hours to complete. Before the delete operation completes, some Documents might still be returned by DocumentService.GetDocument or DocumentService.ListDocuments.
To get a list of the {::Google::Cloud::DiscoveryEngine::V1::Document Document}s to be deleted, set PurgeDocumentsRequest.force to false.
def purge_documents(request, options = nil) -> ::Gapic::Operation
purge_documents
via a request object, either of type
PurgeDocumentsRequest or an equivalent Hash.
- request (::Google::Cloud::DiscoveryEngine::V1::PurgeDocumentsRequest, ::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 purge_documents(parent: nil, filter: nil, force: nil) -> ::Gapic::Operation
purge_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 parent resource name, such as
projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}
. -
filter (::String) — Required. Filter matching documents to purge. Only currently supported
value is
*
(all items). -
force (::Boolean) — Actually performs the purge. If
force
is set to false, return the expected purge count without deleting any documents.
- (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/discovery_engine/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DiscoveryEngine::V1::PurgeDocumentsRequest.new # Call the purge_documents method. result = client.purge_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
#update_document
def update_document(request, options = nil) -> ::Google::Cloud::DiscoveryEngine::V1::Document
def update_document(document: nil, allow_missing: nil) -> ::Google::Cloud::DiscoveryEngine::V1::Document
Updates a Document.
def update_document(request, options = nil) -> ::Google::Cloud::DiscoveryEngine::V1::Document
update_document
via a request object, either of type
UpdateDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::DiscoveryEngine::V1::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, allow_missing: nil) -> ::Google::Cloud::DiscoveryEngine::V1::Document
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::DiscoveryEngine::V1::Document, ::Hash) — Required. The document to update/create.
If the caller does not have permission to update the Document, regardless of whether or not it exists, a
PERMISSION_DENIED
error is returned.If the Document to update does not exist and allow_missing is not set, a
NOT_FOUND
error is returned. - allow_missing (::Boolean) — If set to true, and the Document is not found, a new Document will be created.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::DiscoveryEngine::V1::Document)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/discovery_engine/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DiscoveryEngine::V1::UpdateDocumentRequest.new # Call the update_document method. result = client.update_document request # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Document. p result