Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e22e2bd

Browse filesBrowse files
feat: [Many APIs] Add REST Interceptors which support reading metadata (#13496)
BEGIN_COMMIT_OVERRIDE feat: Add REST Interceptors which support reading metadata feat: Add support for reading selective GAPIC generation methods from service YAML chore: Update gapic-generator-python to v1.22.0 END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. feat: Add support for reading selective GAPIC generation methods from service YAML chore: Update gapic-generator-python to v1.22.0 PiperOrigin-RevId: 724026024 Source-Link: googleapis/googleapis@ad99638 Source-Link: googleapis/googleapis-gen@e291c4d Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpZ3F1ZXJ5LWxvZ2dpbmcvLk93bEJvdC55YW1sIiwiaCI6ImUyOTFjNGRkMWQ2NzBlZGExOTk5OGRlNzZmOTY3ZTE2MDNhNDg5OTMifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpZ3F1ZXJ5LW1pZ3JhdGlvbi8uT3dsQm90LnlhbWwiLCJoIjoiZTI5MWM0ZGQxZDY3MGVkYTE5OTk4ZGU3NmY5NjdlMTYwM2E0ODk5MyJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpZ3F1ZXJ5LXJlc2VydmF0aW9uLy5Pd2xCb3QueWFtbCIsImgiOiJlMjkxYzRkZDFkNjcwZWRhMTk5OThkZTc2Zjk2N2UxNjAzYTQ4OTkzIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpbGxpbmctYnVkZ2V0cy8uT3dsQm90LnlhbWwiLCJoIjoiZTI5MWM0ZGQxZDY3MGVkYTE5OTk4ZGU3NmY5NjdlMTYwM2E0ODk5MyJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29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joicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRhdGEtZnVzaW9uLy5Pd2xCb3QueWFtbCIsImgiOiJlMjkxYzRkZDFkNjcwZWRhMTk5OThkZTc2Zjk2N2UxNjAzYTQ4OTkzIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRhdGEtcW5hLy5Pd2xCb3QueWFtbCIsImgiOiJlMjkxYzRkZDFkNjcwZWRhMTk5OThkZTc2Zjk2N2UxNjAzYTQ4OTkzIn0= --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <omairnaveed@ymail.com>
1 parent eb554e8 commit e22e2bd
Copy full SHA for e22e2bd

File tree

Expand file treeCollapse file tree

184 files changed

+14744
-971
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

184 files changed

+14744
-971
lines changed

‎packages/google-cloud-bigquery-logging/google/cloud/bigquery_logging/gapic_version.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-logging/google/cloud/bigquery_logging/gapic_version.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "1.5.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

‎packages/google-cloud-bigquery-logging/google/cloud/bigquery_logging_v1/gapic_version.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-logging/google/cloud/bigquery_logging_v1/gapic_version.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "1.5.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

‎packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration/gapic_version.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration/gapic_version.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.11.12" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

‎packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/gapic_version.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/gapic_version.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.11.12" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

‎packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/client.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/client.py
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# limitations under the License.
1515
#
1616
from collections import OrderedDict
17+
from http import HTTPStatus
18+
import json
1719
import logging as std_logging
1820
import os
1921
import re
@@ -514,6 +516,33 @@ def _validate_universe_domain(self):
514516
# NOTE (b/349488459): universe validation is disabled until further notice.
515517
return True
516518

519+
def _add_cred_info_for_auth_errors(
520+
self, error: core_exceptions.GoogleAPICallError
521+
) -> None:
522+
"""Adds credential info string to error details for 401/403/404 errors.
523+
524+
Args:
525+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
526+
"""
527+
if error.code not in [
528+
HTTPStatus.UNAUTHORIZED,
529+
HTTPStatus.FORBIDDEN,
530+
HTTPStatus.NOT_FOUND,
531+
]:
532+
return
533+
534+
cred = self._transport._credentials
535+
536+
# get_cred_info is only available in google-auth>=2.35.0
537+
if not hasattr(cred, "get_cred_info"):
538+
return
539+
540+
# ignore the type check since pypy test fails when get_cred_info
541+
# is not available
542+
cred_info = cred.get_cred_info() # type: ignore
543+
if cred_info and hasattr(error._details, "append"):
544+
error._details.append(json.dumps(cred_info))
545+
517546
@property
518547
def api_endpoint(self):
519548
"""Return the API endpoint used by the client instance.

‎packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/gapic_version.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/gapic_version.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.11.12" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

‎packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/client.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/client.py
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# limitations under the License.
1515
#
1616
from collections import OrderedDict
17+
from http import HTTPStatus
18+
import json
1719
import logging as std_logging
1820
import os
1921
import re
@@ -514,6 +516,33 @@ def _validate_universe_domain(self):
514516
# NOTE (b/349488459): universe validation is disabled until further notice.
515517
return True
516518

519+
def _add_cred_info_for_auth_errors(
520+
self, error: core_exceptions.GoogleAPICallError
521+
) -> None:
522+
"""Adds credential info string to error details for 401/403/404 errors.
523+
524+
Args:
525+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
526+
"""
527+
if error.code not in [
528+
HTTPStatus.UNAUTHORIZED,
529+
HTTPStatus.FORBIDDEN,
530+
HTTPStatus.NOT_FOUND,
531+
]:
532+
return
533+
534+
cred = self._transport._credentials
535+
536+
# get_cred_info is only available in google-auth>=2.35.0
537+
if not hasattr(cred, "get_cred_info"):
538+
return
539+
540+
# ignore the type check since pypy test fails when get_cred_info
541+
# is not available
542+
cred_info = cred.get_cred_info() # type: ignore
543+
if cred_info and hasattr(error._details, "append"):
544+
error._details.append(json.dumps(cred_info))
545+
517546
@property
518547
def api_endpoint(self):
519548
"""Return the API endpoint used by the client instance.

‎packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/client.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/client.py
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# limitations under the License.
1515
#
1616
from collections import OrderedDict
17+
from http import HTTPStatus
18+
import json
1719
import logging as std_logging
1820
import os
1921
import re
@@ -463,6 +465,33 @@ def _validate_universe_domain(self):
463465
# NOTE (b/349488459): universe validation is disabled until further notice.
464466
return True
465467

468+
def _add_cred_info_for_auth_errors(
469+
self, error: core_exceptions.GoogleAPICallError
470+
) -> None:
471+
"""Adds credential info string to error details for 401/403/404 errors.
472+
473+
Args:
474+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
475+
"""
476+
if error.code not in [
477+
HTTPStatus.UNAUTHORIZED,
478+
HTTPStatus.FORBIDDEN,
479+
HTTPStatus.NOT_FOUND,
480+
]:
481+
return
482+
483+
cred = self._transport._credentials
484+
485+
# get_cred_info is only available in google-auth>=2.35.0
486+
if not hasattr(cred, "get_cred_info"):
487+
return
488+
489+
# ignore the type check since pypy test fails when get_cred_info
490+
# is not available
491+
cred_info = cred.get_cred_info() # type: ignore
492+
if cred_info and hasattr(error._details, "append"):
493+
error._details.append(json.dumps(cred_info))
494+
466495
@property
467496
def api_endpoint(self):
468497
"""Return the API endpoint used by the client instance.

‎packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2.json

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-bigquery-migration",
11-
"version": "0.11.12"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

‎packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2alpha.json

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2alpha.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-bigquery-migration",
11-
"version": "0.11.12"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

‎packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2/test_migration_service.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2/test_migration_service.py
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
except ImportError: # pragma: NO COVER
2323
import mock
2424

25+
import json
2526
import math
2627

2728
from google.api_core import api_core_version
@@ -69,6 +70,13 @@
6970
translation_usability,
7071
)
7172

73+
CRED_INFO_JSON = {
74+
"credential_source": "/path/to/file",
75+
"credential_type": "service account credentials",
76+
"principal": "service-account@example.com",
77+
}
78+
CRED_INFO_STRING = json.dumps(CRED_INFO_JSON)
79+
7280

7381
async def mock_async_gen(data, chunk_size=1):
7482
for i in range(0, len(data)): # pragma: NO COVER
@@ -328,6 +336,49 @@ def test__get_universe_domain():
328336
assert str(excinfo.value) == "Universe Domain cannot be an empty string."
329337

330338

339+
@pytest.mark.parametrize(
340+
"error_code,cred_info_json,show_cred_info",
341+
[
342+
(401, CRED_INFO_JSON, True),
343+
(403, CRED_INFO_JSON, True),
344+
(404, CRED_INFO_JSON, True),
345+
(500, CRED_INFO_JSON, False),
346+
(401, None, False),
347+
(403, None, False),
348+
(404, None, False),
349+
(500, None, False),
350+
],
351+
)
352+
def test__add_cred_info_for_auth_errors(error_code, cred_info_json, show_cred_info):
353+
cred = mock.Mock(["get_cred_info"])
354+
cred.get_cred_info = mock.Mock(return_value=cred_info_json)
355+
client = MigrationServiceClient(credentials=cred)
356+
client._transport._credentials = cred
357+
358+
error = core_exceptions.GoogleAPICallError("message", details=["foo"])
359+
error.code = error_code
360+
361+
client._add_cred_info_for_auth_errors(error)
362+
if show_cred_info:
363+
assert error.details == ["foo", CRED_INFO_STRING]
364+
else:
365+
assert error.details == ["foo"]
366+
367+
368+
@pytest.mark.parametrize("error_code", [401, 403, 404, 500])
369+
def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code):
370+
cred = mock.Mock([])
371+
assert not hasattr(cred, "get_cred_info")
372+
client = MigrationServiceClient(credentials=cred)
373+
client._transport._credentials = cred
374+
375+
error = core_exceptions.GoogleAPICallError("message", details=[])
376+
error.code = error_code
377+
378+
client._add_cred_info_for_auth_errors(error)
379+
assert error.details == []
380+
381+
331382
@pytest.mark.parametrize(
332383
"client_class,transport_name",
333384
[

‎packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_migration_service.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_migration_service.py
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
except ImportError: # pragma: NO COVER
2323
import mock
2424

25+
import json
2526
import math
2627

2728
from google.api_core import api_core_version
@@ -66,6 +67,13 @@
6667
translation_task,
6768
)
6869

70+
CRED_INFO_JSON = {
71+
"credential_source": "/path/to/file",
72+
"credential_type": "service account credentials",
73+
"principal": "service-account@example.com",
74+
}
75+
CRED_INFO_STRING = json.dumps(CRED_INFO_JSON)
76+
6977

7078
async def mock_async_gen(data, chunk_size=1):
7179
for i in range(0, len(data)): # pragma: NO COVER
@@ -325,6 +333,49 @@ def test__get_universe_domain():
325333
assert str(excinfo.value) == "Universe Domain cannot be an empty string."
326334

327335

336+
@pytest.mark.parametrize(
337+
"error_code,cred_info_json,show_cred_info",
338+
[
339+
(401, CRED_INFO_JSON, True),
340+
(403, CRED_INFO_JSON, True),
341+
(404, CRED_INFO_JSON, True),
342+
(500, CRED_INFO_JSON, False),
343+
(401, None, False),
344+
(403, None, False),
345+
(404, None, False),
346+
(500, None, False),
347+
],
348+
)
349+
def test__add_cred_info_for_auth_errors(error_code, cred_info_json, show_cred_info):
350+
cred = mock.Mock(["get_cred_info"])
351+
cred.get_cred_info = mock.Mock(return_value=cred_info_json)
352+
client = MigrationServiceClient(credentials=cred)
353+
client._transport._credentials = cred
354+
355+
error = core_exceptions.GoogleAPICallError("message", details=["foo"])
356+
error.code = error_code
357+
358+
client._add_cred_info_for_auth_errors(error)
359+
if show_cred_info:
360+
assert error.details == ["foo", CRED_INFO_STRING]
361+
else:
362+
assert error.details == ["foo"]
363+
364+
365+
@pytest.mark.parametrize("error_code", [401, 403, 404, 500])
366+
def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code):
367+
cred = mock.Mock([])
368+
assert not hasattr(cred, "get_cred_info")
369+
client = MigrationServiceClient(credentials=cred)
370+
client._transport._credentials = cred
371+
372+
error = core_exceptions.GoogleAPICallError("message", details=[])
373+
error.code = error_code
374+
375+
client._add_cred_info_for_auth_errors(error)
376+
assert error.details == []
377+
378+
328379
@pytest.mark.parametrize(
329380
"client_class,transport_name",
330381
[

‎packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_sql_translation_service.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_sql_translation_service.py
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
except ImportError: # pragma: NO COVER
2323
import mock
2424

25+
import json
2526
import math
2627

2728
from google.api_core import api_core_version
@@ -54,6 +55,13 @@
5455
)
5556
from google.cloud.bigquery_migration_v2alpha.types import translation_service
5657

58+
CRED_INFO_JSON = {
59+
"credential_source": "/path/to/file",
60+
"credential_type": "service account credentials",
61+
"principal": "service-account@example.com",
62+
}
63+
CRED_INFO_STRING = json.dumps(CRED_INFO_JSON)
64+
5765

5866
async def mock_async_gen(data, chunk_size=1):
5967
for i in range(0, len(data)): # pragma: NO COVER
@@ -329,6 +337,49 @@ def test__get_universe_domain():
329337
assert str(excinfo.value) == "Universe Domain cannot be an empty string."
330338

331339

340+
@pytest.mark.parametrize(
341+
"error_code,cred_info_json,show_cred_info",
342+
[
343+
(401, CRED_INFO_JSON, True),
344+
(403, CRED_INFO_JSON, True),
345+
(404, CRED_INFO_JSON, True),
346+
(500, CRED_INFO_JSON, False),
347+
(401, None, False),
348+
(403, None, False),
349+
(404, None, False),
350+
(500, None, False),
351+
],
352+
)
353+
def test__add_cred_info_for_auth_errors(error_code, cred_info_json, show_cred_info):
354+
cred = mock.Mock(["get_cred_info"])
355+
cred.get_cred_info = mock.Mock(return_value=cred_info_json)
356+
client = SqlTranslationServiceClient(credentials=cred)
357+
client._transport._credentials = cred
358+
359+
error = core_exceptions.GoogleAPICallError("message", details=["foo"])
360+
error.code = error_code
361+
362+
client._add_cred_info_for_auth_errors(error)
363+
if show_cred_info:
364+
assert error.details == ["foo", CRED_INFO_STRING]
365+
else:
366+
assert error.details == ["foo"]
367+
368+
369+
@pytest.mark.parametrize("error_code", [401, 403, 404, 500])
370+
def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code):
371+
cred = mock.Mock([])
372+
assert not hasattr(cred, "get_cred_info")
373+
client = SqlTranslationServiceClient(credentials=cred)
374+
client._transport._credentials = cred
375+
376+
error = core_exceptions.GoogleAPICallError("message", details=[])
377+
error.code = error_code
378+
379+
client._add_cred_info_for_auth_errors(error)
380+
assert error.details == []
381+
382+
332383
@pytest.mark.parametrize(
333384
"client_class,transport_name",
334385
[

‎packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation/gapic_version.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation/gapic_version.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "1.15.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.