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

feat(snippetgen): turn resource path strings into f-strings #1012

Merged
merged 6 commits into from
Nov 5, 2021

Conversation

busunkim96
Copy link
Contributor

@busunkim96 busunkim96 commented Oct 7, 2021

Fixes #965.

Uses the already-existing resource path logic for autogen snippets.

Previous:

    # Initialize request argument(s)
    request = asset_v1.DeleteFeedRequest(
        name="projects/{project}/feeds/{feed}",
    )

Now:

    # Initialize request argument(s)
    project = "my-project-id"
    feed = "feed_value"
    name = f"projects/{project}/feeds/{feed}"

    request = asset_v1.DeleteFeedRequest(
        name=name,
    )

Note: The logic may result in multiple variables with the same name (it doesn't happen for any of the golden APIs, but might for an API with more required fields).

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 7, 2021
if not resource_message_descriptor:
resource_message = None
for service in api_schema.services.values():
resource_message = service.resource_messages_dict.get(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched to looking through service.resource_messages_dict as the common resources (projects/{project}, folders/{folder}, ...) aren't in api_schema.messages.

@busunkim96 busunkim96 marked this pull request as ready for review October 7, 2021 22:50
@busunkim96 busunkim96 requested a review from a team as a code owner October 7, 2021 22:50
@busunkim96 busunkim96 requested a review from a team as a code owner November 4, 2021 15:03
@busunkim96 busunkim96 changed the title chore(snippetgen): turn resource path strings into f-strings feat(snippetgen): turn resource path strings into f-strings Nov 5, 2021
@busunkim96 busunkim96 added the automerge Merge the pull request once unit tests and other checks pass. label Nov 5, 2021
@gcf-merge-on-green gcf-merge-on-green bot merged commit a110e1d into master Nov 5, 2021
@gcf-merge-on-green gcf-merge-on-green bot deleted the snippetgen-resource-paths branch November 5, 2021 21:36
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

snippetgen: turn resource path strings into f-strings
2 participants