This repository was archived by the owner on Feb 13, 2026. It is now read-only.
fix: fix client.quotas() method - #24
Merged
Merged
Conversation
client.quotas() now properly handles quota resources with ``whitelistedKeySpecs``.
client.quotas() now properly handles quota resources with ``whitelistedKeySpecs``.
busunkim96
commented
Oct 5, 2020
tseaver
approved these changes
Oct 6, 2020
crwilcox
reviewed
Oct 6, 2020
| return { | ||
| key: int(value) for key, value in resp["quota"].items() if key != "kind" | ||
| } | ||
| quotas = resp["quota"] |
Contributor
There was a problem hiding this comment.
Is there an advantage to getting the quotas and popping kind over a list comprehension? It appears the issue was the type conversion to int?
Contributor
Author
There was a problem hiding this comment.
This method started failing because there's a new key whitelistedKeySpecs in quota. str -> int conversion failed since it's a list
https://cloud.google.com/dns/docs/reference/v1/projects#resource
"quota": {
"kind": "dns#quota",
"managedZones": integer,
"rrsetsPerManagedZone": integer,
"rrsetAdditionsPerChange": integer,
"rrsetDeletionsPerChange": integer,
"totalRrdataSizePerChange": integer,
"resourceRecordsPerRrset": integer,
"dnsKeysPerManagedZone": integer,
"whitelistedKeySpecs": [
{
"kind": "dns#dnsKeySpec",
"keyType": string,
"algorithm": string,
"keyLength": unsigned integer
}
],
"networksPerManagedZone": integer,
"managedZonesPerNetwork": integer,
"policies": integer,
"networksPerPolicy": integer,
"targetNameServersPerPolicy": integer,
"targetNameServersPerManagedZone": integer
}
Each entrywhitelistedKeySpecs also has a 'kind' that needs to be stripped. I found it easier to pop than to edit the existing list comprehension.
| :returns: keys for the mapping correspond to those of the ``quota`` | ||
| sub-mapping of the project resource. | ||
| sub-mapping of the project resource. ``kind`` is stripped | ||
| from the results. |
Contributor
There was a problem hiding this comment.
Thanks for adding this to the comment. It seems we always stripped this away silently :)
crwilcox
approved these changes
Oct 9, 2020
gcf-merge-on-green Bot
pushed a commit
that referenced
this pull request
Oct 12, 2020
🤖 I have created a release \*beep\* \*boop\* --- ### [0.32.1](https://www.github.com/googleapis/python-dns/compare/v0.32.0...v0.32.1) (2020-10-12) ### Bug Fixes * fix client.quotas() method ([#24](https://www.github.com/googleapis/python-dns/issues/24)) ([9d97955](https://www.github.com/googleapis/python-dns/commit/9d979552512c633366e5ff34d155b5550ec7f6f3)) ### Documentation * remove samples in library docs ([#17](https://www.github.com/googleapis/python-dns/issues/17)) ([51d4d10](https://www.github.com/googleapis/python-dns/commit/51d4d10884d3e13bb9051114537a1a6eddab0086)) * update README.rst ([#25](https://www.github.com/googleapis/python-dns/issues/25)) ([3e511cb](https://www.github.com/googleapis/python-dns/commit/3e511cb0b4c6496d310365aeb326cf720a8d5609)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
client.quotas() now properly handles quota resource with
whitelistedKeySpecs.This also removes the str -> int conversion for values in
quotas. The API returns integers so there is no need to do the conversion. See https://cloud.google.com/dns/docs/reference/v1/projects#resourceFixes #21 🦕