blockstorage: add isPublic query option for volume types#3451
blockstorage: add isPublic query option for volume types#3451kayrus merged 2 commits intogophercloud:mainfrom
Conversation
There was a problem hiding this comment.
Thank you for submitting your first PR! Be sure that we will be looking at it but keep in mind
this sometimes takes a while.
Please let the maintainers know if your PR has not got enough attention after a few days.
If any doubt, please consult our PR tutorial.
| type ListOpts struct { | ||
| // Specifies whether to request public or private types. | ||
| // Set to "none" to retrieve both types. Defaults to public only. | ||
| IsPublic string `q:"is_public"` |
There was a problem hiding this comment.
this must be bool. if it defaults to true by default, then it must be a bool pointer. would be nice to have a unit test, see
There was a problem hiding this comment.
Thank you for the hint. Making this parameter a bool pointer is a good idea. However, when its value is nil, the BuildQueryString function ignores this parameter. This query is used for every OpenStack API implementation.
Without modifying this function and potentially causing side effects, translating this to the Python type None would require manually modifying the query string itself, which is an ugly hack. Therefore, I opted to create a string enum that can be used at the caller side to limit the query results. I'm open to discussing the naming of the variables (I don't think they are quite optimal yet; for example, if IsPublic has the value VisibilityPublic).
Another change is that now, by default, both public and private volume types are queried (when no ListOpts struct is provided). This aligns with the OpenStack client, which uses the parameter ?is_public=None by default. This can be verified by enabling the debug functionality of the client for the command: volume type list.
Adjust IsPublic type to utilize a string enum Add test cases
|
Failed to backport PR to |
Fixes #3450
Links to the line numbers/files in the OpenStack source code that support the
code in this PR:
https://docs.openstack.org/api-ref/block-storage/v3/index.html#volume-types-types