This repository was archived by the owner on Feb 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
fix: fix client.quotas() method #24
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b960d5f
fix: fix client.quotas() method
busunkim96 eddbacc
fix: fix client.quotas() method
busunkim96 2322c19
chore: rename system test
busunkim96 b6215fc
Merge branch 'fix-21' of github.com:googleapis/python-dns into fix-21
busunkim96 e7a67c6
chore: fix lint
busunkim96 ed99301
chore: remove duped file
busunkim96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
| """ | ||
| path = "/projects/%s" % (self.project,) | ||
| resp = self._connection.api_request(method="GET", path=path) | ||
|
|
||
| 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. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method started failing because there's a new key https://cloud.google.com/dns/docs/reference/v1/projects#resource Each entry |
||
| # Remove the key "kind" | ||
| # https://cloud.google.com/dns/docs/reference/v1/projects#resource | ||
| quotas.pop("kind", None) | ||
| if "whitelistedKeySpecs" in quotas: | ||
| # whitelistedKeySpecs is a list of dicts that represent keyspecs | ||
| # Remove "kind" here as well | ||
| for key_spec in quotas["whitelistedKeySpecs"]: | ||
| key_spec.pop("kind", None) | ||
|
|
||
| return quotas | ||
|
|
||
| def list_zones(self, max_results=None, page_token=None): | ||
| """List zones for the project associated with this client. | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # | ||
| # Copyright 2020 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
|
||
| from google.cloud import dns | ||
|
|
||
|
|
||
| def test_quota(): | ||
| client = dns.Client() | ||
|
|
||
| quotas = client.quotas() | ||
|
|
||
| # check that kind is properly stripped from the resource | ||
| assert "kind" not in quotas | ||
| for keyspec in quotas["whitelistedKeySpecs"]: | ||
| assert "kind" not in keyspec |
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
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.
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 :)