-
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(snippetgen): generate mock input for required fields #941
Conversation
Here is the summary of changes. You are about to add 2 region tags.
This comment is generated by snippet-bot.
|
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.
Okay @busunkim96 - I looked at some - didn't make it through all, but a lot of my comments will apply to multiple samples, I think. Hope it was at least a little helpful!
@@ -35,6 +35,7 @@ def sample_batch_get_assets_history(): | |||
|
|||
# Initialize request argument(s) | |||
request = asset_v1.BatchGetAssetsHistoryRequest( | |||
parent="*", |
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.
I'm not familiar with this syntax - is this asterisk something that's typical for this service?
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.
The * wouldn't actually work if passed to the service. The snippetgen logic pulls the first resource pattern out of the protos, and in some uncommon cases it is just a *
rather than some more specific pattern like projects/{project}
. The *
pattern creates problems for generating resource helper methods and tests too - see #701
...et/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_create_feed_sync.py
Show resolved
Hide resolved
...t/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_delete_feed_async.py
Show resolved
Hide resolved
...et/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_delete_feed_sync.py
Show resolved
Hide resolved
...mples/iamcredentials_generated_credentials_v1_iam_credentials_generate_access_token_async.py
Show resolved
Hide resolved
...edis/samples/generated_samples/redis_generated_redis_v1_cloud_redis_update_instance_async.py
Show resolved
Hide resolved
tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_method_bidi_streaming_async.py
Outdated
Show resolved
Hide resolved
...et/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_create_feed_sync.py
Show resolved
Hide resolved
...t/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_delete_feed_async.py
Show resolved
Hide resolved
@software-dov Thank you for the review! PTAL |
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.
Mostly nitpicking and one minor concern, looks great! Thanks for doing this, and I hope the existing samplegen code wasn't too unpleasant to work with.
Generate mock field inputs for all required fields.
resource_pb2.resource_reference
) is the pattern provided in the protos.TODOs:
When a resource's pattern is
*
this results in unhelpful stringsMap fields are not yet handled.
Other changes:
Fields are set like
foo.bar
rather than through dict accessfoo["bar"]
. This is because the former allows you to set fields nested more than one field deepfoo.bar.baz
.Before:
After: