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

Access Display Names of enum fields via enum object #1738

Merged
merged 12 commits into from
Oct 15, 2018

Conversation

beccasaurus
Copy link
Contributor

To get the display name of enum fields of protobuf objects, we had been copy/pasting the enum field names from the .proto into our code and using the int index of the enum field to get the display name

Updated various samples to get enum field display names the newer, improved way:

from google.cloud.mylibrary import enums

enum_object = enums.EnumName(response.enum_field)

print('The display name of enum_field is: {}'.format(enum_object.name))

Related: googleapis/google-cloud-python#6169

Language library needed to be updated to make use of this feature. Worked out-of-the-box for Video Intelligence and Text-to-Speech

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 5, 2018
@@ -22,6 +22,9 @@


BUCKET = os.environ['CLOUD_STORAGE_BUCKET']


# Videos used for these tests can be found in the gs://demomaker/ public bucket
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm going to send a PR to update these tests to explicitly use the demomaker bucket to save future contributor friction, so this comment will no longer be necessary. Please remove so we can avoid merge conflicts.

Rebecca Taylor added 2 commits October 9, 2018 15:02
…ogleCloudPlatform/python-docs-samples into use-IntEnum-to-get-enum-display-names
@beccasaurus beccasaurus merged commit 8d79fd1 into master Oct 15, 2018
@beccasaurus beccasaurus deleted the use-IntEnum-to-get-enum-display-names branch October 15, 2018 20:53
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request Apr 9, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request May 13, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request May 13, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request May 13, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
busunkim96 pushed a commit to busunkim96/python-language that referenced this pull request May 20, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
busunkim96 pushed a commit to busunkim96/python-videointelligence that referenced this pull request May 20, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request May 20, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
busunkim96 pushed a commit to googleapis/python-texttospeech that referenced this pull request May 20, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
hkdevandla pushed a commit to hkdevandla/python-language that referenced this pull request Sep 26, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
busunkim96 pushed a commit to googleapis/python-language that referenced this pull request Sep 29, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
danoscarmike pushed a commit to googleapis/python-videointelligence that referenced this pull request Sep 30, 2020
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
msampathkumar pushed a commit that referenced this pull request Nov 10, 2022
* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bff.
msampathkumar pushed a commit that referenced this pull request Nov 10, 2022
* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bff.
m-strzelczyk pushed a commit that referenced this pull request Nov 18, 2022
* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bff.
parthea pushed a commit to googleapis/google-cloud-python that referenced this pull request Jul 6, 2023
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
dizcology pushed a commit that referenced this pull request Sep 11, 2023
* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bff.
leahecole pushed a commit that referenced this pull request Sep 15, 2023
* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bff.
parthea pushed a commit to googleapis/google-cloud-python that referenced this pull request Sep 22, 2023
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
parthea pushed a commit to googleapis/google-cloud-python that referenced this pull request Sep 22, 2023
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
parthea pushed a commit to googleapis/google-cloud-python that referenced this pull request Sep 22, 2023
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
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.

3 participants