-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat: Automatically populate uuid4 fields #1985
Conversation
7f93c76
to
03cc1e1
Compare
247c62b
to
66c4309
Compare
497f954
to
c2feb1a
Compare
c2feb1a
to
68a79a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Only minor comments in the files, but one overall comment before I approve: could we have some sort of golden file that exercises the uuid
tests you added? (i.e. from a proto with an autopopulated field)
gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/client.py.j2
Outdated
Show resolved
Hide resolved
gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/client.py.j2
Outdated
Show resolved
Hide resolved
gapic/ads-templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2
Outdated
Show resolved
Hide resolved
gapic/ads-templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2
Outdated
Show resolved
Hide resolved
gapic/templates/%namespace/%name_%version/%sub/services/%service/_client_macros.j2
Outdated
Show resolved
Hide resolved
gapic/templates/%namespace/%name_%version/%sub/services/%service/_client_macros.j2
Show resolved
Hide resolved
gapic/templates/%namespace/%name_%version/%sub/services/%service/_client_macros.j2
Show resolved
Hide resolved
gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2
Outdated
Show resolved
Hide resolved
gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2
Outdated
Show resolved
Hide resolved
gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2
Outdated
Show resolved
Hide resolved
Co-authored-by: Victor Chudnovsky <vchudnov@google.com>
Co-authored-by: Victor Chudnovsky <vchudnov@google.com>
This is already being done since we're running tests against gapic-generator-python/noxfile.py Line 197 in 24a23a1
On an unrelated note, I've opened PR #1991 to add showcase to the |
@vchudnov-g Please could you take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
{% if method_settings is not none %} | ||
{% for auto_populated_field in method_settings.auto_populated_fields %} | ||
# Ensure that the uuid4 field is set according to AIP 4235 | ||
assert re.match(r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}", args[0].{{ auto_populated_field }}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this check in multiple places, so I suggest having this in a macro. Even if we have to have duplicate macros for the ads vs non-ads templates (we can define the Ads macro in this file, IIUC)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 70f0c64
{% if method_settings is not none %} | ||
{% for auto_populated_field in method_settings.auto_populated_fields %} | ||
# Ensure that the uuid4 field is set according to AIP 4235 | ||
assert re.match(r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}", args[0].{{ auto_populated_field }}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto previous comment: We have this check in multiple places, so I suggest having this in a macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 70f0c64
Adds support for automatically populating uuid fields as per https://google.aip.dev/client-libraries/4235
Towards b/322910372