Class: Google::Cloud::DiscoveryEngine::V1::DocumentService::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/discovery_engine/v1/document_service/client.rb

Overview

Client for the DocumentService service.

Service for ingesting Document information of the customer's website.

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#branch_path, #document_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new DocumentService client object.

Examples:


# 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

Yields:

  • (config)

    Configure the DocumentService client.

Yield Parameters:



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 121

def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/cloud/discoveryengine/v1/document_service_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-")
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @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

  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @config.endpoint
  end

  @document_service_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::DiscoveryEngine::V1::DocumentService::Stub,
    credentials:  credentials,
    endpoint:     @config.endpoint,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors,
    channel_pool_config: @config.channel_pool
  )
end

Instance Attribute Details

#location_clientGoogle::Cloud::Location::Locations::Client (readonly)

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

Returns:

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


182
183
184
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 182

def location_client
  @location_client
end

#operations_client::Google::Cloud::DiscoveryEngine::V1::DocumentService::Operations (readonly)

Get the associated client for long-running operations.



175
176
177
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 175

def operations_client
  @operations_client
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the DocumentService Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all DocumentService clients
::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 58

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "DiscoveryEngine", "V1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.timeout = 30.0
    default_config.retry_policy = {
      initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.import_documents.timeout = 300.0
    default_config.rpcs.import_documents.retry_policy = {
      initial_delay: 1.0, max_delay: 30.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#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 configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



100
101
102
103
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 100

def configure
  yield @config if block_given?
  @config
end

#create_document(request, options = nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document #create_document(parent: nil, document: nil, document_id: nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document

Creates a Document.

Examples:

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

Overloads:

  • #create_document(request, options = nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document

    Pass arguments to create_document via a request object, either of type CreateDocumentRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_document(parent: nil, document: nil, document_id: nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document

    Pass arguments to 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).

    Parameters:

    • parent (::String) (defaults to: nil)

      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) (defaults to: nil)

      Required. The Document to create.

    • document_id (::String) (defaults to: nil)

      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.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 461

def create_document request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::CreateDocumentRequest

  # 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
   = @config.rpcs.create_document..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_document.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_document.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @document_service_stub.call_rpc :create_document, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_document(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_document(name: nil) ⇒ ::Google::Protobuf::Empty

Deletes a Document.

Examples:

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

Overloads:

  • #delete_document(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_document via a request object, either of type Google::Cloud::DiscoveryEngine::V1::DeleteDocumentRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_document(name: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to 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).

    Parameters:

    • name (::String) (defaults to: nil)

      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.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 653

def delete_document request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::DeleteDocumentRequest

  # 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
   = @config.rpcs.delete_document..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
  [:"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("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_document.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_document.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @document_service_stub.call_rpc :delete_document, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_document(request, options = nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document #get_document(name: nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document

Gets a Document.

Examples:

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

Overloads:

  • #get_document(request, options = nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document

    Pass arguments to get_document via a request object, either of type GetDocumentRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_document(name: nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document

    Pass arguments to 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).

    Parameters:

    • name (::String) (defaults to: nil)

      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.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 239

def get_document request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::GetDocumentRequest

  # 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
   = @config.rpcs.get_document..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
  [:"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("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_document.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_document.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @document_service_stub.call_rpc :get_document, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#import_documents(request, options = nil) ⇒ ::Gapic::Operation #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 Documents to be successfully updated.

Examples:

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

Overloads:

  • #import_documents(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to import_documents via a request object, either of type ImportDocumentsRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #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

    Pass arguments to 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).

    Parameters:

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.



814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 814

def import_documents request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest

  # 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
   = @config.rpcs.import_documents..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.import_documents.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.import_documents.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @document_service_stub.call_rpc :import_documents, 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

#list_documents(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document> #list_documents(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document>

Gets a list of Documents.

Examples:

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

Overloads:

  • #list_documents(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document>

    Pass arguments to list_documents via a request object, either of type ListDocumentsRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_documents(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document>

    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).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The parent branch resource name, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}. Use default_branch as the branch ID, to list documents under the default branch.

      If the caller does not have permission to list Documents under this branch, regardless of whether or not this branch exists, a PERMISSION_DENIED error is returned.

    • page_size (::Integer) (defaults to: nil)

      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) (defaults to: nil)

      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.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 353

def list_documents request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::ListDocumentsRequest

  # 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
   = @config.rpcs.list_documents..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_documents.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_documents.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @document_service_stub.call_rpc :list_documents, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @document_service_stub, :list_documents, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#purge_documents(request, options = nil) ⇒ ::Gapic::Operation #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 Documents to be deleted, set PurgeDocumentsRequest.force to false.

Examples:

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

Overloads:

  • #purge_documents(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to purge_documents via a request object, either of type PurgeDocumentsRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #purge_documents(parent: nil, filter: nil, force: nil) ⇒ ::Gapic::Operation

    Pass arguments to 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).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The parent resource name, such as projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}.

    • filter (::String) (defaults to: nil)

      Required. Filter matching documents to purge. Only currently supported value is * (all items).

    • force (::Boolean) (defaults to: nil)

      Actually performs the purge. If force is set to false, return the expected purge count without deleting any documents.

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.



930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 930

def purge_documents request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::PurgeDocumentsRequest

  # 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
   = @config.rpcs.purge_documents..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.purge_documents.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.purge_documents.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @document_service_stub.call_rpc :purge_documents, 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

#update_document(request, options = nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document #update_document(document: nil, allow_missing: nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document

Updates a Document.

Examples:

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

Overloads:

  • #update_document(request, options = nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document

    Pass arguments to update_document via a request object, either of type UpdateDocumentRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_document(document: nil, allow_missing: nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1::Document

    Pass arguments to 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).

    Parameters:

    • document (::Google::Cloud::DiscoveryEngine::V1::Document, ::Hash) (defaults to: nil)

      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) (defaults to: nil)

      If set to true, and the Document is not found, a new Document will be created.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
# File 'lib/google/cloud/discovery_engine/v1/document_service/client.rb', line 559

def update_document request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::UpdateDocumentRequest

  # 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
   = @config.rpcs.update_document..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.document&.name
    header_params["document.name"] = request.document.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_document.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_document.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @document_service_stub.call_rpc :update_document, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end