Skip to content

Commit 81d36fc

Browse files
fix: [google-cloud-documentai] Resolve AttributeError 'Credentials' object has no attribute 'universe_domain' (#12259)
- [ ] Regenerate this pull request now. fix: Add google-auth as a direct dependency fix: Add staticmethod decorator to methods added in v1.14.0 chore: Update gapic-generator-python to v1.14.1 PiperOrigin-RevId: 603728206 Source-Link: googleapis/googleapis@9063da8 Source-Link: googleapis/googleapis-gen@891c67d Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRvY3VtZW50YWkvLk93bEJvdC55YW1sIiwiaCI6Ijg5MWM2N2QwYTg1NWIwODA4NWViMzAxZGFiYjE0MDY0ZWY0YjJjNmQifQ== BEGIN_NESTED_COMMIT feat: [google-cloud-documentai] expose model_type in v1 processor, so that user can see the model_type after get or list processor version PiperOrigin-RevId: 603727585 Source-Link: googleapis/googleapis@7a9a855 Source-Link: googleapis/googleapis-gen@9643051 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRvY3VtZW50YWkvLk93bEJvdC55YW1sIiwiaCI6Ijk2NDMwNTExNTA3NjJjM2UxNWQxY2Q0MjBkZGZiOTc4YTFiN2MyNGMifQ== END_NESTED_COMMIT BEGIN_NESTED_COMMIT feat: [google-cloud-documentai] add model_type in v1beta3 processor proto PiperOrigin-RevId: 603726122 Source-Link: googleapis/googleapis@c7fd8bd Source-Link: googleapis/googleapis-gen@23bc05e Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRvY3VtZW50YWkvLk93bEJvdC55YW1sIiwiaCI6IjIzYmMwNWU2OTlhZDU3MDEwMjc1ODkxMzdiZTQ0ZDRhNDMwOTE4MjkifQ== END_NESTED_COMMIT --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: omair <omairn@google.com>
1 parent e5788c2 commit 81d36fc

File tree

20 files changed

+1622
-1574
lines changed

20 files changed

+1622
-1574
lines changed

packages/google-cloud-documentai/google/cloud/documentai/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.22.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-documentai/google/cloud/documentai_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.22.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-documentai/google/cloud/documentai_v1/services/document_processor_service/client.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ def _read_environment_variables():
497497
)
498498
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
499499

500+
@staticmethod
500501
def _get_client_cert_source(provided_cert_source, use_cert_flag):
501502
"""Return the client cert source to be used by the client.
502503
@@ -515,6 +516,7 @@ def _get_client_cert_source(provided_cert_source, use_cert_flag):
515516
client_cert_source = mtls.default_client_cert_source()
516517
return client_cert_source
517518

519+
@staticmethod
518520
def _get_api_endpoint(
519521
api_override, client_cert_source, universe_domain, use_mtls_endpoint
520522
):
@@ -591,17 +593,18 @@ def _compare_universes(
591593
Raises:
592594
ValueError: when client_universe does not match the universe in credentials.
593595
"""
594-
if credentials:
595-
credentials_universe = credentials.universe_domain
596-
if client_universe != credentials_universe:
597-
default_universe = DocumentProcessorServiceClient._DEFAULT_UNIVERSE
598-
raise ValueError(
599-
"The configured universe domain "
600-
f"({client_universe}) does not match the universe domain "
601-
f"found in the credentials ({credentials_universe}). "
602-
"If you haven't configured the universe domain explicitly, "
603-
f"`{default_universe}` is the default."
604-
)
596+
597+
default_universe = DocumentProcessorServiceClient._DEFAULT_UNIVERSE
598+
credentials_universe = getattr(credentials, "universe_domain", default_universe)
599+
600+
if client_universe != credentials_universe:
601+
raise ValueError(
602+
"The configured universe domain "
603+
f"({client_universe}) does not match the universe domain "
604+
f"found in the credentials ({credentials_universe}). "
605+
"If you haven't configured the universe domain explicitly, "
606+
f"`{default_universe}` is the default."
607+
)
605608
return True
606609

607610
def _validate_universe_domain(self):

packages/google-cloud-documentai/google/cloud/documentai_v1/types/processor.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class ProcessorVersion(proto.Message):
6767
deprecation_info (google.cloud.documentai_v1.types.ProcessorVersion.DeprecationInfo):
6868
If set, information about the eventual
6969
deprecation of this version.
70+
model_type (google.cloud.documentai_v1.types.ProcessorVersion.ModelType):
71+
Output only. The model type of this processor
72+
version.
7073
"""
7174

7275
class State(proto.Enum):
@@ -106,6 +109,23 @@ class State(proto.Enum):
106109
FAILED = 7
107110
IMPORTING = 8
108111

112+
class ModelType(proto.Enum):
113+
r"""The possible model types of the processor version.
114+
115+
Values:
116+
MODEL_TYPE_UNSPECIFIED (0):
117+
The processor version has unspecified model
118+
type.
119+
MODEL_TYPE_GENERATIVE (1):
120+
The processor version has generative model
121+
type.
122+
MODEL_TYPE_CUSTOM (2):
123+
The processor version has custom model type.
124+
"""
125+
MODEL_TYPE_UNSPECIFIED = 0
126+
MODEL_TYPE_GENERATIVE = 1
127+
MODEL_TYPE_CUSTOM = 2
128+
109129
class DeprecationInfo(proto.Message):
110130
r"""Information about the upcoming deprecation of this processor
111131
version.
@@ -174,6 +194,11 @@ class DeprecationInfo(proto.Message):
174194
number=13,
175195
message=DeprecationInfo,
176196
)
197+
model_type: ModelType = proto.Field(
198+
proto.ENUM,
199+
number=15,
200+
enum=ModelType,
201+
)
177202

178203

179204
class ProcessorVersionAlias(proto.Message):

packages/google-cloud-documentai/google/cloud/documentai_v1beta2/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.22.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-documentai/google/cloud/documentai_v1beta2/services/document_understanding_service/client.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ def _read_environment_variables():
370370
)
371371
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
372372

373+
@staticmethod
373374
def _get_client_cert_source(provided_cert_source, use_cert_flag):
374375
"""Return the client cert source to be used by the client.
375376
@@ -388,6 +389,7 @@ def _get_client_cert_source(provided_cert_source, use_cert_flag):
388389
client_cert_source = mtls.default_client_cert_source()
389390
return client_cert_source
390391

392+
@staticmethod
391393
def _get_api_endpoint(
392394
api_override, client_cert_source, universe_domain, use_mtls_endpoint
393395
):
@@ -464,17 +466,18 @@ def _compare_universes(
464466
Raises:
465467
ValueError: when client_universe does not match the universe in credentials.
466468
"""
467-
if credentials:
468-
credentials_universe = credentials.universe_domain
469-
if client_universe != credentials_universe:
470-
default_universe = DocumentUnderstandingServiceClient._DEFAULT_UNIVERSE
471-
raise ValueError(
472-
"The configured universe domain "
473-
f"({client_universe}) does not match the universe domain "
474-
f"found in the credentials ({credentials_universe}). "
475-
"If you haven't configured the universe domain explicitly, "
476-
f"`{default_universe}` is the default."
477-
)
469+
470+
default_universe = DocumentUnderstandingServiceClient._DEFAULT_UNIVERSE
471+
credentials_universe = getattr(credentials, "universe_domain", default_universe)
472+
473+
if client_universe != credentials_universe:
474+
raise ValueError(
475+
"The configured universe domain "
476+
f"({client_universe}) does not match the universe domain "
477+
f"found in the credentials ({credentials_universe}). "
478+
"If you haven't configured the universe domain explicitly, "
479+
f"`{default_universe}` is the default."
480+
)
478481
return True
479482

480483
def _validate_universe_domain(self):

packages/google-cloud-documentai/google/cloud/documentai_v1beta3/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.22.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-documentai/google/cloud/documentai_v1beta3/services/document_processor_service/client.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ def _read_environment_variables():
497497
)
498498
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
499499

