google-cloud-modelarmor 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. {google_cloud_modelarmor-0.1.0/google_cloud_modelarmor.egg-info → google_cloud_modelarmor-0.2.0}/PKG-INFO +8 -8
  2. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/README.rst +2 -2
  3. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor/gapic_version.py +1 -1
  4. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/gapic_version.py +1 -1
  5. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/model_armor/async_client.py +28 -7
  6. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/model_armor/client.py +83 -25
  7. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/model_armor/transports/rest.py +236 -16
  8. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/types/service.py +17 -56
  9. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0/google_cloud_modelarmor.egg-info}/PKG-INFO +8 -8
  10. google_cloud_modelarmor-0.2.0/google_cloud_modelarmor.egg-info/requires.txt +7 -0
  11. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/setup.py +5 -5
  12. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/tests/unit/gapic/modelarmor_v1/test_model_armor.py +94 -0
  13. google_cloud_modelarmor-0.1.0/google_cloud_modelarmor.egg-info/requires.txt +0 -7
  14. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/LICENSE +0 -0
  15. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/MANIFEST.in +0 -0
  16. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor/__init__.py +0 -0
  17. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor/py.typed +0 -0
  18. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/__init__.py +0 -0
  19. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/gapic_metadata.json +0 -0
  20. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/py.typed +0 -0
  21. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/__init__.py +0 -0
  22. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/model_armor/__init__.py +0 -0
  23. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/model_armor/pagers.py +0 -0
  24. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/model_armor/transports/__init__.py +0 -0
  25. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/model_armor/transports/base.py +0 -0
  26. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/model_armor/transports/grpc.py +0 -0
  27. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/model_armor/transports/grpc_asyncio.py +0 -0
  28. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/services/model_armor/transports/rest_base.py +0 -0
  29. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google/cloud/modelarmor_v1/types/__init__.py +0 -0
  30. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google_cloud_modelarmor.egg-info/SOURCES.txt +0 -0
  31. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google_cloud_modelarmor.egg-info/dependency_links.txt +0 -0
  32. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google_cloud_modelarmor.egg-info/not-zip-safe +0 -0
  33. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/google_cloud_modelarmor.egg-info/top_level.txt +0 -0
  34. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/setup.cfg +0 -0
  35. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/tests/__init__.py +0 -0
  36. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/tests/unit/__init__.py +0 -0
  37. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/tests/unit/gapic/__init__.py +0 -0
  38. {google_cloud_modelarmor-0.1.0 → google_cloud_modelarmor-0.2.0}/tests/unit/gapic/modelarmor_v1/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: google-cloud-modelarmor
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Google Cloud Modelarmor API client library
5
5
  Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-modelarmor
6
6
  Author: Google LLC
@@ -23,11 +23,11 @@ Classifier: Operating System :: OS Independent
23
23
  Classifier: Topic :: Internet
24
24
  Requires-Python: >=3.7
25
25
  License-File: LICENSE
26
- Requires-Dist: google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.1
27
- Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1
28
- Requires-Dist: proto-plus<2.0.0dev,>=1.22.3
29
- Requires-Dist: proto-plus<2.0.0dev,>=1.25.0; python_version >= "3.13"
30
- Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0dev,>=3.20.2
26
+ Requires-Dist: google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0,>=1.34.1
27
+ Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0,>=2.14.1
28
+ Requires-Dist: proto-plus<2.0.0,>=1.22.3
29
+ Requires-Dist: proto-plus<2.0.0,>=1.25.0; python_version >= "3.13"
30
+ Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0,>=3.20.2
31
31
 
32
32
  Python Client for Model Armor API
33
33
  =================================
@@ -57,12 +57,12 @@ In order to use this library, you first need to go through the following steps:
57
57
  1. `Select or create a Cloud Platform project.`_
58
58
  2. `Enable billing for your project.`_
59
59
  3. `Enable the Model Armor API.`_
60
- 4. `Setup Authentication.`_
60
+ 4. `Set up Authentication.`_
61
61
 
62
62
  .. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
63
63
  .. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
64
64
  .. _Enable the Model Armor API.: https://cloud.google.com/security-command-center/docs/model-armor-overview
65
- .. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
65
+ .. _Set up Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
66
66
 
