Open
Description
The message constructor is incompatible with message.to_dict
(when preserving_proto_field_name
is used) and the actual REST API payloads. Meanwhile, .from_json
is compatible with .to_json
.
Environment details
- Programming language: 3.7
- OS: Linux
- Package version: 1.22.1
Steps to reproduce
from google.cloud import batch_v1
This works:
batch_v1.Job.from_json('{"taskGroups": [{}]}')
This does not work:
batch_v1.Job({"taskGroups": [{}]})
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-145-58ddc394e1ed> in <module>
----> 1 batch_v1.Job({"taskGroups": [{}]})
/opt/conda/lib/python3.7/site-packages/proto/message.py in __init__(self, mapping, ignore_unknown_fields, **kwargs)
564
565 raise ValueError(
--> 566 "Unknown field for {}: {}".format(self.__class__.__name__, key)
567 )
568
ValueError: Unknown field for Job: taskGroups