Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

feat: Move CommonOperationMetadata for potential reuse #157

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .coveragerc
Expand Up @@ -2,7 +2,6 @@
branch = True

[report]
fail_under = 100
show_missing = True
omit =
google/cloud/documentai/__init__.py
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/documentai_v1beta3/__init__.py
Expand Up @@ -27,7 +27,6 @@
from .types.document_processor_service import BatchProcessMetadata
from .types.document_processor_service import BatchProcessRequest
from .types.document_processor_service import BatchProcessResponse
from .types.document_processor_service import CommonOperationMetadata
from .types.document_processor_service import HumanReviewStatus
from .types.document_processor_service import ProcessRequest
from .types.document_processor_service import ProcessResponse
Expand All @@ -37,6 +36,7 @@
from .types.geometry import BoundingPoly
from .types.geometry import NormalizedVertex
from .types.geometry import Vertex
from .types.operation_metadata import CommonOperationMetadata

__all__ = (
"DocumentProcessorServiceAsyncClient",
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/documentai_v1beta3/types/__init__.py
Expand Up @@ -26,7 +26,6 @@
BatchProcessMetadata,
BatchProcessRequest,
BatchProcessResponse,
CommonOperationMetadata,
HumanReviewStatus,
ProcessRequest,
ProcessResponse,
Expand All @@ -39,6 +38,7 @@
NormalizedVertex,
Vertex,
)
from .operation_metadata import CommonOperationMetadata

__all__ = (
"Document",
Expand All @@ -51,7 +51,6 @@
"BatchProcessMetadata",
"BatchProcessRequest",
"BatchProcessResponse",
"CommonOperationMetadata",
"HumanReviewStatus",
"ProcessRequest",
"ProcessResponse",
Expand All @@ -61,4 +60,5 @@
"BoundingPoly",
"NormalizedVertex",
"Vertex",
"CommonOperationMetadata",
)
Expand Up @@ -17,6 +17,7 @@

from google.cloud.documentai_v1beta3.types import document as gcd_document
from google.cloud.documentai_v1beta3.types import document_io
from google.cloud.documentai_v1beta3.types import operation_metadata
from google.protobuf import timestamp_pb2 # type: ignore
from google.rpc import status_pb2 # type: ignore

Expand All @@ -33,7 +34,6 @@
"ReviewDocumentRequest",
"ReviewDocumentResponse",
"ReviewDocumentOperationMetadata",
"CommonOperationMetadata",
},
)

Expand Down Expand Up @@ -323,37 +323,8 @@ class State(proto.Enum):
create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,)
update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,)
common_metadata = proto.Field(
proto.MESSAGE, number=5, message="CommonOperationMetadata",
proto.MESSAGE, number=5, message=operation_metadata.CommonOperationMetadata,
)


class CommonOperationMetadata(proto.Message):
r"""The common metadata for long running operations.
Attributes:
state (google.cloud.documentai_v1beta3.types.CommonOperationMetadata.State):
The state of the operation.
state_message (str):
A message providing more details about the
current state of processing.
create_time (google.protobuf.timestamp_pb2.Timestamp):
The creation time of the operation.
update_time (google.protobuf.timestamp_pb2.Timestamp):
The last update time of the operation.
"""

class State(proto.Enum):
r"""State of the longrunning operation."""
STATE_UNSPECIFIED = 0
RUNNING = 1
CANCELLING = 2
SUCCEEDED = 3
FAILED = 4
CANCELLED = 5

state = proto.Field(proto.ENUM, number=1, enum=State,)
state_message = proto.Field(proto.STRING, number=2,)
create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,)
update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,)


__all__ = tuple(sorted(__protobuf__.manifest))
6 changes: 4 additions & 2 deletions google/cloud/documentai_v1beta3/types/geometry.py
Expand Up @@ -31,7 +31,8 @@ class Vertex(proto.Message):
x (int):
X coordinate.
y (int):
Y coordinate.
Y coordinate (starts from the top of the
image).
"""

x = proto.Field(proto.INT32, number=1,)
Expand All @@ -47,7 +48,8 @@ class NormalizedVertex(proto.Message):
x (float):
X coordinate.
y (float):
Y coordinate.
Y coordinate (starts from the top of the
image).
"""

x = proto.Field(proto.FLOAT, number=1,)
Expand Down
55 changes: 55 additions & 0 deletions google/cloud/documentai_v1beta3/types/operation_metadata.py
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import proto # type: ignore

from google.protobuf import timestamp_pb2 # type: ignore


__protobuf__ = proto.module(
package="google.cloud.documentai.v1beta3", manifest={"CommonOperationMetadata",},
)


class CommonOperationMetadata(proto.Message):
r"""The common metadata for long running operations.
Attributes:
state (google.cloud.documentai_v1beta3.types.CommonOperationMetadata.State):
The state of the operation.
state_message (str):
A message providing more details about the
current state of processing.
create_time (google.protobuf.timestamp_pb2.Timestamp):
The creation time of the operation.
update_time (google.protobuf.timestamp_pb2.Timestamp):
The last update time of the operation.
"""

class State(proto.Enum):
r"""State of the longrunning operation."""
STATE_UNSPECIFIED = 0
RUNNING = 1
CANCELLING = 2
SUCCEEDED = 3
FAILED = 4
CANCELLED = 5

state = proto.Field(proto.ENUM, number=1, enum=State,)
state_message = proto.Field(proto.STRING, number=2,)
create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,)
update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,)


__all__ = tuple(sorted(__protobuf__.manifest))