67
67
  Installation
68
68
  ~~~~~~~~~~~~
@@ -26,12 +26,12 @@ In order to use this library, you first need to go through the following steps:
26
26
  1. `Select or create a Cloud Platform project.`_
27
27
  2. `Enable billing for your project.`_
28
28
  3. `Enable the Model Armor API.`_
29
- 4. `Setup Authentication.`_
29
+ 4. `Set up Authentication.`_
30
30
 
31
31
  .. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
32
32
  .. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
33
33
  .. _Enable the Model Armor API.: https://cloud.google.com/security-command-center/docs/model-armor-overview
34
- .. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
34
+ .. _Set up Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
35
35
 
36
36
  Installation
37
37
  ~~~~~~~~~~~~
@@ -13,4 +13,4 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- __version__ = "0.1.0" # {x-release-please-version}
16
+ __version__ = "0.2.0" # {x-release-please-version}
@@ -13,4 +13,4 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- __version__ = "0.1.0" # {x-release-please-version}
16
+ __version__ = "0.2.0" # {x-release-please-version}
@@ -355,7 +355,10 @@ class ModelArmorAsyncClient:
355
355
  # Create or coerce a protobuf request object.
356
356
  # - Quick check: If we got a request object, we should *not* have
357
357
  # gotten any keyword arguments that map to the request.
358
- has_flattened_params = any([parent])
358
+ flattened_params = [parent]
359
+ has_flattened_params = (
360
+ len([param for param in flattened_params if param is not None]) > 0
361
+ )
359
362
  if request is not None and has_flattened_params:
