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

Commit

Permalink
feat(v1): Move CommonOperationMetadata into a separate file for poten…
Browse files Browse the repository at this point in the history
…tial reuse (#158)

PiperOrigin-RevId: 377562108

Source-Link: googleapis/googleapis@3e0f7eb

Source-Link: googleapis/googleapis-gen@70f4e20
  • Loading branch information
gcf-owl-bot[bot] committed Jun 8, 2021
1 parent a1a92b2 commit c309f8f
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 40 deletions.
6 changes: 2 additions & 4 deletions google/cloud/documentai/__init__.py
Expand Up @@ -37,9 +37,6 @@
from google.cloud.documentai_v1.types.document_processor_service import (
BatchProcessResponse,
)
from google.cloud.documentai_v1.types.document_processor_service import (
CommonOperationMetadata,
)
from google.cloud.documentai_v1.types.document_processor_service import (
HumanReviewStatus,
)
Expand All @@ -57,6 +54,7 @@
from google.cloud.documentai_v1.types.geometry import BoundingPoly
from google.cloud.documentai_v1.types.geometry import NormalizedVertex
from google.cloud.documentai_v1.types.geometry import Vertex
from google.cloud.documentai_v1.types.operation_metadata import CommonOperationMetadata

__all__ = (
"DocumentProcessorServiceClient",
Expand All @@ -71,7 +69,6 @@
"BatchProcessMetadata",
"BatchProcessRequest",
"BatchProcessResponse",
"CommonOperationMetadata",
"HumanReviewStatus",
"ProcessRequest",
"ProcessResponse",
Expand All @@ -81,4 +78,5 @@
"BoundingPoly",
"NormalizedVertex",
"Vertex",
"CommonOperationMetadata",
)
2 changes: 1 addition & 1 deletion google/cloud/documentai_v1/__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_v1/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",
)
33 changes: 2 additions & 31 deletions google/cloud/documentai_v1/types/document_processor_service.py
Expand Up @@ -17,6 +17,7 @@

from google.cloud.documentai_v1.types import document as gcd_document
from google.cloud.documentai_v1.types import document_io
from google.cloud.documentai_v1.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 @@ -242,37 +242,8 @@ class ReviewDocumentOperationMetadata(proto.Message):
"""

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_v1.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_v1/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_v1/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.v1", manifest={"CommonOperationMetadata",},
)


class CommonOperationMetadata(proto.Message):
r"""The common metadata for long running operations.
Attributes:
state (google.cloud.documentai_v1.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))

0 comments on commit c309f8f

Please sign in to comment.