-
Notifications
You must be signed in to change notification settings - Fork 14
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
fix: fix client.quotas() method #24
Conversation
client.quotas() now properly handles quota resources with ``whitelistedKeySpecs``.
client.quotas() now properly handles quota resources with ``whitelistedKeySpecs``.
return { | ||
key: int(value) for key, value in resp["quota"].items() if key != "kind" | ||
} | ||
quotas = resp["quota"] |
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.
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?
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.
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.
@@ -91,14 +91,23 @@ def quotas(self): | |||
|
|||
:rtype: mapping | |||
: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. |
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.
Thanks for adding this to the comment. It seems we always stripped this away silently :)
🤖 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).
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 🦕