Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MessageToDict in logging._gax #2600

Merged
merged 3 commits into from
Oct 25, 2016

Conversation

dhermes
Copy link
Contributor

@dhermes dhermes commented Oct 25, 2016

This allows removal of lots of custom conversion code. I noticed this when doing #2589.

This replaces lots of ad-hoc conversion code.
Also replacing _struct_pb_to_mapping with MessageToDict and
removing the unused _value_pb_to_value (wasn't showing up in
uncovered code / non-linted code since it was fully unit
tested).
@dhermes dhermes added the api: logging Issues related to the Cloud Logging API. label Oct 25, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 25, 2016
@dhermes
Copy link
Contributor Author

dhermes commented Oct 25, 2016

@tseaver FYI ParseDict handles the camel-case handling:

>>> from google.protobuf.json_format import ParseDict
>>> from google.logging.type.http_request_pb2 import HttpRequest
>>> ParseDict({'request_url': 'a'}, HttpRequest())
request_url: "a"

>>> ParseDict({'requestUrl': 'a'}, HttpRequest())
request_url: "a"

@daspecster
Copy link
Contributor

Here's a link to MessageToDict just for easy reference.

mapping['operation'], entry_pb.operation)

mapping['timestamp'] = _datetime_to_rfc3339(mapping['timestamp'])
ParseDict(mapping, entry_pb)

This comment was marked as spam.

This comment was marked as spam.

# Import the wrappers to register the type URL for BoolValue
# pylint: disable=unused-variable
from google.protobuf import wrappers_pb2
# pylint: enable=unused-variable

This comment was marked as spam.

@dhermes
Copy link
Contributor Author

dhermes commented Oct 25, 2016

@tseaver Any remaining issues?

@tseaver
Copy link
Contributor

tseaver commented Oct 25, 2016

LGTM

@dhermes dhermes merged commit 25f4475 into googleapis:master Oct 25, 2016
@dhermes dhermes deleted the gax-logging-use-messagetodict branch October 25, 2016 18:34
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
…getodict

Use MessageToDict in logging._gax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the Cloud Logging API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants