google-cloud-modelarmor 0.1.1__tar.gz → 0.2.1__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.
- {google_cloud_modelarmor-0.1.1/google_cloud_modelarmor.egg-info → google_cloud_modelarmor-0.2.1}/PKG-INFO +97 -8
- google_cloud_modelarmor-0.2.1/README.rst +197 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor/gapic_version.py +1 -1
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/gapic_version.py +1 -1
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/model_armor/async_client.py +28 -7
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/model_armor/client.py +28 -7
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/types/service.py +15 -7
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1/google_cloud_modelarmor.egg-info}/PKG-INFO +97 -8
- google_cloud_modelarmor-0.2.1/google_cloud_modelarmor.egg-info/requires.txt +7 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/setup.py +5 -5
- google_cloud_modelarmor-0.1.1/README.rst +0 -108
- google_cloud_modelarmor-0.1.1/google_cloud_modelarmor.egg-info/requires.txt +0 -7
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/LICENSE +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/MANIFEST.in +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor/__init__.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor/py.typed +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/__init__.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/gapic_metadata.json +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/py.typed +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/__init__.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/model_armor/__init__.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/model_armor/pagers.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/model_armor/transports/__init__.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/model_armor/transports/base.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/model_armor/transports/grpc.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/model_armor/transports/grpc_asyncio.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/model_armor/transports/rest.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/services/model_armor/transports/rest_base.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/types/__init__.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google_cloud_modelarmor.egg-info/SOURCES.txt +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google_cloud_modelarmor.egg-info/dependency_links.txt +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google_cloud_modelarmor.egg-info/not-zip-safe +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google_cloud_modelarmor.egg-info/top_level.txt +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/setup.cfg +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/tests/__init__.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/tests/unit/__init__.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/tests/unit/gapic/__init__.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/tests/unit/gapic/modelarmor_v1/__init__.py +0 -0
- {google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/tests/unit/gapic/modelarmor_v1/test_model_armor.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: google-cloud-modelarmor
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.1
|
|
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.
|
|
27
|
-
Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.
|
|
28
|
-
Requires-Dist: proto-plus<2.0.
|
|
29
|
-
Requires-Dist: proto-plus<2.0.
|
|
30
|
-
Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<
|
|
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,<7.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. `
|
|
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
|
-
..
|
|
65
|
+
.. _Set up Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
|
|
66
66
|
|
|
67
67
|
Installation
|
|
68
68
|
~~~~~~~~~~~~
|
|
@@ -137,3 +137,92 @@ Next Steps
|
|
|
137
137
|
|
|
138
138
|
.. _Model Armor API Product documentation: https://cloud.google.com/security-command-center/docs/model-armor-overview
|
|
139
139
|
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst
|
|
140
|
+
|
|
141
|
+
Logging
|
|
142
|
+
-------
|
|
143
|
+
|
|
144
|
+
This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes.
|
|
145
|
+
Note the following:
|
|
146
|
+
|
|
147
|
+
#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging.
|
|
148
|
+
#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**.
|
|
149
|
+
#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below.
|
|
150
|
+
|
|
151
|
+
Simple, environment-based configuration
|
|
152
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
153
|
+
|
|
154
|
+
To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google
|
|
155
|
+
logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged
|
|
156
|
+
messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging
|
|
157
|
+
event.
|
|
158
|
+
|
|
159
|
+
A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log.
|
|
160
|
+
|
|
161
|
+
- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc.
|
|
162
|
+
- Invalid logging scopes: :code:`foo`, :code:`123`, etc.
|
|
163
|
+
|
|
164
|
+
**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers.
|
|
165
|
+
|
|
166
|
+
Environment-Based Examples
|
|
167
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
168
|
+
|
|
169
|
+
- Enabling the default handler for all Google-based loggers
|
|
170
|
+
|
|
171
|
+
.. code-block:: console
|
|
172
|
+
|
|
173
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google
|
|
174
|
+
|
|
175
|
+
- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
176
|
+
|
|
177
|
+
.. code-block:: console
|
|
178
|
+
|
|
179
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
Advanced, code-based configuration
|
|
183
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
184
|
+
|
|
185
|
+
You can also configure a valid logging scope using Python's standard `logging` mechanism.
|
|
186
|
+
|
|
187
|
+
Code-Based Examples
|
|
188
|
+
^^^^^^^^^^^^^^^^^^^
|
|
189
|
+
|
|
190
|
+
- Configuring a handler for all Google-based loggers
|
|
191
|
+
|
|
192
|
+
.. code-block:: python
|
|
193
|
+
|
|
194
|
+
import logging
|
|
195
|
+
|
|
196
|
+
from google.cloud.translate_v3 import translate
|
|
197
|
+
|
|
198
|
+
base_logger = logging.getLogger("google")
|
|
199
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
200
|
+
base_logger.setLevel(logging.DEBUG)
|
|
201
|
+
|
|
202
|
+
- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
203
|
+
|
|
204
|
+
.. code-block:: python
|
|
205
|
+
|
|
206
|
+
import logging
|
|
207
|
+
|
|
208
|
+
from google.cloud.translate_v3 import translate
|
|
209
|
+
|
|
210
|
+
base_logger = logging.getLogger("google.cloud.library_v1")
|
|
211
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
212
|
+
base_logger.setLevel(logging.DEBUG)
|
|
213
|
+
|
|
214
|
+
Logging details
|
|
215
|
+
~~~~~~~~~~~~~~~
|
|
216
|
+
|
|
217
|
+
#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root
|
|
218
|
+
logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set
|
|
219
|
+
:code:`logging.getLogger("google").propagate = True` in your code.
|
|
220
|
+
#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for
|
|
221
|
+
one library, but decide you need to also set up environment-based logging configuration for another library.
|
|
222
|
+
|
|
223
|
+
#. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual
|
|
224
|
+
if the code -based configuration gets applied first.
|
|
225
|
+
|
|
226
|
+
#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get
|
|
227
|
+
executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured.
|
|
228
|
+
(This is the reason for 2.i. above.)
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Python Client for Model Armor API
|
|
2
|
+
=================================
|
|
3
|
+
|
|
4
|
+
|preview| |pypi| |versions|
|
|
5
|
+
|
|
6
|
+
`Model Armor API`_: Model Armor helps you protect against risks like prompt injection, harmful content, and data leakage in generative AI applications by letting you define policies that filter user prompts and model responses.
|
|
7
|
+
|
|
8
|
+
- `Client Library Documentation`_
|
|
9
|
+
- `Product Documentation`_
|
|
10
|
+
|
|
11
|
+
.. |preview| image:: https://img.shields.io/badge/support-preview-orange.svg
|
|
12
|
+
:target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#stability-levels
|
|
13
|
+
.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-modelarmor.svg
|
|
14
|
+
:target: https://pypi.org/project/google-cloud-modelarmor/
|
|
15
|
+
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-modelarmor.svg
|
|
16
|
+
:target: https://pypi.org/project/google-cloud-modelarmor/
|
|
17
|
+
.. _Model Armor API: https://cloud.google.com/security-command-center/docs/model-armor-overview
|
|
18
|
+
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/google-cloud-modelarmor/latest/summary_overview
|
|
19
|
+
.. _Product Documentation: https://cloud.google.com/security-command-center/docs/model-armor-overview
|
|
20
|
+
|
|
21
|
+
Quick Start
|
|
22
|
+
-----------
|
|
23
|
+
|
|
24
|
+
In order to use this library, you first need to go through the following steps:
|
|
25
|
+
|
|
26
|
+
1. `Select or create a Cloud Platform project.`_
|
|
27
|
+
2. `Enable billing for your project.`_
|
|
28
|
+
3. `Enable the Model Armor API.`_
|
|
29
|
+
4. `Set up Authentication.`_
|
|
30
|
+
|
|
31
|
+
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
|
|
32
|
+
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
|
|
33
|
+
.. _Enable the Model Armor API.: https://cloud.google.com/security-command-center/docs/model-armor-overview
|
|
34
|
+
.. _Set up Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
|
|
35
|
+
|
|
36
|
+
Installation
|
|
37
|
+
~~~~~~~~~~~~
|
|
38
|
+
|
|
39
|
+
Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
|
|
40
|
+
creates isolated Python environments. These isolated environments can have separate
|
|
41
|
+
versions of Python packages, which allows you to isolate one project's dependencies
|
|
42
|
+
from the dependencies of other projects.
|
|
43
|
+
|
|
44
|
+
With `venv`_, it's possible to install this library without needing system
|
|
45
|
+
install permissions, and without clashing with the installed system
|
|
46
|
+
dependencies.
|
|
47
|
+
|
|
48
|
+
.. _`venv`: https://docs.python.org/3/library/venv.html
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Code samples and snippets
|
|
52
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
53
|
+
|
|
54
|
+
Code samples and snippets live in the `samples/`_ folder.
|
|
55
|
+
|
|
56
|
+
.. _samples/: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-modelarmor/samples
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
Supported Python Versions
|
|
60
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
61
|
+
Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
|
|
62
|
+
Python.
|
|
63
|
+
|
|
64
|
+
Python >= 3.7
|
|
65
|
+
|
|
66
|
+
.. _active: https://devguide.python.org/devcycle/#in-development-main-branch
|
|
67
|
+
.. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
|
|
68
|
+
|
|
69
|
+
Unsupported Python Versions
|
|
70
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
71
|
+
Python <= 3.6
|
|
72
|
+
|
|
73
|
+
If you are using an `end-of-life`_
|
|
74
|
+
version of Python, we recommend that you update as soon as possible to an actively supported version.
|
|
75
|
+
|
|
76
|
+
.. _end-of-life: https://devguide.python.org/devcycle/#end-of-life-branches
|
|
77
|
+
|
|
78
|
+
Mac/Linux
|
|
79
|
+
^^^^^^^^^
|
|
80
|
+
|
|
81
|
+
.. code-block:: console
|
|
82
|
+
|
|
83
|
+
python3 -m venv <your-env>
|
|
84
|
+
source <your-env>/bin/activate
|
|
85
|
+
pip install google-cloud-modelarmor
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
Windows
|
|
89
|
+
^^^^^^^
|
|
90
|
+
|
|
91
|
+
.. code-block:: console
|
|
92
|
+
|
|
93
|
+
py -m venv <your-env>
|
|
94
|
+
.\<your-env>\Scripts\activate
|
|
95
|
+
pip install google-cloud-modelarmor
|
|
96
|
+
|
|
97
|
+
Next Steps
|
|
98
|
+
~~~~~~~~~~
|
|
99
|
+
|
|
100
|
+
- Read the `Client Library Documentation`_ for Model Armor API
|
|
101
|
+
to see other available methods on the client.
|
|
102
|
+
- Read the `Model Armor API Product documentation`_ to learn
|
|
103
|
+
more about the product and see How-to Guides.
|
|
104
|
+
- View this `README`_ to see the full list of Cloud
|
|
105
|
+
APIs that we cover.
|
|
106
|
+
|
|
107
|
+
.. _Model Armor API Product documentation: https://cloud.google.com/security-command-center/docs/model-armor-overview
|
|
108
|
+
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst
|
|
109
|
+
|
|
110
|
+
Logging
|
|
111
|
+
-------
|
|
112
|
+
|
|
113
|
+
This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes.
|
|
114
|
+
Note the following:
|
|
115
|
+
|
|
116
|
+
#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging.
|
|
117
|
+
#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**.
|
|
118
|
+
#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below.
|
|
119
|
+
|
|
120
|
+
Simple, environment-based configuration
|
|
121
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
122
|
+
|
|
123
|
+
To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google
|
|
124
|
+
logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged
|
|
125
|
+
messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging
|
|
126
|
+
event.
|
|
127
|
+
|
|
128
|
+
A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log.
|
|
129
|
+
|
|
130
|
+
- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc.
|
|
131
|
+
- Invalid logging scopes: :code:`foo`, :code:`123`, etc.
|
|
132
|
+
|
|
133
|
+
**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers.
|
|
134
|
+
|
|
135
|
+
Environment-Based Examples
|
|
136
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
137
|
+
|
|
138
|
+
- Enabling the default handler for all Google-based loggers
|
|
139
|
+
|
|
140
|
+
.. code-block:: console
|
|
141
|
+
|
|
142
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google
|
|
143
|
+
|
|
144
|
+
- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
145
|
+
|
|
146
|
+
.. code-block:: console
|
|
147
|
+
|
|
148
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
Advanced, code-based configuration
|
|
152
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
153
|
+
|
|
154
|
+
You can also configure a valid logging scope using Python's standard `logging` mechanism.
|
|
155
|
+
|
|
156
|
+
Code-Based Examples
|
|
157
|
+
^^^^^^^^^^^^^^^^^^^
|
|
158
|
+
|
|
159
|
+
- Configuring a handler for all Google-based loggers
|
|
160
|
+
|
|
161
|
+
.. code-block:: python
|
|
162
|
+
|
|
163
|
+
import logging
|
|
164
|
+
|
|
165
|
+
from google.cloud.translate_v3 import translate
|
|
166
|
+
|
|
167
|
+
base_logger = logging.getLogger("google")
|
|
168
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
169
|
+
base_logger.setLevel(logging.DEBUG)
|
|
170
|
+
|
|
171
|
+
- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
172
|
+
|
|
173
|
+
.. code-block:: python
|
|
174
|
+
|
|
175
|
+
import logging
|
|
176
|
+
|
|
177
|
+
from google.cloud.translate_v3 import translate
|
|
178
|
+
|
|
179
|
+
base_logger = logging.getLogger("google.cloud.library_v1")
|
|
180
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
181
|
+
base_logger.setLevel(logging.DEBUG)
|
|
182
|
+
|
|
183
|
+
Logging details
|
|
184
|
+
~~~~~~~~~~~~~~~
|
|
185
|
+
|
|
186
|
+
#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root
|
|
187
|
+
logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set
|
|
188
|
+
:code:`logging.getLogger("google").propagate = True` in your code.
|
|
189
|
+
#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for
|
|
190
|
+
one library, but decide you need to also set up environment-based logging configuration for another library.
|
|
191
|
+
|
|
192
|
+
#. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual
|
|
193
|
+
if the code -based configuration gets applied first.
|
|
194
|
+
|
|
195
|
+
#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get
|
|
196
|
+
executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured.
|
|
197
|
+
(This is the reason for 2.i. above.)
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 "
|
|
@@ -797,7 +797,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
|
|
|
797
797
|
# Create or coerce a protobuf request object.
|
|
798
798
|
# - Quick check: If we got a request object, we should *not* have
|
|
799
799
|
# gotten any keyword arguments that map to the request.
|
|
800
|
-
|
|
800
|
+
flattened_params = [parent]
|
|
801
|
+
has_flattened_params = (
|
|
802
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
803
|
+
)
|
|
801
804
|
if request is not None and has_flattened_params:
|
|
802
805
|
raise ValueError(
|
|
803
806
|
"If the `request` argument is set, then none of "
|
|
@@ -908,7 +911,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
|
|
|
908
911
|
# Create or coerce a protobuf request object.
|
|
909
912
|
# - Quick check: If we got a request object, we should *not* have
|
|
910
913
|
# gotten any keyword arguments that map to the request.
|
|
911
|
-
|
|
914
|
+
flattened_params = [name]
|
|
915
|
+
has_flattened_params = (
|
|
916
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
917
|
+
)
|
|
912
918
|
if request is not None and has_flattened_params:
|
|
913
919
|
raise ValueError(
|
|
914
920
|
"If the `request` argument is set, then none of "
|
|
@@ -1025,7 +1031,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
|
|
|
1025
1031
|
# Create or coerce a protobuf request object.
|
|
1026
1032
|
# - Quick check: If we got a request object, we should *not* have
|
|
1027
1033
|
# gotten any keyword arguments that map to the request.
|
|
1028
|
-
|
|
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
|
+
)
|
|
1029
1038
|
if request is not None and has_flattened_params:
|
|
1030
1039
|
raise ValueError(
|
|
1031
1040
|
"If the `request` argument is set, then none of "
|
|
@@ -1140,7 +1149,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
|
|
|
1140
1149
|
# Create or coerce a protobuf request object.
|
|
1141
1150
|
# - Quick check: If we got a request object, we should *not* have
|
|
1142
1151
|
# gotten any keyword arguments that map to the request.
|
|
1143
|
-
|
|
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
|
+
)
|
|
1144
1156
|
if request is not None and has_flattened_params:
|
|
1145
1157
|
raise ValueError(
|
|
1146
1158
|
"If the `request` argument is set, then none of "
|
|
@@ -1237,7 +1249,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
|
|
|
1237
1249
|
# Create or coerce a protobuf request object.
|
|
1238
1250
|
# - Quick check: If we got a request object, we should *not* have
|
|
1239
1251
|
# gotten any keyword arguments that map to the request.
|
|
1240
|
-
|
|
1252
|
+
flattened_params = [name]
|
|
1253
|
+
has_flattened_params = (
|
|
1254
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1255
|
+
)
|
|
1241
1256
|
if request is not None and has_flattened_params:
|
|
1242
1257
|
raise ValueError(
|
|
1243
1258
|
"If the `request` argument is set, then none of "
|
|
@@ -1339,7 +1354,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
|
|
|
1339
1354
|
# Create or coerce a protobuf request object.
|
|
1340
1355
|
# - Quick check: If we got a request object, we should *not* have
|
|
1341
1356
|
# gotten any keyword arguments that map to the request.
|
|
1342
|
-
|
|
1357
|
+
flattened_params = [name]
|
|
1358
|
+
has_flattened_params = (
|
|
1359
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1360
|
+
)
|
|
1343
1361
|
if request is not None and has_flattened_params:
|
|
1344
1362
|
raise ValueError(
|
|
1345
1363
|
"If the `request` argument is set, then none of "
|
|
@@ -1455,7 +1473,10 @@ class ModelArmorClient(metaclass=ModelArmorClientMeta):
|
|
|
1455
1473
|
# Create or coerce a protobuf request object.
|
|
1456
1474
|
# - Quick check: If we got a request object, we should *not* have
|
|
1457
1475
|
# gotten any keyword arguments that map to the request.
|
|
1458
|
-
|
|
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
|
+
)
|
|
1459
1480
|
if request is not None and has_flattened_params:
|
|
1460
1481
|
raise ValueError(
|
|
1461
1482
|
"If the `request` argument is set, then none of "
|
|
@@ -310,6 +310,8 @@ class Template(proto.Message):
|
|
|
310
310
|
class FloorSetting(proto.Message):
|
|
311
311
|
r"""Message describing FloorSetting resource
|
|
312
312
|
|
|
313
|
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
|
314
|
+
|
|
313
315
|
Attributes:
|
|
314
316
|
name (str):
|
|
315
317
|
Identifier. The resource name.
|
|
@@ -321,6 +323,8 @@ class FloorSetting(proto.Message):
|
|
|
321
323
|
Required. ModelArmor filter configuration.
|
|
322
324
|
enable_floor_setting_enforcement (bool):
|
|
323
325
|
Optional. Floor Settings enforcement status.
|
|
326
|
+
|
|
327
|
+
This field is a member of `oneof`_ ``_enable_floor_setting_enforcement``.
|
|
324
328
|
"""
|
|
325
329
|
|
|
326
330
|
name: str = proto.Field(
|
|
@@ -345,6 +349,7 @@ class FloorSetting(proto.Message):
|
|
|
345
349
|
enable_floor_setting_enforcement: bool = proto.Field(
|
|
346
350
|
proto.BOOL,
|
|
347
351
|
number=5,
|
|
352
|
+
optional=True,
|
|
348
353
|
)
|
|
349
354
|
|
|
350
355
|
|
|
@@ -866,10 +871,9 @@ class SdpAdvancedConfig(proto.Message):
|
|
|
866
871
|
not provided), then Sensitive Data Protection InspectContent
|
|
867
872
|
action is performed during Sanitization. All Sensitive Data
|
|
868
873
|
Protection findings identified during inspection will be
|
|
869
|
-
returned as SdpFinding in SdpInsepctionResult
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
``organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template}``
|
|
874
|
+
returned as SdpFinding in SdpInsepctionResult.
|
|
875
|
+
|
|
876
|
+
e.g.
|
|
873
877
|
``projects/{project}/locations/{location}/inspectTemplates/{inspect_template}``
|
|
874
878
|
deidentify_template (str):
|
|
875
879
|
Optional. Optional Sensitive Data Protection Deidentify
|
|
@@ -882,9 +886,6 @@ class SdpAdvancedConfig(proto.Message):
|
|
|
882
886
|
deidentify template must be present in inspect template.
|
|
883
887
|
|
|
884
888
|
e.g.
|
|
885
|
-
``organizations/{organization}/deidentifyTemplates/{deidentify_template}``,
|
|
886
|
-
``projects/{project}/deidentifyTemplates/{deidentify_template}``
|
|
887
|
-
``organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template}``
|
|
888
889
|
``projects/{project}/locations/{location}/deidentifyTemplates/{deidentify_template}``
|
|
889
890
|
"""
|
|
890
891
|
|
|
@@ -1395,6 +1396,9 @@ class SdpDeidentifyResult(proto.Message):
|
|
|
1395
1396
|
transformed_bytes (int):
|
|
1396
1397
|
Total size in bytes that were transformed
|
|
1397
1398
|
during deidentification.
|
|
1399
|
+
info_types (MutableSequence[str]):
|
|
1400
|
+
List of Sensitive Data Protection info-types
|
|
1401
|
+
that were de-identified.
|
|
1398
1402
|
"""
|
|
1399
1403
|
|
|
1400
1404
|
execution_state: "FilterExecutionState" = proto.Field(
|
|
@@ -1421,6 +1425,10 @@ class SdpDeidentifyResult(proto.Message):
|
|
|
1421
1425
|
proto.INT64,
|
|
1422
1426
|
number=5,
|
|
1423
1427
|
)
|
|
1428
|
+
info_types: MutableSequence[str] = proto.RepeatedField(
|
|
1429
|
+
proto.STRING,
|
|
1430
|
+
number=6,
|
|
1431
|
+
)
|
|
1424
1432
|
|
|
1425
1433
|
|
|
1426
1434
|
class SdpFinding(proto.Message):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: google-cloud-modelarmor
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.1
|
|
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.
|
|
27
|
-
Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.
|
|
28
|
-
Requires-Dist: proto-plus<2.0.
|
|
29
|
-
Requires-Dist: proto-plus<2.0.
|
|
30
|
-
Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<
|
|
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,<7.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. `
|
|
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
|
-
..
|
|
65
|
+
.. _Set up Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
|
|
66
66
|
|
|
67
67
|
Installation
|
|
68
68
|
~~~~~~~~~~~~
|
|
@@ -137,3 +137,92 @@ Next Steps
|
|
|
137
137
|
|
|
138
138
|
.. _Model Armor API Product documentation: https://cloud.google.com/security-command-center/docs/model-armor-overview
|
|
139
139
|
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst
|
|
140
|
+
|
|
141
|
+
Logging
|
|
142
|
+
-------
|
|
143
|
+
|
|
144
|
+
This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes.
|
|
145
|
+
Note the following:
|
|
146
|
+
|
|
147
|
+
#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging.
|
|
148
|
+
#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**.
|
|
149
|
+
#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below.
|
|
150
|
+
|
|
151
|
+
Simple, environment-based configuration
|
|
152
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
153
|
+
|
|
154
|
+
To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google
|
|
155
|
+
logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged
|
|
156
|
+
messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging
|
|
157
|
+
event.
|
|
158
|
+
|
|
159
|
+
A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log.
|
|
160
|
+
|
|
161
|
+
- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc.
|
|
162
|
+
- Invalid logging scopes: :code:`foo`, :code:`123`, etc.
|
|
163
|
+
|
|
164
|
+
**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers.
|
|
165
|
+
|
|
166
|
+
Environment-Based Examples
|
|
167
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
168
|
+
|
|
169
|
+
- Enabling the default handler for all Google-based loggers
|
|
170
|
+
|
|
171
|
+
.. code-block:: console
|
|
172
|
+
|
|
173
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google
|
|
174
|
+
|
|
175
|
+
- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
176
|
+
|
|
177
|
+
.. code-block:: console
|
|
178
|
+
|
|
179
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
Advanced, code-based configuration
|
|
183
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
184
|
+
|
|
185
|
+
You can also configure a valid logging scope using Python's standard `logging` mechanism.
|
|
186
|
+
|
|
187
|
+
Code-Based Examples
|
|
188
|
+
^^^^^^^^^^^^^^^^^^^
|
|
189
|
+
|
|
190
|
+
- Configuring a handler for all Google-based loggers
|
|
191
|
+
|
|
192
|
+
.. code-block:: python
|
|
193
|
+
|
|
194
|
+
import logging
|
|
195
|
+
|
|
196
|
+
from google.cloud.translate_v3 import translate
|
|
197
|
+
|
|
198
|
+
base_logger = logging.getLogger("google")
|
|
199
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
200
|
+
base_logger.setLevel(logging.DEBUG)
|
|
201
|
+
|
|
202
|
+
- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
203
|
+
|
|
204
|
+
.. code-block:: python
|
|
205
|
+
|
|
206
|
+
import logging
|
|
207
|
+
|
|
208
|
+
from google.cloud.translate_v3 import translate
|
|
209
|
+
|
|
210
|
+
base_logger = logging.getLogger("google.cloud.library_v1")
|
|
211
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
212
|
+
base_logger.setLevel(logging.DEBUG)
|
|
213
|
+
|
|
214
|
+
Logging details
|
|
215
|
+
~~~~~~~~~~~~~~~
|
|
216
|
+
|
|
217
|
+
#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root
|
|
218
|
+
logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set
|
|
219
|
+
:code:`logging.getLogger("google").propagate = True` in your code.
|
|
220
|
+
#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for
|
|
221
|
+
one library, but decide you need to also set up environment-based logging configuration for another library.
|
|
222
|
+
|
|
223
|
+
#. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual
|
|
224
|
+
if the code -based configuration gets applied first.
|
|
225
|
+
|
|
226
|
+
#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get
|
|
227
|
+
executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured.
|
|
228
|
+
(This is the reason for 2.i. above.)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
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
|
|
2
|
+
google-auth!=2.24.0,!=2.25.0,<3.0.0,>=2.14.1
|
|
3
|
+
proto-plus<2.0.0,>=1.22.3
|
|
4
|
+
protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<7.0.0,>=3.20.2
|
|
5
|
+
|
|
6
|
+
[:python_version >= "3.13"]
|
|
7
|
+
proto-plus<2.0.0,>=1.25.0
|
|
@@ -39,13 +39,13 @@ else:
|
|
|
39
39
|
release_status = "Development Status :: 5 - Production/Stable"
|
|
40
40
|
|
|
41
41
|
dependencies = [
|
|
42
|
-
"google-api-core[grpc] >= 1.34.1, <3.0.
|
|
42
|
+
"google-api-core[grpc] >= 1.34.1, <3.0.0,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*",
|
|
43
43
|
# Exclude incompatible versions of `google-auth`
|
|
44
44
|
# See https://github.com/googleapis/google-cloud-python/issues/12364
|
|
45
|
-
"google-auth >= 2.14.1, <3.0.
|
|
46
|
-
"proto-plus >= 1.22.3, <2.0.
|
|
47
|
-
"proto-plus >= 1.25.0, <2.0.
|
|
48
|
-
"protobuf>=3.20.2,<
|
|
45
|
+
"google-auth >= 2.14.1, <3.0.0,!=2.24.0,!=2.25.0",
|
|
46
|
+
"proto-plus >= 1.22.3, <2.0.0",
|
|
47
|
+
"proto-plus >= 1.25.0, <2.0.0; python_version >= '3.13'",
|
|
48
|
+
"protobuf>=3.20.2,<7.0.0,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
|
|
49
49
|
]
|
|
50
50
|
extras = {}
|
|
51
51
|
url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-modelarmor"
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
Python Client for Model Armor API
|
|
2
|
-
=================================
|
|
3
|
-
|
|
4
|
-
|preview| |pypi| |versions|
|
|
5
|
-
|
|
6
|
-
`Model Armor API`_: Model Armor helps you protect against risks like prompt injection, harmful content, and data leakage in generative AI applications by letting you define policies that filter user prompts and model responses.
|
|
7
|
-
|
|
8
|
-
- `Client Library Documentation`_
|
|
9
|
-
- `Product Documentation`_
|
|
10
|
-
|
|
11
|
-
.. |preview| image:: https://img.shields.io/badge/support-preview-orange.svg
|
|
12
|
-
:target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#stability-levels
|
|
13
|
-
.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-modelarmor.svg
|
|
14
|
-
:target: https://pypi.org/project/google-cloud-modelarmor/
|
|
15
|
-
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-modelarmor.svg
|
|
16
|
-
:target: https://pypi.org/project/google-cloud-modelarmor/
|
|
17
|
-
.. _Model Armor API: https://cloud.google.com/security-command-center/docs/model-armor-overview
|
|
18
|
-
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/google-cloud-modelarmor/latest/summary_overview
|
|
19
|
-
.. _Product Documentation: https://cloud.google.com/security-command-center/docs/model-armor-overview
|
|
20
|
-
|
|
21
|
-
Quick Start
|
|
22
|
-
-----------
|
|
23
|
-
|
|
24
|
-
In order to use this library, you first need to go through the following steps:
|
|
25
|
-
|
|
26
|
-
1. `Select or create a Cloud Platform project.`_
|
|
27
|
-
2. `Enable billing for your project.`_
|
|
28
|
-
3. `Enable the Model Armor API.`_
|
|
29
|
-
4. `Setup Authentication.`_
|
|
30
|
-
|
|
31
|
-
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
|
|
32
|
-
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
|
|
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
|
|
35
|
-
|
|
36
|
-
Installation
|
|
37
|
-
~~~~~~~~~~~~
|
|
38
|
-
|
|
39
|
-
Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
|
|
40
|
-
creates isolated Python environments. These isolated environments can have separate
|
|
41
|
-
versions of Python packages, which allows you to isolate one project's dependencies
|
|
42
|
-
from the dependencies of other projects.
|
|
43
|
-
|
|
44
|
-
With `venv`_, it's possible to install this library without needing system
|
|
45
|
-
install permissions, and without clashing with the installed system
|
|
46
|
-
dependencies.
|
|
47
|
-
|
|
48
|
-
.. _`venv`: https://docs.python.org/3/library/venv.html
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Code samples and snippets
|
|
52
|
-
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
53
|
-
|
|
54
|
-
Code samples and snippets live in the `samples/`_ folder.
|
|
55
|
-
|
|
56
|
-
.. _samples/: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-modelarmor/samples
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Supported Python Versions
|
|
60
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
61
|
-
Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
|
|
62
|
-
Python.
|
|
63
|
-
|
|
64
|
-
Python >= 3.7
|
|
65
|
-
|
|
66
|
-
.. _active: https://devguide.python.org/devcycle/#in-development-main-branch
|
|
67
|
-
.. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
|
|
68
|
-
|
|
69
|
-
Unsupported Python Versions
|
|
70
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
71
|
-
Python <= 3.6
|
|
72
|
-
|
|
73
|
-
If you are using an `end-of-life`_
|
|
74
|
-
version of Python, we recommend that you update as soon as possible to an actively supported version.
|
|
75
|
-
|
|
76
|
-
.. _end-of-life: https://devguide.python.org/devcycle/#end-of-life-branches
|
|
77
|
-
|
|
78
|
-
Mac/Linux
|
|
79
|
-
^^^^^^^^^
|
|
80
|
-
|
|
81
|
-
.. code-block:: console
|
|
82
|
-
|
|
83
|
-
python3 -m venv <your-env>
|
|
84
|
-
source <your-env>/bin/activate
|
|
85
|
-
pip install google-cloud-modelarmor
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
Windows
|
|
89
|
-
^^^^^^^
|
|
90
|
-
|
|
91
|
-
.. code-block:: console
|
|
92
|
-
|
|
93
|
-
py -m venv <your-env>
|
|
94
|
-
.\<your-env>\Scripts\activate
|
|
95
|
-
pip install google-cloud-modelarmor
|
|
96
|
-
|
|
97
|
-
Next Steps
|
|
98
|
-
~~~~~~~~~~
|
|
99
|
-
|
|
100
|
-
- Read the `Client Library Documentation`_ for Model Armor API
|
|
101
|
-
to see other available methods on the client.
|
|
102
|
-
- Read the `Model Armor API Product documentation`_ to learn
|
|
103
|
-
more about the product and see How-to Guides.
|
|
104
|
-
- View this `README`_ to see the full list of Cloud
|
|
105
|
-
APIs that we cover.
|
|
106
|
-
|
|
107
|
-
.. _Model Armor API Product documentation: https://cloud.google.com/security-command-center/docs/model-armor-overview
|
|
108
|
-
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
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
|
|
2
|
-
google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1
|
|
3
|
-
proto-plus<2.0.0dev,>=1.22.3
|
|
4
|
-
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
|
|
5
|
-
|
|
6
|
-
[:python_version >= "3.13"]
|
|
7
|
-
proto-plus<2.0.0dev,>=1.25.0
|
|
File without changes
|
|
File without changes
|
{google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor/__init__.py
RENAMED
|
File without changes
|
{google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/google/cloud/modelarmor_v1/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_modelarmor-0.1.1 → google_cloud_modelarmor-0.2.1}/tests/unit/gapic/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|