lib/google/cloud/dialogflow/v2/documents/client.rb in google-cloud-dialogflow-v2-0.12.0 vs lib/google/cloud/dialogflow/v2/documents/client.rb in google-cloud-dialogflow-v2-0.13.0
- old
+ new
@@ -138,10 +138,11 @@
@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.quota_project = @quota_project_id
config.endpoint = @config.endpoint
end
@documents_stub = ::Gapic::ServiceStub.new(
::Google::Cloud::Dialogflow::V2::Documents::Stub,
@@ -172,11 +173,11 @@
# 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 list_documents(parent: nil, page_size: nil, page_token: nil)
+ # @overload list_documents(parent: nil, page_size: nil, page_token: nil, filter: nil)
# Pass arguments to `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).
#
# @param parent [::String]
@@ -186,11 +187,33 @@
# @param page_size [::Integer]
# The maximum number of items to return in a single page. By
# default 10 and at most 100.
# @param page_token [::String]
# The next_page_token value returned from a previous list request.
+ # @param filter [::String]
+ # The filter expression used to filter documents returned by the list method.
+ # The expression has the following syntax:
#
+ # <field> <operator> <value> [AND <field> <operator> <value>] ...
+ #
+ # 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](https://aip.dev/160).
+ #
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Document>]
# @yieldparam operation [::GRPC::ActiveCall::Operation]
#
# @return [::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Document>]
@@ -682,11 +705,11 @@
# 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 reload_document(name: nil, content_uri: nil)
+ # @overload reload_document(name: nil, content_uri: nil, import_gcs_custom_metadata: nil, smart_messaging_partial_update: nil)
# Pass arguments to `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).
#
# @param name [::String]
@@ -697,10 +720,16 @@
# 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>`.
+ # @param 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.
+ # @param smart_messaging_partial_update [::Boolean]
+ # Optional. When enabled, the reload request is to apply partial update to the smart
+ # messaging allowlist.
#
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Gapic::Operation]
# @yieldparam operation [::GRPC::ActiveCall::Operation]
#
@@ -771,10 +800,121 @@
rescue ::GRPC::BadStatus => e
raise ::Google::Cloud::Error.from_error(e)
end
##
+ # Exports a smart messaging candidate document into the specified
+ # destination.
+ #
+ # This method is a [long-running
+ # operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation).
+ # The returned `Operation` type has the following method-specific fields:
+ #
+ # - `metadata`: {::Google::Cloud::Dialogflow::V2::KnowledgeOperationMetadata KnowledgeOperationMetadata}
+ # - `response`: {::Google::Cloud::Dialogflow::V2::Document Document}
+ #
+ # @overload export_document(request, options = nil)
+ # Pass arguments to `export_document` via a request object, either of type
+ # {::Google::Cloud::Dialogflow::V2::ExportDocumentRequest} or an equivalent Hash.
+ #
+ # @param 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.
+ # @param options [::Gapic::CallOptions, ::Hash]
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
+ #
+ # @overload export_document(name: nil, gcs_destination: nil, export_full_content: nil, smart_messaging_partial_update: nil)
+ # Pass arguments to `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).
+ #
+ # @param name [::String]
+ # Required. The name of the document to export.
+ # Format: `projects/<Project ID>/locations/<Location
+ # ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>`.
+ # @param gcs_destination [::Google::Cloud::Dialogflow::V2::GcsDestination, ::Hash]
+ # Cloud Storage file path to export the document.
+ # @param export_full_content [::Boolean]
+ # When enabled, export the full content of the document including empirical
+ # probability.
+ # @param smart_messaging_partial_update [::Boolean]
+ # When enabled, export the smart messaging allowlist document for partial
+ # update.
+ #
+ # @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.
+ #
+ # @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::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 this
+ # # object to check the status of an operation, cancel it, or wait
+ # # for results. Here is how to block until completion:
+ # result.wait_until_done! timeout: 60
+ # if result.response?
+ # p result.response
+ # else
+ # puts "Error!"
+ # end
+ #
+ def export_document request, options = nil
+ raise ::ArgumentError, "request must be provided" if request.nil?
+
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::ExportDocumentRequest
+
+ # 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_document.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 = {}
+ if request.name
+ header_params["name"] = request.name
+ end
+
+ 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_document.timeout,
+ metadata: metadata,
+ retry_policy: @config.rpcs.export_document.retry_policy
+
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
+
+ @documents_stub.call_rpc :export_document, 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
+
+ ##
# Configuration class for the Documents API.
#
# This class represents the configuration for Documents,
# providing control over timeouts, retry behavior, logging, transport
# parameters, and other low-level controls. Certain parameters can also be
@@ -935,10 +1075,15 @@
##
# RPC-specific configuration for `reload_document`
# @return [::Gapic::Config::Method]
#
attr_reader :reload_document
+ ##
+ # RPC-specific configuration for `export_document`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :export_document
# @private
def initialize parent_rpcs = nil
list_documents_config = parent_rpcs.list_documents if parent_rpcs.respond_to? :list_documents
@list_documents = ::Gapic::Config::Method.new list_documents_config
@@ -950,9 +1095,11 @@
@delete_document = ::Gapic::Config::Method.new delete_document_config
update_document_config = parent_rpcs.update_document if parent_rpcs.respond_to? :update_document
@update_document = ::Gapic::Config::Method.new update_document_config
reload_document_config = parent_rpcs.reload_document if parent_rpcs.respond_to? :reload_document
@reload_document = ::Gapic::Config::Method.new reload_document_config
+ export_document_config = parent_rpcs.export_document if parent_rpcs.respond_to? :export_document
+ @export_document = ::Gapic::Config::Method.new export_document_config
yield self if block_given?
end
end
end