360
363
  raise ValueError(
361
364
  "If the `request` argument is set, then none of "
@@ -469,7 +472,10 @@ class ModelArmorAsyncClient:
469
472
  # Create or coerce a protobuf request object.
470
473
  # - Quick check: If we got a request object, we should *not* have
471
474
  # gotten any keyword arguments that map to the request.
472
- has_flattened_params = any([name])
475
+ flattened_params = [name]
476
+ has_flattened_params = (
477
+ len([param for param in flattened_params if param is not None]) > 0
478
+ )
473
479
  if request is not None and has_flattened_params:
474
480
  raise ValueError(
475
481
  "If the `request` argument is set, then none of "
@@ -589,7 +595,10 @@ class ModelArmorAsyncClient:
589
595
  # Create or coerce a protobuf request object.
590
596
  # - Quick check: If we got a request object, we should *not* have
591
597
  # gotten any keyword arguments that map to the request.
592
- has_flattened_params = any([parent, template, template_id])
598
+ flattened_params = [parent, template, template_id]
599
+ has_flattened_params = (
600
+ len([param for param in flattened_params if param is not None]) > 0
601
+ )
593
602
  if request is not None and has_flattened_params:
594
603
  raise ValueError(
595
604
  "If the `request` argument is set, then none of "
@@ -707,7 +716,10 @@ class ModelArmorAsyncClient:
707
716
  # Create or coerce a protobuf request object.
708
717
  # - Quick check: If we got a request object, we should *not* have
709
718
  # gotten any keyword arguments that map to the request.
710
- has_flattened_params = any([template, update_mask])
719
+ flattened_params = [template, update_mask]
720
+ has_flattened_params = (
721
+ len([param for param in flattened_params if param is not None]) > 0
722
+ )
711
723
  if request is not None and has_flattened_params:
712
724
  raise ValueError(
713
725
  "If the `request` argument is set, then none of "
@@ -807,7 +819,10 @@ class ModelArmorAsyncClient:
807
819
  # Create or coerce a protobuf request object.
808
820
  # - Quick check: If we got a request object, we should *not* have
809
821
  # gotten any keyword arguments that map to the request.
810
- has_flattened_params = any([name])
822
+ flattened_params = [name]
823
+ has_flattened_params = (
824
+ len([param for param in flattened_params if param is not None]) > 0
825
+ )
811
826
  if request is not None and has_flattened_params:
812
827
  raise ValueError(
813
828
  "If the `request` argument is set, then none of "
@@ -912,7 +927,10 @@ class ModelArmorAsyncClient:
912
927
  # Create or coerce a protobuf request object.
913
928
  # - Quick check: If we got a request object, we should *not* have
914
929
  # gotten any keyword arguments that map to the request.
915
- has_flattened_params = any([name])
930
+ flattened_params = [name]
931
+ has_flattened_params = (
932
+ len([param for param in flattened_params if param is not None]) > 0
933
+ )
916
934
  if request is not None and has_flattened_params:
917
935
  raise ValueError(
918
936
  "If the `request` argument is set, then none of "
@@ -1031,7 +1049,10 @@ class ModelArmorAsyncClient:
1031
1049
  # Create or coerce a protobuf request object.
1032
1050
  # - Quick check: If we got a request object, we should *not* have
1033
1051
  # gotten any keyword arguments that map to the request.
1034
- has_flattened_params = any([floor_setting, update_mask])
1052
+ flattened_params = [floor_setting, update_mask]
1053
+ has_flattened_params = (
1054
+ len([param for param in flattened_params if param is not None]) > 0
1055
+ )
1035
1056
  if request is not None and has_flattened_params:
1036
1057
  raise ValueError(
1037
1058
  "If the `request` argument is set, then none of "
@@ -14,6 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  from collections import OrderedDict
17
+ from http import HTTPStatus
18
+ import json
17
19
  import logging as std_logging
18
20
  import os
19
21
  import re
@@ -506,6 +508,33 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
506
508
  # NOTE (b/349488459): universe validation is disabled until further notice.
507
509
  return True
508
510
 
511
+ def _add_cred_info_for_auth_errors(
512
+ self, error: core_exceptions.GoogleAPICallError
513
+ ) -> None:
514
+ """Adds credential info string to error details for 401/403/404 errors.
515
+
516
+ Args:
517
+ error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
518
+ """
519
+ if error.code not in [
520
+ HTTPStatus.UNAUTHORIZED,
521
+ HTTPStatus.FORBIDDEN,
522
+ HTTPStatus.NOT_FOUND,
523
+ ]:
524
+ return
525
+
526
+ cred = self._transport._credentials
527
+
528
+ # get_cred_info is only available in google-auth>=2.35.0
529
+ if not hasattr(cred, "get_cred_info"):
530
+ return
531
+
532
+ # ignore the type check since pypy test fails when get_cred_info
533
+ # is not available
534
+ cred_info = cred.get_cred_info() # type: ignore
535
+ if cred_info and hasattr(error._details, "append"):
536
+ error._details.append(json.dumps(cred_info))
537
+
509
538
  @property
510
539
  def api_endpoint(self):
511
540
  """Return the API endpoint used by the client instance.
@@ -768,7 +797,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
768
797
  # Create or coerce a protobuf request object.
769
798
  # - Quick check: If we got a request object, we should *not* have
770
799
  # gotten any keyword arguments that map to the request.
771
- has_flattened_params = any([parent])
800
+ flattened_params = [parent]
801
+ has_flattened_params = (
802
+ len([param for param in flattened_params if param is not None]) > 0
803
+ )
772
804
  if request is not None and has_flattened_params:
773
805
  raise ValueError(
774
806
  "If the `request` argument is set, then none of "
@@ -879,7 +911,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
879
911
  # Create or coerce a protobuf request object.
880
912
  # - Quick check: If we got a request object, we should *not* have
881
913
  # gotten any keyword arguments that map to the request.
882
- has_flattened_params = any([name])
914
+ flattened_params = [name]
915
+ has_flattened_params = (
916
+ len([param for param in flattened_params if param is not None]) > 0
917
+ )
883
918
  if request is not None and has_flattened_params:
884
919
  raise ValueError(
885
920
  "If the `request` argument is set, then none of "
@@ -996,7 +1031,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
996
1031
  # Create or coerce a protobuf request object.
997
1032
  # - Quick check: If we got a request object, we should *not* have
998
1033
  # gotten any keyword arguments that map to the request.
999
- has_flattened_params = any([parent, template, template_id])
1034
+ flattened_params = [parent, template, template_id]
1035
+ has_flattened_params = (
1036
+ len([param for param in flattened_params if param is not None]) > 0
1037
+ )
1000
1038
  if request is not None and has_flattened_params:
1001
1039
  raise ValueError(
1002
1040
  "If the `request` argument is set, then none of "
@@ -1111,7 +1149,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
1111
1149
  # Create or coerce a protobuf request object.
1112
1150
  # - Quick check: If we got a request object, we should *not* have
1113
1151
  # gotten any keyword arguments that map to the request.
1114
- has_flattened_params = any([template, update_mask])
1152
+ flattened_params = [template, update_mask]
1153
+ has_flattened_params = (
1154
+ len([param for param in flattened_params if param is not None]) > 0
1155
+ )
1115
1156
  if request is not None and has_flattened_params:
1116
1157
  raise ValueError(
1117
1158
  "If the `request` argument is set, then none of "
@@ -1208,7 +1249,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
1208
1249
  # Create or coerce a protobuf request object.
1209
1250
  # - Quick check: If we got a request object, we should *not* have
1210
1251
  # gotten any keyword arguments that map to the request.
1211
- has_flattened_params = any([name])
1252
+ flattened_params = [name]
1253
+ has_flattened_params = (
1254
+ len([param for param in flattened_params if param is not None]) > 0
1255
+ )
1212
1256
  if request is not None and has_flattened_params:
1213
1257
  raise ValueError(
1214
1258
  "If the `request` argument is set, then none of "
@@ -1310,7 +1354,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
1310
1354
  # Create or coerce a protobuf request object.
1311
1355
  # - Quick check: If we got a request object, we should *not* have
1312
1356
  # gotten any keyword arguments that map to the request.
1313
- has_flattened_params = any([name])
1357
+ flattened_params = [name]
1358
+ has_flattened_params = (
1359
+ len([param for param in flattened_params if param is not None]) > 0
1360
+ )
1314
1361
  if request is not None and has_flattened_params:
1315
1362
  raise ValueError(
1316
1363
  "If the `request` argument is set, then none of "
@@ -1426,7 +1473,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
1426
1473
  # Create or coerce a protobuf request object.
1427
1474
  # - Quick check: If we got a request object, we should *not* have
1428
1475
  # gotten any keyword arguments that map to the request.
1429
- has_flattened_params = any([floor_setting, update_mask])
1476
+ flattened_params = [floor_setting, update_mask]
1477
+ has_flattened_params = (
1478
+ len([param for param in flattened_params if param is not None]) > 0
1479
+ )
1430
1480
  if request is not None and has_flattened_params:
1431
1481
  raise ValueError(
1432
1482
  "If the `request` argument is set, then none of "
@@ -1697,16 +1747,20 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
1697
1747
  # Validate the universe domain.
1698
1748
  self._validate_universe_domain()
1699
1749
 
1700
- # Send the request.
1701
- response = rpc(
1702
- request,
1703
- retry=retry,
1704
- timeout=timeout,
1705
- metadata=metadata,
1706
- )
1750
+ try:
1751
+ # Send the request.
1752
+ response = rpc(
1753
+ request,
1754
+ retry=retry,
1755
+ timeout=timeout,
1756
+ metadata=metadata,
1757
+ )
1707
1758
 
1708
- # Done; return the response.
1709
- return response
1759
+ # Done; return the response.
1760
+ return response
1761
+ except core_exceptions.GoogleAPICallError as e:
1762
+ self._add_cred_info_for_auth_errors(e)
1763
+ raise e
1710
1764
 
1711
1765
  def list_locations(
1712
1766
  self,
@@ -1752,16 +1806,20 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
1752
1806
  # Validate the universe domain.
1753
1807
  self._validate_universe_domain()
1754
1808
 
1755
- # Send the request.
1756
- response = rpc(
1757
- request,
1758
- retry=retry,
1759
- timeout=timeout,
1760
- metadata=metadata,
1761
- )
1809
+ try:
1810
+ # Send the request.
1811
+ response = rpc(
1812
+ request,
1813
+ retry=retry,
1814
+ timeout=timeout,
1815
+ metadata=metadata,
1816
+ )
1762
1817
 
1763
- # Done; return the response.
1764
- return response
1818
+ # Done; return the response.
1819
+ return response
1820
+ except core_exceptions.GoogleAPICallError as e:
1821
+ self._add_cred_info_for_auth_errors(e)
1822
+ raise e
1765
1823
 
1766
1824
 
1767
1825
  DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(