500+
@staticmethod
500501
def _get_client_cert_source(provided_cert_source, use_cert_flag):
501502
"""Return the client cert source to be used by the client.
502503
@@ -515,6 +516,7 @@ def _get_client_cert_source(provided_cert_source, use_cert_flag):
515516
client_cert_source = mtls.default_client_cert_source()
516517
return client_cert_source
517518

519+
@staticmethod
518520
def _get_api_endpoint(
519521
api_override, client_cert_source, universe_domain, use_mtls_endpoint
520522
):
@@ -591,17 +593,18 @@ def _compare_universes(
591593
Raises:
592594
ValueError: when client_universe does not match the universe in credentials.
593595
"""
594-
if credentials:
595-
credentials_universe = credentials.universe_domain
596-
if client_universe != credentials_universe:
597-
default_universe = DocumentProcessorServiceClient._DEFAULT_UNIVERSE
598-
raise ValueError(
599-
"The configured universe domain "
600-
f"({client_universe}) does not match the universe domain "
601-
f"found in the credentials ({credentials_universe}). "
602-
"If you haven't configured the universe domain explicitly, "
603-
f"`{default_universe}` is the default."
604-
)
596+
597+
default_universe = DocumentProcessorServiceClient._DEFAULT_UNIVERSE
598+
credentials_universe = getattr(credentials, "universe_domain", default_universe)
599+
600+
if client_universe != credentials_universe:
601+
raise ValueError(
602+
"The configured universe domain "
603+
f"({client_universe}) does not match the universe domain "
604+
f"found in the credentials ({credentials_universe}). "
605+
"If you haven't configured the universe domain explicitly, "
606+
f"`{default_universe}` is the default."
607+
)
605608
return True
606609

607610
def _validate_universe_domain(self):

packages/google-cloud-documentai/google/cloud/documentai_v1beta3/services/document_service/client.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ def _read_environment_variables():
440440
)
441441
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
442442

443+
@staticmethod
443444
def _get_client_cert_source(provided_cert_source, use_cert_flag):
444445
"""Return the client cert source to be used by the client.
445446
@@ -458,6 +459,7 @@ def _get_client_cert_source(provided_cert_source, use_cert_flag):
458459
client_cert_source = mtls.default_client_cert_source()
459460
return client_cert_source
460461

462+
@staticmethod
461463
def _get_api_endpoint(
462464
api_override, client_cert_source, universe_domain, use_mtls_endpoint
463465
):
@@ -532,17 +534,18 @@ def _compare_universes(
532534
Raises:
533535
ValueError: when client_universe does not match the universe in credentials.
534536
"""
535-
if credentials:
536-
credentials_universe = credentials.universe_domain
537-
if client_universe != credentials_universe:
538-
default_universe = DocumentServiceClient._DEFAULT_UNIVERSE
539-
raise ValueError(
540-
"The configured universe domain "
541-
f"({client_universe}) does not match the universe domain "
542-
f"found in the credentials ({credentials_universe}). "
543-
"If you haven't configured the universe domain explicitly, "
544-
f"`{default_universe}` is the default."
545-
)
537+
538+
default_universe = DocumentServiceClient._DEFAULT_UNIVERSE
539+
credentials_universe = getattr(credentials, "universe_domain", default_universe)
540+
541+
if client_universe != credentials_universe:
542+
raise ValueError(
543+
"The configured universe domain "
544+
f"({client_universe}) does not match the universe domain "
545+
f"found in the credentials ({credentials_universe}). "
546+
"If you haven't configured the universe domain explicitly, "
547+
f"`{default_universe}` is the default."
548+
)
546549
return True
547550

548551
def _validate_universe_domain(self):

packages/google-cloud-documentai/google/cloud/documentai_v1beta3/types/document_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class ListDocumentsRequest(proto.Message):
397397
398398
Currently support query strings are:
399399
400-
- ``SplitType=DATASET_SPLIT_TEST|DATASET_SPLIT_TRAIN|DATASET_SPLIT_UNASSIGNED``
400+
- ``SplitType=DATASET_SPLIT_TEST|DATASET_SPLIT_TRAIN|DATASET_SPLIT_UNASSIGNED``
401401
- ``LabelingState=DOCUMENT_LABELED|DOCUMENT_UNLABELED|DOCUMENT_AUTO_LABELED``
402402
- ``DisplayName=\"file_name.pdf\"``
403403
- ``EntityType=abc/def``

0 commit comments

Comments
 (0)