google-cloud-document_ai-v1beta3 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +72 -101
- data/lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb +34 -9
- data/lib/google/cloud/document_ai/v1beta3/document_processor_service/operations.rb +28 -6
- data/lib/google/cloud/document_ai/v1beta3/document_processor_service/rest/client.rb +36 -8
- data/lib/google/cloud/document_ai/v1beta3/document_processor_service/rest/operations.rb +33 -8
- data/lib/google/cloud/document_ai/v1beta3/document_processor_service/rest/service_stub.rb +14 -2
- data/lib/google/cloud/document_ai/v1beta3/document_service/client.rb +175 -8
- data/lib/google/cloud/document_ai/v1beta3/document_service/operations.rb +28 -6
- data/lib/google/cloud/document_ai/v1beta3/document_service/rest/client.rb +170 -7
- data/lib/google/cloud/document_ai/v1beta3/document_service/rest/operations.rb +33 -8
- data/lib/google/cloud/document_ai/v1beta3/document_service/rest/service_stub.rb +74 -2
- data/lib/google/cloud/document_ai/v1beta3/version.rb +1 -1
- data/lib/google/cloud/documentai/v1beta3/document_io_pb.rb +1 -1
- data/lib/google/cloud/documentai/v1beta3/document_processor_service_pb.rb +2 -2
- data/lib/google/cloud/documentai/v1beta3/document_schema_pb.rb +5 -1
- data/lib/google/cloud/documentai/v1beta3/document_service_pb.rb +5 -1
- data/lib/google/cloud/documentai/v1beta3/document_service_services_pb.rb +2 -0
- data/lib/google/cloud/documentai/v1beta3/processor_pb.rb +2 -1
- data/proto_docs/google/api/client.rb +14 -0
- data/proto_docs/google/cloud/documentai/v1beta3/dataset.rb +1 -0
- data/proto_docs/google/cloud/documentai/v1beta3/document.rb +14 -1
- data/proto_docs/google/cloud/documentai/v1beta3/document_io.rb +11 -3
- data/proto_docs/google/cloud/documentai/v1beta3/document_processor_service.rb +26 -9
- data/proto_docs/google/cloud/documentai/v1beta3/document_schema.rb +51 -0
- data/proto_docs/google/cloud/documentai/v1beta3/document_service.rb +115 -7
- data/proto_docs/google/cloud/documentai/v1beta3/processor.rb +15 -0
- metadata +7 -7
@@ -30,16 +30,28 @@ module Google
|
|
30
30
|
# including transcoding, making the REST call, and deserialing the response.
|
31
31
|
#
|
32
32
|
class ServiceStub
|
33
|
-
def initialize endpoint:, credentials:
|
33
|
+
def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
|
34
34
|
# These require statements are intentionally placed here to initialize
|
35
35
|
# the REST modules only when it's required.
|
36
36
|
require "gapic/rest"
|
37
37
|
|
38
|
-
@client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
|
38
|
+
@client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
|
39
|
+
endpoint_template: endpoint_template,
|
40
|
+
universe_domain: universe_domain,
|
41
|
+
credentials: credentials,
|
39
42
|
numeric_enums: true,
|
40
43
|
raise_faraday_errors: false
|
41
44
|
end
|
42
45
|
|
46
|
+
##
|
47
|
+
# The effective universe domain
|
48
|
+
#
|
49
|
+
# @return [String]
|
50
|
+
#
|
51
|
+
def universe_domain
|
52
|
+
@client_stub.universe_domain
|
53
|
+
end
|
54
|
+
|
43
55
|
##
|
44
56
|
# Baseline implementation for the process_document REST call
|
45
57
|
#
|
@@ -31,6 +31,9 @@ module Google
|
|
31
31
|
# Service to call Cloud DocumentAI to manage document collection (dataset).
|
32
32
|
#
|
33
33
|
class Client
|
34
|
+
# @private
|
35
|
+
DEFAULT_ENDPOINT_TEMPLATE = "documentai.$UNIVERSE_DOMAIN$"
|
36
|
+
|
34
37
|
include Paths
|
35
38
|
|
36
39
|
# @private
|
@@ -91,6 +94,15 @@ module Google
|
|
91
94
|
@config
|
92
95
|
end
|
93
96
|
|
97
|
+
##
|
98
|
+
# The effective universe domain
|
99
|
+
#
|
100
|
+
# @return [String]
|
101
|
+
#
|
102
|
+
def universe_domain
|
103
|
+
@document_service_stub.universe_domain
|
104
|
+
end
|
105
|
+
|
94
106
|
##
|
95
107
|
# Create a new DocumentService client object.
|
96
108
|
#
|
@@ -124,8 +136,9 @@ module Google
|
|
124
136
|
credentials = @config.credentials
|
125
137
|
# Use self-signed JWT if the endpoint is unchanged from default,
|
126
138
|
# but only if the default endpoint does not have a region prefix.
|
127
|
-
enable_self_signed_jwt = @config.endpoint
|
128
|
-
|
139
|
+
enable_self_signed_jwt = @config.endpoint.nil? ||
|
140
|
+
(@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
|
141
|
+
!@config.endpoint.split(".").first.include?("-"))
|
129
142
|
credentials ||= Credentials.default scope: @config.scope,
|
130
143
|
enable_self_signed_jwt: enable_self_signed_jwt
|
131
144
|
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
@@ -138,18 +151,22 @@ module Google
|
|
138
151
|
config.credentials = credentials
|
139
152
|
config.quota_project = @quota_project_id
|
140
153
|
config.endpoint = @config.endpoint
|
154
|
+
config.universe_domain = @config.universe_domain
|
141
155
|
end
|
142
156
|
|
143
157
|
@location_client = Google::Cloud::Location::Locations::Client.new do |config|
|
144
158
|
config.credentials = credentials
|
145
159
|
config.quota_project = @quota_project_id
|
146
160
|
config.endpoint = @config.endpoint
|
161
|
+
config.universe_domain = @config.universe_domain
|
147
162
|
end
|
148
163
|
|
149
164
|
@document_service_stub = ::Gapic::ServiceStub.new(
|
150
165
|
::Google::Cloud::DocumentAI::V1beta3::DocumentService::Stub,
|
151
|
-
credentials:
|
152
|
-
endpoint:
|
166
|
+
credentials: credentials,
|
167
|
+
endpoint: @config.endpoint,
|
168
|
+
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
|
169
|
+
universe_domain: @config.universe_domain,
|
153
170
|
channel_args: @config.channel_args,
|
154
171
|
interceptors: @config.interceptors,
|
155
172
|
channel_pool_config: @config.channel_pool
|
@@ -461,6 +478,141 @@ module Google
|
|
461
478
|
raise ::Google::Cloud::Error.from_error(e)
|
462
479
|
end
|
463
480
|
|
481
|
+
##
|
482
|
+
# Returns a list of documents present in the dataset.
|
483
|
+
#
|
484
|
+
# @overload list_documents(request, options = nil)
|
485
|
+
# Pass arguments to `list_documents` via a request object, either of type
|
486
|
+
# {::Google::Cloud::DocumentAI::V1beta3::ListDocumentsRequest} or an equivalent Hash.
|
487
|
+
#
|
488
|
+
# @param request [::Google::Cloud::DocumentAI::V1beta3::ListDocumentsRequest, ::Hash]
|
489
|
+
# A request object representing the call parameters. Required. To specify no
|
490
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
491
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
492
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
493
|
+
#
|
494
|
+
# @overload list_documents(dataset: nil, page_size: nil, page_token: nil, filter: nil, return_total_size: nil, skip: nil)
|
495
|
+
# Pass arguments to `list_documents` via keyword arguments. Note that at
|
496
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
497
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
498
|
+
#
|
499
|
+
# @param dataset [::String]
|
500
|
+
# Required. The resource name of the dataset to be listed.
|
501
|
+
# Format:
|
502
|
+
# projects/\\{project}/locations/\\{location}/processors/\\{processor}/dataset
|
503
|
+
# @param page_size [::Integer]
|
504
|
+
# The maximum number of documents to return. The service may return
|
505
|
+
# fewer than this value.
|
506
|
+
# If unspecified, at most 20 documents will be returned.
|
507
|
+
# The maximum value is 100; values above 100 will be coerced to 100.
|
508
|
+
# @param page_token [::String]
|
509
|
+
# A page token, received from a previous `ListDocuments` call.
|
510
|
+
# Provide this to retrieve the subsequent page.
|
511
|
+
#
|
512
|
+
# When paginating, all other parameters provided to `ListDocuments`
|
513
|
+
# must match the call that provided the page token.
|
514
|
+
# @param filter [::String]
|
515
|
+
# Optional. Query to filter the documents based on
|
516
|
+
# https://google.aip.dev/160.
|
517
|
+
# ## Currently support query strings are:
|
518
|
+
#
|
519
|
+
# `SplitType=DATASET_SPLIT_TEST|DATASET_SPLIT_TRAIN|DATASET_SPLIT_UNASSIGNED`
|
520
|
+
# - `LabelingState=DOCUMENT_LABELED|DOCUMENT_UNLABELED|DOCUMENT_AUTO_LABELED`
|
521
|
+
# - `DisplayName=\"file_name.pdf\"`
|
522
|
+
# - `EntityType=abc/def`
|
523
|
+
# - `TagName=\"auto-labeling-running\"|\"sampled\"`
|
524
|
+
#
|
525
|
+
# Note:
|
526
|
+
# - Only `AND`, `=` and `!=` are supported.
|
527
|
+
# e.g. `DisplayName=file_name AND EntityType!=abc` IS supported.
|
528
|
+
# - Wildcard `*` is supported only in `DisplayName` filter
|
529
|
+
# - No duplicate filter keys are allowed,
|
530
|
+
# e.g. `EntityType=a AND EntityType=b` is NOT supported.
|
531
|
+
# - String match is case sensitive (for filter `DisplayName` & `EntityType`).
|
532
|
+
# @param return_total_size [::Boolean]
|
533
|
+
# Optional. Controls if the ListDocuments request requires a total size
|
534
|
+
# of matched documents. See ListDocumentsResponse.total_size.
|
535
|
+
#
|
536
|
+
# Enabling this flag may adversely impact performance.
|
537
|
+
#
|
538
|
+
# Defaults to false.
|
539
|
+
# @param skip [::Integer]
|
540
|
+
# Optional. Number of results to skip beginning from the `page_token` if
|
541
|
+
# provided. https://google.aip.dev/158#skipping-results. It must be a
|
542
|
+
# non-negative integer. Negative values wil be rejected. Note that this is
|
543
|
+
# not the number of pages to skip. If this value causes the cursor to move
|
544
|
+
# past the end of results, `ListDocumentsResponse.document_metadata` and
|
545
|
+
# `ListDocumentsResponse.next_page_token` will be empty.
|
546
|
+
#
|
547
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
548
|
+
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::DocumentMetadata>]
|
549
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
550
|
+
#
|
551
|
+
# @return [::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::DocumentMetadata>]
|
552
|
+
#
|
553
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
554
|
+
#
|
555
|
+
# @example Basic example
|
556
|
+
# require "google/cloud/document_ai/v1beta3"
|
557
|
+
#
|
558
|
+
# # Create a client object. The client can be reused for multiple calls.
|
559
|
+
# client = Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.new
|
560
|
+
#
|
561
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
562
|
+
# request = Google::Cloud::DocumentAI::V1beta3::ListDocumentsRequest.new
|
563
|
+
#
|
564
|
+
# # Call the list_documents method.
|
565
|
+
# result = client.list_documents request
|
566
|
+
#
|
567
|
+
# # The returned object is of type Gapic::PagedEnumerable. You can iterate
|
568
|
+
# # over elements, and API calls will be issued to fetch pages as needed.
|
569
|
+
# result.each do |item|
|
570
|
+
# # Each element is of type ::Google::Cloud::DocumentAI::V1beta3::DocumentMetadata.
|
571
|
+
# p item
|
572
|
+
# end
|
573
|
+
#
|
574
|
+
def list_documents request, options = nil
|
575
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
576
|
+
|
577
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ListDocumentsRequest
|
578
|
+
|
579
|
+
# Converts hash and nil to an options object
|
580
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
581
|
+
|
582
|
+
# Customize the options with defaults
|
583
|
+
metadata = @config.rpcs.list_documents.metadata.to_h
|
584
|
+
|
585
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
586
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
587
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
588
|
+
gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
|
589
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
590
|
+
|
591
|
+
header_params = {}
|
592
|
+
if request.dataset
|
593
|
+
header_params["dataset"] = request.dataset
|
594
|
+
end
|
595
|
+
|
596
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
597
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
598
|
+
|
599
|
+
options.apply_defaults timeout: @config.rpcs.list_documents.timeout,
|
600
|
+
metadata: metadata,
|
601
|
+
retry_policy: @config.rpcs.list_documents.retry_policy
|
602
|
+
|
603
|
+
options.apply_defaults timeout: @config.timeout,
|
604
|
+
metadata: @config.metadata,
|
605
|
+
retry_policy: @config.retry_policy
|
606
|
+
|
607
|
+
@document_service_stub.call_rpc :list_documents, request, options: options do |response, operation|
|
608
|
+
response = ::Gapic::PagedEnumerable.new @document_service_stub, :list_documents, request, response, operation, options
|
609
|
+
yield response, operation if block_given?
|
610
|
+
return response
|
611
|
+
end
|
612
|
+
rescue ::GRPC::BadStatus => e
|
613
|
+
raise ::Google::Cloud::Error.from_error(e)
|
614
|
+
end
|
615
|
+
|
464
616
|
##
|
465
617
|
# Deletes a set of documents.
|
466
618
|
#
|
@@ -768,9 +920,9 @@ module Google
|
|
768
920
|
# end
|
769
921
|
#
|
770
922
|
# @!attribute [rw] endpoint
|
771
|
-
#
|
772
|
-
#
|
773
|
-
# @return [::String]
|
923
|
+
# A custom service endpoint, as a hostname or hostname:port. The default is
|
924
|
+
# nil, indicating to use the default endpoint in the current universe domain.
|
925
|
+
# @return [::String,nil]
|
774
926
|
# @!attribute [rw] credentials
|
775
927
|
# Credentials to send with calls. You may provide any of the following types:
|
776
928
|
# * (`String`) The path to a service account key file in JSON format
|
@@ -816,13 +968,20 @@ module Google
|
|
816
968
|
# @!attribute [rw] quota_project
|
817
969
|
# A separate project against which to charge quota.
|
818
970
|
# @return [::String]
|
971
|
+
# @!attribute [rw] universe_domain
|
972
|
+
# The universe domain within which to make requests. This determines the
|
973
|
+
# default endpoint URL. The default value of nil uses the environment
|
974
|
+
# universe (usually the default "googleapis.com" universe).
|
975
|
+
# @return [::String,nil]
|
819
976
|
#
|
820
977
|
class Configuration
|
821
978
|
extend ::Gapic::Config
|
822
979
|
|
980
|
+
# @private
|
981
|
+
# The endpoint specific to the default "googleapis.com" universe. Deprecated.
|
823
982
|
DEFAULT_ENDPOINT = "documentai.googleapis.com"
|
824
983
|
|
825
|
-
config_attr :endpoint,
|
984
|
+
config_attr :endpoint, nil, ::String, nil
|
826
985
|
config_attr :credentials, nil do |value|
|
827
986
|
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
828
987
|
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
@@ -837,6 +996,7 @@ module Google
|
|
837
996
|
config_attr :metadata, nil, ::Hash, nil
|
838
997
|
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
839
998
|
config_attr :quota_project, nil, ::String, nil
|
999
|
+
config_attr :universe_domain, nil, ::String, nil
|
840
1000
|
|
841
1001
|
# @private
|
842
1002
|
def initialize parent_config = nil
|
@@ -899,6 +1059,11 @@ module Google
|
|
899
1059
|
#
|
900
1060
|
attr_reader :get_document
|
901
1061
|
##
|
1062
|
+
# RPC-specific configuration for `list_documents`
|
1063
|
+
# @return [::Gapic::Config::Method]
|
1064
|
+
#
|
1065
|
+
attr_reader :list_documents
|
1066
|
+
##
|
902
1067
|
# RPC-specific configuration for `batch_delete_documents`
|
903
1068
|
# @return [::Gapic::Config::Method]
|
904
1069
|
#
|
@@ -922,6 +1087,8 @@ module Google
|
|
922
1087
|
@import_documents = ::Gapic::Config::Method.new import_documents_config
|
923
1088
|
get_document_config = parent_rpcs.get_document if parent_rpcs.respond_to? :get_document
|
924
1089
|
@get_document = ::Gapic::Config::Method.new get_document_config
|
1090
|
+
list_documents_config = parent_rpcs.list_documents if parent_rpcs.respond_to? :list_documents
|
1091
|
+
@list_documents = ::Gapic::Config::Method.new list_documents_config
|
925
1092
|
batch_delete_documents_config = parent_rpcs.batch_delete_documents if parent_rpcs.respond_to? :batch_delete_documents
|
926
1093
|
@batch_delete_documents = ::Gapic::Config::Method.new batch_delete_documents_config
|
927
1094
|
get_dataset_schema_config = parent_rpcs.get_dataset_schema if parent_rpcs.respond_to? :get_dataset_schema
|
@@ -26,6 +26,9 @@ module Google
|
|
26
26
|
module DocumentService
|
27
27
|
# Service that implements Longrunning Operations API.
|
28
28
|
class Operations
|
29
|
+
# @private
|
30
|
+
DEFAULT_ENDPOINT_TEMPLATE = "documentai.$UNIVERSE_DOMAIN$"
|
31
|
+
|
29
32
|
# @private
|
30
33
|
attr_reader :operations_stub
|
31
34
|
|
@@ -60,6 +63,15 @@ module Google
|
|
60
63
|
@config
|
61
64
|
end
|
62
65
|
|
66
|
+
##
|
67
|
+
# The effective universe domain
|
68
|
+
#
|
69
|
+
# @return [String]
|
70
|
+
#
|
71
|
+
def universe_domain
|
72
|
+
@operations_stub.universe_domain
|
73
|
+
end
|
74
|
+
|
63
75
|
##
|
64
76
|
# Create a new Operations client object.
|
65
77
|
#
|
@@ -90,8 +102,10 @@ module Google
|
|
90
102
|
|
91
103
|
@operations_stub = ::Gapic::ServiceStub.new(
|
92
104
|
::Google::Longrunning::Operations::Stub,
|
93
|
-
credentials:
|
94
|
-
endpoint:
|
105
|
+
credentials: credentials,
|
106
|
+
endpoint: @config.endpoint,
|
107
|
+
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
|
108
|
+
universe_domain: @config.universe_domain,
|
95
109
|
channel_args: @config.channel_args,
|
96
110
|
interceptors: @config.interceptors,
|
97
111
|
channel_pool_config: @config.channel_pool
|
@@ -613,9 +627,9 @@ module Google
|
|
613
627
|
# end
|
614
628
|
#
|
615
629
|
# @!attribute [rw] endpoint
|
616
|
-
#
|
617
|
-
#
|
618
|
-
# @return [::String]
|
630
|
+
# A custom service endpoint, as a hostname or hostname:port. The default is
|
631
|
+
# nil, indicating to use the default endpoint in the current universe domain.
|
632
|
+
# @return [::String,nil]
|
619
633
|
# @!attribute [rw] credentials
|
620
634
|
# Credentials to send with calls. You may provide any of the following types:
|
621
635
|
# * (`String`) The path to a service account key file in JSON format
|
@@ -661,13 +675,20 @@ module Google
|
|
661
675
|
# @!attribute [rw] quota_project
|
662
676
|
# A separate project against which to charge quota.
|
663
677
|
# @return [::String]
|
678
|
+
# @!attribute [rw] universe_domain
|
679
|
+
# The universe domain within which to make requests. This determines the
|
680
|
+
# default endpoint URL. The default value of nil uses the environment
|
681
|
+
# universe (usually the default "googleapis.com" universe).
|
682
|
+
# @return [::String,nil]
|
664
683
|
#
|
665
684
|
class Configuration
|
666
685
|
extend ::Gapic::Config
|
667
686
|
|
687
|
+
# @private
|
688
|
+
# The endpoint specific to the default "googleapis.com" universe. Deprecated.
|
668
689
|
DEFAULT_ENDPOINT = "documentai.googleapis.com"
|
669
690
|
|
670
|
-
config_attr :endpoint,
|
691
|
+
config_attr :endpoint, nil, ::String, nil
|
671
692
|
config_attr :credentials, nil do |value|
|
672
693
|
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
673
694
|
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
@@ -682,6 +703,7 @@ module Google
|
|
682
703
|
config_attr :metadata, nil, ::Hash, nil
|
683
704
|
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
684
705
|
config_attr :quota_project, nil, ::String, nil
|
706
|
+
config_attr :universe_domain, nil, ::String, nil
|
685
707
|
|
686
708
|
# @private
|
687
709
|
def initialize parent_config = nil
|
@@ -33,6 +33,9 @@ module Google
|
|
33
33
|
# Service to call Cloud DocumentAI to manage document collection (dataset).
|
34
34
|
#
|
35
35
|
class Client
|
36
|
+
# @private
|
37
|
+
DEFAULT_ENDPOINT_TEMPLATE = "documentai.$UNIVERSE_DOMAIN$"
|
38
|
+
|
36
39
|
include Paths
|
37
40
|
|
38
41
|
# @private
|
@@ -93,6 +96,15 @@ module Google
|
|
93
96
|
@config
|
94
97
|
end
|
95
98
|
|
99
|
+
##
|
100
|
+
# The effective universe domain
|
101
|
+
#
|
102
|
+
# @return [String]
|
103
|
+
#
|
104
|
+
def universe_domain
|
105
|
+
@document_service_stub.universe_domain
|
106
|
+
end
|
107
|
+
|
96
108
|
##
|
97
109
|
# Create a new DocumentService REST client object.
|
98
110
|
#
|
@@ -120,8 +132,9 @@ module Google
|
|
120
132
|
credentials = @config.credentials
|
121
133
|
# Use self-signed JWT if the endpoint is unchanged from default,
|
122
134
|
# but only if the default endpoint does not have a region prefix.
|
123
|
-
enable_self_signed_jwt = @config.endpoint
|
124
|
-
|
135
|
+
enable_self_signed_jwt = @config.endpoint.nil? ||
|
136
|
+
(@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
|
137
|
+
!@config.endpoint.split(".").first.include?("-"))
|
125
138
|
credentials ||= Credentials.default scope: @config.scope,
|
126
139
|
enable_self_signed_jwt: enable_self_signed_jwt
|
127
140
|
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
@@ -135,16 +148,23 @@ module Google
|
|
135
148
|
config.credentials = credentials
|
136
149
|
config.quota_project = @quota_project_id
|
137
150
|
config.endpoint = @config.endpoint
|
151
|
+
config.universe_domain = @config.universe_domain
|
138
152
|
end
|
139
153
|
|
140
154
|
@location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
|
141
155
|
config.credentials = credentials
|
142
156
|
config.quota_project = @quota_project_id
|
143
157
|
config.endpoint = @config.endpoint
|
158
|
+
config.universe_domain = @config.universe_domain
|
144
159
|
config.bindings_override = @config.bindings_override
|
145
160
|
end
|
146
161
|
|
147
|
-
@document_service_stub = ::Google::Cloud::DocumentAI::V1beta3::DocumentService::Rest::ServiceStub.new
|
162
|
+
@document_service_stub = ::Google::Cloud::DocumentAI::V1beta3::DocumentService::Rest::ServiceStub.new(
|
163
|
+
endpoint: @config.endpoint,
|
164
|
+
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
|
165
|
+
universe_domain: @config.universe_domain,
|
166
|
+
credentials: credentials
|
167
|
+
)
|
148
168
|
end
|
149
169
|
|
150
170
|
##
|
@@ -431,6 +451,134 @@ module Google
|
|
431
451
|
raise ::Google::Cloud::Error.from_error(e)
|
432
452
|
end
|
433
453
|
|
454
|
+
##
|
455
|
+
# Returns a list of documents present in the dataset.
|
456
|
+
#
|
457
|
+
# @overload list_documents(request, options = nil)
|
458
|
+
# Pass arguments to `list_documents` via a request object, either of type
|
459
|
+
# {::Google::Cloud::DocumentAI::V1beta3::ListDocumentsRequest} or an equivalent Hash.
|
460
|
+
#
|
461
|
+
# @param request [::Google::Cloud::DocumentAI::V1beta3::ListDocumentsRequest, ::Hash]
|
462
|
+
# A request object representing the call parameters. Required. To specify no
|
463
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
464
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
465
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
466
|
+
#
|
467
|
+
# @overload list_documents(dataset: nil, page_size: nil, page_token: nil, filter: nil, return_total_size: nil, skip: nil)
|
468
|
+
# Pass arguments to `list_documents` via keyword arguments. Note that at
|
469
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
470
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
471
|
+
#
|
472
|
+
# @param dataset [::String]
|
473
|
+
# Required. The resource name of the dataset to be listed.
|
474
|
+
# Format:
|
475
|
+
# projects/\\{project}/locations/\\{location}/processors/\\{processor}/dataset
|
476
|
+
# @param page_size [::Integer]
|
477
|
+
# The maximum number of documents to return. The service may return
|
478
|
+
# fewer than this value.
|
479
|
+
# If unspecified, at most 20 documents will be returned.
|
480
|
+
# The maximum value is 100; values above 100 will be coerced to 100.
|
481
|
+
# @param page_token [::String]
|
482
|
+
# A page token, received from a previous `ListDocuments` call.
|
483
|
+
# Provide this to retrieve the subsequent page.
|
484
|
+
#
|
485
|
+
# When paginating, all other parameters provided to `ListDocuments`
|
486
|
+
# must match the call that provided the page token.
|
487
|
+
# @param filter [::String]
|
488
|
+
# Optional. Query to filter the documents based on
|
489
|
+
# https://google.aip.dev/160.
|
490
|
+
# ## Currently support query strings are:
|
491
|
+
#
|
492
|
+
# `SplitType=DATASET_SPLIT_TEST|DATASET_SPLIT_TRAIN|DATASET_SPLIT_UNASSIGNED`
|
493
|
+
# - `LabelingState=DOCUMENT_LABELED|DOCUMENT_UNLABELED|DOCUMENT_AUTO_LABELED`
|
494
|
+
# - `DisplayName=\"file_name.pdf\"`
|
495
|
+
# - `EntityType=abc/def`
|
496
|
+
# - `TagName=\"auto-labeling-running\"|\"sampled\"`
|
497
|
+
#
|
498
|
+
# Note:
|
499
|
+
# - Only `AND`, `=` and `!=` are supported.
|
500
|
+
# e.g. `DisplayName=file_name AND EntityType!=abc` IS supported.
|
501
|
+
# - Wildcard `*` is supported only in `DisplayName` filter
|
502
|
+
# - No duplicate filter keys are allowed,
|
503
|
+
# e.g. `EntityType=a AND EntityType=b` is NOT supported.
|
504
|
+
# - String match is case sensitive (for filter `DisplayName` & `EntityType`).
|
505
|
+
# @param return_total_size [::Boolean]
|
506
|
+
# Optional. Controls if the ListDocuments request requires a total size
|
507
|
+
# of matched documents. See ListDocumentsResponse.total_size.
|
508
|
+
#
|
509
|
+
# Enabling this flag may adversely impact performance.
|
510
|
+
#
|
511
|
+
# Defaults to false.
|
512
|
+
# @param skip [::Integer]
|
513
|
+
# Optional. Number of results to skip beginning from the `page_token` if
|
514
|
+
# provided. https://google.aip.dev/158#skipping-results. It must be a
|
515
|
+
# non-negative integer. Negative values wil be rejected. Note that this is
|
516
|
+
# not the number of pages to skip. If this value causes the cursor to move
|
517
|
+
# past the end of results, `ListDocumentsResponse.document_metadata` and
|
518
|
+
# `ListDocumentsResponse.next_page_token` will be empty.
|
519
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
520
|
+
# @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::DocumentMetadata>]
|
521
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
522
|
+
#
|
523
|
+
# @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::DocumentMetadata>]
|
524
|
+
#
|
525
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
526
|
+
#
|
527
|
+
# @example Basic example
|
528
|
+
# require "google/cloud/document_ai/v1beta3"
|
529
|
+
#
|
530
|
+
# # Create a client object. The client can be reused for multiple calls.
|
531
|
+
# client = Google::Cloud::DocumentAI::V1beta3::DocumentService::Rest::Client.new
|
532
|
+
#
|
533
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
534
|
+
# request = Google::Cloud::DocumentAI::V1beta3::ListDocumentsRequest.new
|
535
|
+
#
|
536
|
+
# # Call the list_documents method.
|
537
|
+
# result = client.list_documents request
|
538
|
+
#
|
539
|
+
# # The returned object is of type Gapic::PagedEnumerable. You can iterate
|
540
|
+
# # over elements, and API calls will be issued to fetch pages as needed.
|
541
|
+
# result.each do |item|
|
542
|
+
# # Each element is of type ::Google::Cloud::DocumentAI::V1beta3::DocumentMetadata.
|
543
|
+
# p item
|
544
|
+
# end
|
545
|
+
#
|
546
|
+
def list_documents request, options = nil
|
547
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
548
|
+
|
549
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ListDocumentsRequest
|
550
|
+
|
551
|
+
# Converts hash and nil to an options object
|
552
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
553
|
+
|
554
|
+
# Customize the options with defaults
|
555
|
+
call_metadata = @config.rpcs.list_documents.metadata.to_h
|
556
|
+
|
557
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
558
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
559
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
560
|
+
gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION,
|
561
|
+
transports_version_send: [:rest]
|
562
|
+
|
563
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
564
|
+
|
565
|
+
options.apply_defaults timeout: @config.rpcs.list_documents.timeout,
|
566
|
+
metadata: call_metadata,
|
567
|
+
retry_policy: @config.rpcs.list_documents.retry_policy
|
568
|
+
|
569
|
+
options.apply_defaults timeout: @config.timeout,
|
570
|
+
metadata: @config.metadata,
|
571
|
+
retry_policy: @config.retry_policy
|
572
|
+
|
573
|
+
@document_service_stub.list_documents request, options do |result, operation|
|
574
|
+
result = ::Gapic::Rest::PagedEnumerable.new @document_service_stub, :list_documents, "document_metadata", request, result, options
|
575
|
+
yield result, operation if block_given?
|
576
|
+
return result
|
577
|
+
end
|
578
|
+
rescue ::Gapic::Rest::Error => e
|
579
|
+
raise ::Google::Cloud::Error.from_error(e)
|
580
|
+
end
|
581
|
+
|
434
582
|
##
|
435
583
|
# Deletes a set of documents.
|
436
584
|
#
|
@@ -717,9 +865,9 @@ module Google
|
|
717
865
|
# end
|
718
866
|
#
|
719
867
|
# @!attribute [rw] endpoint
|
720
|
-
#
|
721
|
-
#
|
722
|
-
# @return [::String]
|
868
|
+
# A custom service endpoint, as a hostname or hostname:port. The default is
|
869
|
+
# nil, indicating to use the default endpoint in the current universe domain.
|
870
|
+
# @return [::String,nil]
|
723
871
|
# @!attribute [rw] credentials
|
724
872
|
# Credentials to send with calls. You may provide any of the following types:
|
725
873
|
# * (`String`) The path to a service account key file in JSON format
|
@@ -756,13 +904,20 @@ module Google
|
|
756
904
|
# @!attribute [rw] quota_project
|
757
905
|
# A separate project against which to charge quota.
|
758
906
|
# @return [::String]
|
907
|
+
# @!attribute [rw] universe_domain
|
908
|
+
# The universe domain within which to make requests. This determines the
|
909
|
+
# default endpoint URL. The default value of nil uses the environment
|
910
|
+
# universe (usually the default "googleapis.com" universe).
|
911
|
+
# @return [::String,nil]
|
759
912
|
#
|
760
913
|
class Configuration
|
761
914
|
extend ::Gapic::Config
|
762
915
|
|
916
|
+
# @private
|
917
|
+
# The endpoint specific to the default "googleapis.com" universe. Deprecated.
|
763
918
|
DEFAULT_ENDPOINT = "documentai.googleapis.com"
|
764
919
|
|
765
|
-
config_attr :endpoint,
|
920
|
+
config_attr :endpoint, nil, ::String, nil
|
766
921
|
config_attr :credentials, nil do |value|
|
767
922
|
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
768
923
|
allowed.any? { |klass| klass === value }
|
@@ -774,6 +929,7 @@ module Google
|
|
774
929
|
config_attr :metadata, nil, ::Hash, nil
|
775
930
|
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
776
931
|
config_attr :quota_project, nil, ::String, nil
|
932
|
+
config_attr :universe_domain, nil, ::String, nil
|
777
933
|
|
778
934
|
# @private
|
779
935
|
# Overrides for http bindings for the RPCs of this service
|
@@ -835,6 +991,11 @@ module Google
|
|
835
991
|
#
|
836
992
|
attr_reader :get_document
|
837
993
|
##
|
994
|
+
# RPC-specific configuration for `list_documents`
|
995
|
+
# @return [::Gapic::Config::Method]
|
996
|
+
#
|
997
|
+
attr_reader :list_documents
|
998
|
+
##
|
838
999
|
# RPC-specific configuration for `batch_delete_documents`
|
839
1000
|
# @return [::Gapic::Config::Method]
|
840
1001
|
#
|
@@ -858,6 +1019,8 @@ module Google
|
|
858
1019
|
@import_documents = ::Gapic::Config::Method.new import_documents_config
|
859
1020
|
get_document_config = parent_rpcs.get_document if parent_rpcs.respond_to? :get_document
|
860
1021
|
@get_document = ::Gapic::Config::Method.new get_document_config
|
1022
|
+
list_documents_config = parent_rpcs.list_documents if parent_rpcs.respond_to? :list_documents
|
1023
|
+
@list_documents = ::Gapic::Config::Method.new list_documents_config
|
861
1024
|
batch_delete_documents_config = parent_rpcs.batch_delete_documents if parent_rpcs.respond_to? :batch_delete_documents
|
862
1025
|
@batch_delete_documents = ::Gapic::Config::Method.new batch_delete_documents_config
|
863
1026
|
get_dataset_schema_config = parent_rpcs.get_dataset_schema if parent_rpcs.respond_to? :get_dataset_schema
|