Class: Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Client

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

Overview

REST 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, #fhir_store_path

Constructor Details

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

Create a new DocumentService REST client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the DocumentService client.

Yield Parameters:



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
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 136

def initialize
  # 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.nil? ||
                           (@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 = ::Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Operations.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @config.endpoint
    config.universe_domain = @config.universe_domain
  end

  @document_service_stub = ::Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::ServiceStub.new(
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    credentials: credentials
  )

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

Instance Attribute Details

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

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

Returns:

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


193
194
195
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 193

def location_client
  @location_client
end

#operations_client::Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Operations (readonly)

Get the associated client for long-running operations.



186
187
188
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 186

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::V1beta::DocumentService::Rest::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 64

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "DiscoveryEngine", "V1beta"]
    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:



106
107
108
109
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 106

def configure
  yield @config if block_given?
  @config
end

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

Creates a Document.

Examples:

Basic example

require "google/cloud/discovery_engine/v1beta"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::DiscoveryEngine::V1beta::CreateDocumentRequest.new

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

# The returned object is of type Google::Cloud::DiscoveryEngine::V1beta::Document.
p result

Overloads:

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

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

    Parameters:

    • request (::Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::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::V1beta::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



457
458
459
460
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
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 457

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.create_document request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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/v1beta"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::DeleteDocumentRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::DiscoveryEngine::V1beta::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 639

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.delete_document request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

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

Gets a Document.

Examples:

Basic example

require "google/cloud/discovery_engine/v1beta"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::DiscoveryEngine::V1beta::GetDocumentRequest.new

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

# The returned object is of type Google::Cloud::DiscoveryEngine::V1beta::Document.
p result

Overloads:

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

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

    Parameters:

    • request (::Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



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
279
280
281
282
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 249

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.get_document request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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, fhir_store_source: nil, spanner_source: nil, cloud_sql_source: nil, firestore_source: nil, bigtable_source: nil, parent: nil, error_config: nil, reconciliation_mode: nil, update_mask: 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/v1beta"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::DiscoveryEngine::V1beta::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:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



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
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 818

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.import_documents request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

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

Gets a list of Documents.

Examples:

Basic example

require "google/cloud/discovery_engine/v1beta"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::Document.
  p item
end

Overloads:

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

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

    Parameters:

    • request (::Google::Cloud::DiscoveryEngine::V1beta::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::Rest::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1beta::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

      1. 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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



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
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 356

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.list_documents request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @document_service_stub, :list_documents, "documents", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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/v1beta"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::Operation)

Raises:

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

    if the REST call is aborted.



928
929
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
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 928

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.purge_documents request, options do |result, operation|
    result = ::Gapic::Operation.new result, @operations_client, options: options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


116
117
118
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 116

def universe_domain
  @document_service_stub.universe_domain
end

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

Updates a Document.

Examples:

Basic example

require "google/cloud/discovery_engine/v1beta"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::DiscoveryEngine::V1beta::UpdateDocumentRequest.new

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

# The returned object is of type Google::Cloud::DiscoveryEngine::V1beta::Document.
p result

Overloads:

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

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

    Parameters:

    • request (::Google::Cloud::DiscoveryEngine::V1beta::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, update_mask: nil) ⇒ ::Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::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.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      Indicates which fields in the provided imported 'document' to update. If not set, will by default update all fields.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



552
553
554
555
556
557
558
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
# File 'lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb', line 552

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::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::V1beta::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.update_document request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end