- Notifications
You must be signed in to change notification settings - Fork90
feat: implementOperationsRestAsyncTransport
to support long running operations#700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
ohmayr merged 16 commits intoasync-rest-lro-support-in-corefromoperations-rest-async-transportOct 3, 2024
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
16 commits Select commitHold shift + click to select a range
09ce3b0
feat: Add OperationsRestAsyncTransport to support long running operat…
partheadaca264
update TODO comment
parthea9f980fd
update TODO comment
partheaf52378b
address feedback
ohmayrf880c72
address feedback
ohmayr34b795f
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot]62f0c39
fix mypy and lint issues
ohmayr3bfad42
minor fix
ohmayr3e9a1a6
add no cover
ohmayr7c08eeb
fix no cover tag
ohmayrcdfa64f
link coverage issue
ohmayr2891173
silence coverage issue
ohmayracdadee
fix statement name error
ohmayr62dfff9
address PR feedback
ohmayrf93e6bd
address PR feedback
ohmayr637a361
address PR comments
ohmayrFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
3 changes: 2 additions & 1 deletiongoogle/api_core/client_info.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionsgoogle/api_core/gapic_v1/client_info.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletiongoogle/api_core/operations_v1/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
24 changes: 17 additions & 7 deletionsgoogle/api_core/operations_v1/transports/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
54 changes: 52 additions & 2 deletionsgoogle/api_core/operations_v1/transports/base.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -14,6 +14,7 @@ | ||
# limitations under the License. | ||
# | ||
import abc | ||
import re | ||
from typing import Awaitable, Callable, Optional, Sequence, Union | ||
import google.api_core # type: ignore | ||
@@ -25,10 +26,13 @@ | ||
from google.auth import credentials as ga_credentials # type: ignore | ||
from google.longrunning import operations_pb2 | ||
from google.oauth2 import service_account # type: ignore | ||
import google.protobuf | ||
from google.protobuf import empty_pb2, json_format # type: ignore | ||
from grpc import Compression | ||
PROTOBUF_VERSION = google.protobuf.__version__ | ||
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( | ||
gapic_version=version.__version__, | ||
) | ||
@@ -45,12 +49,14 @@ def __init__( | ||
self, | ||
*, | ||
host: str = DEFAULT_HOST, | ||
# TODO(https://github.com/googleapis/python-api-core/issues/709): update type hint for credentials to include `google.auth.aio.Credentials`. | ||
credentials: Optional[ga_credentials.Credentials] = None, | ||
credentials_file: Optional[str] = None, | ||
scopes: Optional[Sequence[str]] = None, | ||
quota_project_id: Optional[str] = None, | ||
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, | ||
always_use_jwt_access: Optional[bool] = False, | ||
url_scheme="https", | ||
**kwargs, | ||
) -> None: | ||
"""Instantiate the transport. | ||
@@ -76,10 +82,23 @@ def __init__( | ||
your own client library. | ||
always_use_jwt_access (Optional[bool]): Whether self signed JWT should | ||
be used for service account credentials. | ||
url_scheme: the protocol scheme for the API endpoint. Normally | ||
"https", but for testing or local servers, | ||
"http" can be specified. | ||
""" | ||
maybe_url_match = re.match("^(?P<scheme>http(?:s)?://)?(?P<host>.*)$", host) | ||
if maybe_url_match is None: | ||
raise ValueError( | ||
f"Unexpected hostname structure: {host}" | ||
) # pragma: NO COVER | ||
url_match_items = maybe_url_match.groupdict() | ||
host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host | ||
# Save the hostname. Default to port 443 (HTTPS) if none is specified. | ||
if ":" not in host: | ||
host += ":443" # pragma: NO COVER | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. FYI, looking at this led me to file#714 (pre-existing issue) | ||
self._host = host | ||
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} | ||
@@ -189,6 +208,37 @@ def close(self): | ||
""" | ||
raise NotImplementedError() | ||
def _convert_protobuf_message_to_dict( | ||
self, message: google.protobuf.message.Message | ||
): | ||
r"""Converts protobuf message to a dictionary. | ||
When the dictionary is encoded to JSON, it conforms to proto3 JSON spec. | ||
Args: | ||
message(google.protobuf.message.Message): The protocol buffers message | ||
instance to serialize. | ||
Returns: | ||
A dict representation of the protocol buffer message. | ||
""" | ||
# TODO(https://github.com/googleapis/python-api-core/issues/643): For backwards compatibility | ||
# with protobuf 3.x 4.x, Remove once support for protobuf 3.x and 4.x is dropped. | ||
if PROTOBUF_VERSION[0:2] in ["3.", "4."]: | ||
result = json_format.MessageToDict( | ||
message, | ||
preserving_proto_field_name=True, | ||
including_default_value_fields=True, # type: ignore # backward compatibility | ||
) | ||
else: | ||
result = json_format.MessageToDict( | ||
message, | ||
preserving_proto_field_name=True, | ||
always_print_fields_with_no_presence=True, | ||
) | ||
return result | ||
@property | ||
def list_operations( | ||
self, | ||
50 changes: 6 additions & 44 deletionsgoogle/api_core/operations_v1/transports/rest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.