google-cloud-network-security 0.9.17__py3-none-any.whl
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/network_security/__init__.py +91 -0
- google/cloud/network_security/gapic_version.py +16 -0
- google/cloud/network_security/py.typed +2 -0
- google/cloud/network_security_v1/__init__.py +86 -0
- google/cloud/network_security_v1/gapic_metadata.json +253 -0
- google/cloud/network_security_v1/gapic_version.py +16 -0
- google/cloud/network_security_v1/py.typed +2 -0
- google/cloud/network_security_v1/services/__init__.py +15 -0
- google/cloud/network_security_v1/services/network_security/__init__.py +22 -0
- google/cloud/network_security_v1/services/network_security/async_client.py +3074 -0
- google/cloud/network_security_v1/services/network_security/client.py +3525 -0
- google/cloud/network_security_v1/services/network_security/pagers.py +525 -0
- google/cloud/network_security_v1/services/network_security/transports/__init__.py +36 -0
- google/cloud/network_security_v1/services/network_security/transports/base.py +524 -0
- google/cloud/network_security_v1/services/network_security/transports/grpc.py +993 -0
- google/cloud/network_security_v1/services/network_security/transports/grpc_asyncio.py +1138 -0
- google/cloud/network_security_v1/services/network_security/transports/rest.py +5057 -0
- google/cloud/network_security_v1/services/network_security/transports/rest_base.py +1156 -0
- google/cloud/network_security_v1/types/__init__.py +78 -0
- google/cloud/network_security_v1/types/authorization_policy.py +430 -0
- google/cloud/network_security_v1/types/client_tls_policy.py +270 -0
- google/cloud/network_security_v1/types/common.py +93 -0
- google/cloud/network_security_v1/types/network_security.py +24 -0
- google/cloud/network_security_v1/types/server_tls_policy.py +295 -0
- google/cloud/network_security_v1/types/tls.py +153 -0
- google/cloud/network_security_v1beta1/__init__.py +86 -0
- google/cloud/network_security_v1beta1/gapic_metadata.json +173 -0
- google/cloud/network_security_v1beta1/gapic_version.py +16 -0
- google/cloud/network_security_v1beta1/py.typed +2 -0
- google/cloud/network_security_v1beta1/services/__init__.py +15 -0
- google/cloud/network_security_v1beta1/services/network_security/__init__.py +22 -0
- google/cloud/network_security_v1beta1/services/network_security/async_client.py +3074 -0
- google/cloud/network_security_v1beta1/services/network_security/client.py +3523 -0
- google/cloud/network_security_v1beta1/services/network_security/pagers.py +525 -0
- google/cloud/network_security_v1beta1/services/network_security/transports/__init__.py +32 -0
- google/cloud/network_security_v1beta1/services/network_security/transports/base.py +524 -0
- google/cloud/network_security_v1beta1/services/network_security/transports/grpc.py +993 -0
- google/cloud/network_security_v1beta1/services/network_security/transports/grpc_asyncio.py +1138 -0
- google/cloud/network_security_v1beta1/services/network_security/transports/rest.py +3195 -0
- google/cloud/network_security_v1beta1/types/__init__.py +78 -0
- google/cloud/network_security_v1beta1/types/authorization_policy.py +430 -0
- google/cloud/network_security_v1beta1/types/client_tls_policy.py +270 -0
- google/cloud/network_security_v1beta1/types/common.py +93 -0
- google/cloud/network_security_v1beta1/types/network_security.py +24 -0
- google/cloud/network_security_v1beta1/types/server_tls_policy.py +295 -0
- google/cloud/network_security_v1beta1/types/tls.py +153 -0
- google_cloud_network_security-0.9.17.dist-info/LICENSE +202 -0
- google_cloud_network_security-0.9.17.dist-info/METADATA +229 -0
- google_cloud_network_security-0.9.17.dist-info/RECORD +51 -0
- google_cloud_network_security-0.9.17.dist-info/WHEEL +5 -0
- google_cloud_network_security-0.9.17.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,3525 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2024 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from collections import OrderedDict
|
|
17
|
+
from http import HTTPStatus
|
|
18
|
+
import json
|
|
19
|
+
import logging as std_logging
|
|
20
|
+
import os
|
|
21
|
+
import re
|
|
22
|
+
from typing import (
|
|
23
|
+
Callable,
|
|
24
|
+
Dict,
|
|
25
|
+
Mapping,
|
|
26
|
+
MutableMapping,
|
|
27
|
+
MutableSequence,
|
|
28
|
+
Optional,
|
|
29
|
+
Sequence,
|
|
30
|
+
Tuple,
|
|
31
|
+
Type,
|
|
32
|
+
Union,
|
|
33
|
+
cast,
|
|
34
|
+
)
|
|
35
|
+
import warnings
|
|
36
|
+
|
|
37
|
+
from google.api_core import client_options as client_options_lib
|
|
38
|
+
from google.api_core import exceptions as core_exceptions
|
|
39
|
+
from google.api_core import gapic_v1
|
|
40
|
+
from google.api_core import retry as retries
|
|
41
|
+
from google.auth import credentials as ga_credentials # type: ignore
|
|
42
|
+
from google.auth.exceptions import MutualTLSChannelError # type: ignore
|
|
43
|
+
from google.auth.transport import mtls # type: ignore
|
|
44
|
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
|
45
|
+
from google.oauth2 import service_account # type: ignore
|
|
46
|
+
|
|
47
|
+
from google.cloud.network_security_v1 import gapic_version as package_version
|
|
48
|
+
|
|
49
|
+
try:
|
|
50
|
+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
|
51
|
+
except AttributeError: # pragma: NO COVER
|
|
52
|
+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
from google.api_core import client_logging # type: ignore
|
|
56
|
+
|
|
57
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
58
|
+
except ImportError: # pragma: NO COVER
|
|
59
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
60
|
+
|
|
61
|
+
_LOGGER = std_logging.getLogger(__name__)
|
|
62
|
+
|
|
63
|
+
from google.api_core import operation # type: ignore
|
|
64
|
+
from google.api_core import operation_async # type: ignore
|
|
65
|
+
from google.cloud.location import locations_pb2 # type: ignore
|
|
66
|
+
from google.iam.v1 import iam_policy_pb2 # type: ignore
|
|
67
|
+
from google.iam.v1 import policy_pb2 # type: ignore
|
|
68
|
+
from google.longrunning import operations_pb2 # type: ignore
|
|
69
|
+
from google.protobuf import empty_pb2 # type: ignore
|
|
70
|
+
from google.protobuf import field_mask_pb2 # type: ignore
|
|
71
|
+
from google.protobuf import timestamp_pb2 # type: ignore
|
|
72
|
+
|
|
73
|
+
from google.cloud.network_security_v1.services.network_security import pagers
|
|
74
|
+
from google.cloud.network_security_v1.types import (
|
|
75
|
+
authorization_policy as gcn_authorization_policy,
|
|
76
|
+
)
|
|
77
|
+
from google.cloud.network_security_v1.types import (
|
|
78
|
+
client_tls_policy as gcn_client_tls_policy,
|
|
79
|
+
)
|
|
80
|
+
from google.cloud.network_security_v1.types import (
|
|
81
|
+
server_tls_policy as gcn_server_tls_policy,
|
|
82
|
+
)
|
|
83
|
+
from google.cloud.network_security_v1.types import authorization_policy
|
|
84
|
+
from google.cloud.network_security_v1.types import client_tls_policy
|
|
85
|
+
from google.cloud.network_security_v1.types import common
|
|
86
|
+
from google.cloud.network_security_v1.types import server_tls_policy
|
|
87
|
+
from google.cloud.network_security_v1.types import tls
|
|
88
|
+
|
|
89
|
+
from .transports.base import DEFAULT_CLIENT_INFO, NetworkSecurityTransport
|
|
90
|
+
from .transports.grpc import NetworkSecurityGrpcTransport
|
|
91
|
+
from .transports.grpc_asyncio import NetworkSecurityGrpcAsyncIOTransport
|
|
92
|
+
from .transports.rest import NetworkSecurityRestTransport
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class NetworkSecurityClientMeta(type):
|
|
96
|
+
"""Metaclass for the NetworkSecurity client.
|
|
97
|
+
|
|
98
|
+
This provides class-level methods for building and retrieving
|
|
99
|
+
support objects (e.g. transport) without polluting the client instance
|
|
100
|
+
objects.
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
_transport_registry = (
|
|
104
|
+
OrderedDict()
|
|
105
|
+
) # type: Dict[str, Type[NetworkSecurityTransport]]
|
|
106
|
+
_transport_registry["grpc"] = NetworkSecurityGrpcTransport
|
|
107
|
+
_transport_registry["grpc_asyncio"] = NetworkSecurityGrpcAsyncIOTransport
|
|
108
|
+
_transport_registry["rest"] = NetworkSecurityRestTransport
|
|
109
|
+
|
|
110
|
+
def get_transport_class(
|
|
111
|
+
cls,
|
|
112
|
+
label: Optional[str] = None,
|
|
113
|
+
) -> Type[NetworkSecurityTransport]:
|
|
114
|
+
"""Returns an appropriate transport class.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
label: The name of the desired transport. If none is
|
|
118
|
+
provided, then the first transport in the registry is used.
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
The transport class to use.
|
|
122
|
+
"""
|
|
123
|
+
# If a specific transport is requested, return that one.
|
|
124
|
+
if label:
|
|
125
|
+
return cls._transport_registry[label]
|
|
126
|
+
|
|
127
|
+
# No transport is requested; return the default (that is, the first one
|
|
128
|
+
# in the dictionary).
|
|
129
|
+
return next(iter(cls._transport_registry.values()))
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class NetworkSecurityClient(metaclass=NetworkSecurityClientMeta):
|
|
133
|
+
"""Network Security API provides resources to configure
|
|
134
|
+
authentication and authorization policies. Refer to per API
|
|
135
|
+
resource documentation for more information.
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
@staticmethod
|
|
139
|
+
def _get_default_mtls_endpoint(api_endpoint):
|
|
140
|
+
"""Converts api endpoint to mTLS endpoint.
|
|
141
|
+
|
|
142
|
+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
|
|
143
|
+
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
|
|
144
|
+
Args:
|
|
145
|
+
api_endpoint (Optional[str]): the api endpoint to convert.
|
|
146
|
+
Returns:
|
|
147
|
+
str: converted mTLS api endpoint.
|
|
148
|
+
"""
|
|
149
|
+
if not api_endpoint:
|
|
150
|
+
return api_endpoint
|
|
151
|
+
|
|
152
|
+
mtls_endpoint_re = re.compile(
|
|
153
|
+
r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
m = mtls_endpoint_re.match(api_endpoint)
|
|
157
|
+
name, mtls, sandbox, googledomain = m.groups()
|
|
158
|
+
if mtls or not googledomain:
|
|
159
|
+
return api_endpoint
|
|
160
|
+
|
|
161
|
+
if sandbox:
|
|
162
|
+
return api_endpoint.replace(
|
|
163
|
+
"sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
|
|
167
|
+
|
|
168
|
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
|
169
|
+
DEFAULT_ENDPOINT = "networksecurity.googleapis.com"
|
|
170
|
+
DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
|
|
171
|
+
DEFAULT_ENDPOINT
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
_DEFAULT_ENDPOINT_TEMPLATE = "networksecurity.{UNIVERSE_DOMAIN}"
|
|
175
|
+
_DEFAULT_UNIVERSE = "googleapis.com"
|
|
176
|
+
|
|
177
|
+
@classmethod
|
|
178
|
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
|
179
|
+
"""Creates an instance of this client using the provided credentials
|
|
180
|
+
info.
|
|
181
|
+
|
|
182
|
+
Args:
|
|
183
|
+
info (dict): The service account private key info.
|
|
184
|
+
args: Additional arguments to pass to the constructor.
|
|
185
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
NetworkSecurityClient: The constructed client.
|
|
189
|
+
"""
|
|
190
|
+
credentials = service_account.Credentials.from_service_account_info(info)
|
|
191
|
+
kwargs["credentials"] = credentials
|
|
192
|
+
return cls(*args, **kwargs)
|
|
193
|
+
|
|
194
|
+
@classmethod
|
|
195
|
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
|
196
|
+
"""Creates an instance of this client using the provided credentials
|
|
197
|
+
file.
|
|
198
|
+
|
|
199
|
+
Args:
|
|
200
|
+
filename (str): The path to the service account private key json
|
|
201
|
+
file.
|
|
202
|
+
args: Additional arguments to pass to the constructor.
|
|
203
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
204
|
+
|
|
205
|
+
Returns:
|
|
206
|
+
NetworkSecurityClient: The constructed client.
|
|
207
|
+
"""
|
|
208
|
+
credentials = service_account.Credentials.from_service_account_file(filename)
|
|
209
|
+
kwargs["credentials"] = credentials
|
|
210
|
+
return cls(*args, **kwargs)
|
|
211
|
+
|
|
212
|
+
from_service_account_json = from_service_account_file
|
|
213
|
+
|
|
214
|
+
@property
|
|
215
|
+
def transport(self) -> NetworkSecurityTransport:
|
|
216
|
+
"""Returns the transport used by the client instance.
|
|
217
|
+
|
|
218
|
+
Returns:
|
|
219
|
+
NetworkSecurityTransport: The transport used by the client
|
|
220
|
+
instance.
|
|
221
|
+
"""
|
|
222
|
+
return self._transport
|
|
223
|
+
|
|
224
|
+
@staticmethod
|
|
225
|
+
def authorization_policy_path(
|
|
226
|
+
project: str,
|
|
227
|
+
location: str,
|
|
228
|
+
authorization_policy: str,
|
|
229
|
+
) -> str:
|
|
230
|
+
"""Returns a fully-qualified authorization_policy string."""
|
|
231
|
+
return "projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}".format(
|
|
232
|
+
project=project,
|
|
233
|
+
location=location,
|
|
234
|
+
authorization_policy=authorization_policy,
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
@staticmethod
|
|
238
|
+
def parse_authorization_policy_path(path: str) -> Dict[str, str]:
|
|
239
|
+
"""Parses a authorization_policy path into its component segments."""
|
|
240
|
+
m = re.match(
|
|
241
|
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/authorizationPolicies/(?P<authorization_policy>.+?)$",
|
|
242
|
+
path,
|
|
243
|
+
)
|
|
244
|
+
return m.groupdict() if m else {}
|
|
245
|
+
|
|
246
|
+
@staticmethod
|
|
247
|
+
def client_tls_policy_path(
|
|
248
|
+
project: str,
|
|
249
|
+
location: str,
|
|
250
|
+
client_tls_policy: str,
|
|
251
|
+
) -> str:
|
|
252
|
+
"""Returns a fully-qualified client_tls_policy string."""
|
|
253
|
+
return "projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy}".format(
|
|
254
|
+
project=project,
|
|
255
|
+
location=location,
|
|
256
|
+
client_tls_policy=client_tls_policy,
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
@staticmethod
|
|
260
|
+
def parse_client_tls_policy_path(path: str) -> Dict[str, str]:
|
|
261
|
+
"""Parses a client_tls_policy path into its component segments."""
|
|
262
|
+
m = re.match(
|
|
263
|
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/clientTlsPolicies/(?P<client_tls_policy>.+?)$",
|
|
264
|
+
path,
|
|
265
|
+
)
|
|
266
|
+
return m.groupdict() if m else {}
|
|
267
|
+
|
|
268
|
+
@staticmethod
|
|
269
|
+
def server_tls_policy_path(
|
|
270
|
+
project: str,
|
|
271
|
+
location: str,
|
|
272
|
+
server_tls_policy: str,
|
|
273
|
+
) -> str:
|
|
274
|
+
"""Returns a fully-qualified server_tls_policy string."""
|
|
275
|
+
return "projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy}".format(
|
|
276
|
+
project=project,
|
|
277
|
+
location=location,
|
|
278
|
+
server_tls_policy=server_tls_policy,
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
@staticmethod
|
|
282
|
+
def parse_server_tls_policy_path(path: str) -> Dict[str, str]:
|
|
283
|
+
"""Parses a server_tls_policy path into its component segments."""
|
|
284
|
+
m = re.match(
|
|
285
|
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/serverTlsPolicies/(?P<server_tls_policy>.+?)$",
|
|
286
|
+
path,
|
|
287
|
+
)
|
|
288
|
+
return m.groupdict() if m else {}
|
|
289
|
+
|
|
290
|
+
@staticmethod
|
|
291
|
+
def common_billing_account_path(
|
|
292
|
+
billing_account: str,
|
|
293
|
+
) -> str:
|
|
294
|
+
"""Returns a fully-qualified billing_account string."""
|
|
295
|
+
return "billingAccounts/{billing_account}".format(
|
|
296
|
+
billing_account=billing_account,
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
@staticmethod
|
|
300
|
+
def parse_common_billing_account_path(path: str) -> Dict[str, str]:
|
|
301
|
+
"""Parse a billing_account path into its component segments."""
|
|
302
|
+
m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
|
|
303
|
+
return m.groupdict() if m else {}
|
|
304
|
+
|
|
305
|
+
@staticmethod
|
|
306
|
+
def common_folder_path(
|
|
307
|
+
folder: str,
|
|
308
|
+
) -> str:
|
|
309
|
+
"""Returns a fully-qualified folder string."""
|
|
310
|
+
return "folders/{folder}".format(
|
|
311
|
+
folder=folder,
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
@staticmethod
|
|
315
|
+
def parse_common_folder_path(path: str) -> Dict[str, str]:
|
|
316
|
+
"""Parse a folder path into its component segments."""
|
|
317
|
+
m = re.match(r"^folders/(?P<folder>.+?)$", path)
|
|
318
|
+
return m.groupdict() if m else {}
|
|
319
|
+
|
|
320
|
+
@staticmethod
|
|
321
|
+
def common_organization_path(
|
|
322
|
+
organization: str,
|
|
323
|
+
) -> str:
|
|
324
|
+
"""Returns a fully-qualified organization string."""
|
|
325
|
+
return "organizations/{organization}".format(
|
|
326
|
+
organization=organization,
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
@staticmethod
|
|
330
|
+
def parse_common_organization_path(path: str) -> Dict[str, str]:
|
|
331
|
+
"""Parse a organization path into its component segments."""
|
|
332
|
+
m = re.match(r"^organizations/(?P<organization>.+?)$", path)
|
|
333
|
+
return m.groupdict() if m else {}
|
|
334
|
+
|
|
335
|
+
@staticmethod
|
|
336
|
+
def common_project_path(
|
|
337
|
+
project: str,
|
|
338
|
+
) -> str:
|
|
339
|
+
"""Returns a fully-qualified project string."""
|
|
340
|
+
return "projects/{project}".format(
|
|
341
|
+
project=project,
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
@staticmethod
|
|
345
|
+
def parse_common_project_path(path: str) -> Dict[str, str]:
|
|
346
|
+
"""Parse a project path into its component segments."""
|
|
347
|
+
m = re.match(r"^projects/(?P<project>.+?)$", path)
|
|
348
|
+
return m.groupdict() if m else {}
|
|
349
|
+
|
|
350
|
+
@staticmethod
|
|
351
|
+
def common_location_path(
|
|
352
|
+
project: str,
|
|
353
|
+
location: str,
|
|
354
|
+
) -> str:
|
|
355
|
+
"""Returns a fully-qualified location string."""
|
|
356
|
+
return "projects/{project}/locations/{location}".format(
|
|
357
|
+
project=project,
|
|
358
|
+
location=location,
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
@staticmethod
|
|
362
|
+
def parse_common_location_path(path: str) -> Dict[str, str]:
|
|
363
|
+
"""Parse a location path into its component segments."""
|
|
364
|
+
m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
|
|
365
|
+
return m.groupdict() if m else {}
|
|
366
|
+
|
|
367
|
+
@classmethod
|
|
368
|
+
def get_mtls_endpoint_and_cert_source(
|
|
369
|
+
cls, client_options: Optional[client_options_lib.ClientOptions] = None
|
|
370
|
+
):
|
|
371
|
+
"""Deprecated. Return the API endpoint and client cert source for mutual TLS.
|
|
372
|
+
|
|
373
|
+
The client cert source is determined in the following order:
|
|
374
|
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
|
375
|
+
client cert source is None.
|
|
376
|
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
|
377
|
+
default client cert source exists, use the default one; otherwise the client cert
|
|
378
|
+
source is None.
|
|
379
|
+
|
|
380
|
+
The API endpoint is determined in the following order:
|
|
381
|
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
|
382
|
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
|
383
|
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
|
384
|
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
|
385
|
+
use the default API endpoint.
|
|
386
|
+
|
|
387
|
+
More details can be found at https://google.aip.dev/auth/4114.
|
|
388
|
+
|
|
389
|
+
Args:
|
|
390
|
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
|
391
|
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
|
392
|
+
in this method.
|
|
393
|
+
|
|
394
|
+
Returns:
|
|
395
|
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
|
396
|
+
client cert source to use.
|
|
397
|
+
|
|
398
|
+
Raises:
|
|
399
|
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
|
400
|
+
"""
|
|
401
|
+
|
|
402
|
+
warnings.warn(
|
|
403
|
+
"get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
|
|
404
|
+
DeprecationWarning,
|
|
405
|
+
)
|
|
406
|
+
if client_options is None:
|
|
407
|
+
client_options = client_options_lib.ClientOptions()
|
|
408
|
+
use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
|
|
409
|
+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
|
|
410
|
+
if use_client_cert not in ("true", "false"):
|
|
411
|
+
raise ValueError(
|
|
412
|
+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
|
|
413
|
+
)
|
|
414
|
+
if use_mtls_endpoint not in ("auto", "never", "always"):
|
|
415
|
+
raise MutualTLSChannelError(
|
|
416
|
+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
# Figure out the client cert source to use.
|
|
420
|
+
client_cert_source = None
|
|
421
|
+
if use_client_cert == "true":
|
|
422
|
+
if client_options.client_cert_source:
|
|
423
|
+
client_cert_source = client_options.client_cert_source
|
|
424
|
+
elif mtls.has_default_client_cert_source():
|
|
425
|
+
client_cert_source = mtls.default_client_cert_source()
|
|
426
|
+
|
|
427
|
+
# Figure out which api endpoint to use.
|
|
428
|
+
if client_options.api_endpoint is not None:
|
|
429
|
+
api_endpoint = client_options.api_endpoint
|
|
430
|
+
elif use_mtls_endpoint == "always" or (
|
|
431
|
+
use_mtls_endpoint == "auto" and client_cert_source
|
|
432
|
+
):
|
|
433
|
+
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
|
|
434
|
+
else:
|
|
435
|
+
api_endpoint = cls.DEFAULT_ENDPOINT
|
|
436
|
+
|
|
437
|
+
return api_endpoint, client_cert_source
|
|
438
|
+
|
|
439
|
+
@staticmethod
|
|
440
|
+
def _read_environment_variables():
|
|
441
|
+
"""Returns the environment variables used by the client.
|
|
442
|
+
|
|
443
|
+
Returns:
|
|
444
|
+
Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
|
|
445
|
+
GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
|
|
446
|
+
|
|
447
|
+
Raises:
|
|
448
|
+
ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
|
|
449
|
+
any of ["true", "false"].
|
|
450
|
+
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
|
|
451
|
+
is not any of ["auto", "never", "always"].
|
|
452
|
+
"""
|
|
453
|
+
use_client_cert = os.getenv(
|
|
454
|
+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
|
|
455
|
+
).lower()
|
|
456
|
+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
|
|
457
|
+
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
|
|
458
|
+
if use_client_cert not in ("true", "false"):
|
|
459
|
+
raise ValueError(
|
|
460
|
+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
|
|
461
|
+
)
|
|
462
|
+
if use_mtls_endpoint not in ("auto", "never", "always"):
|
|
463
|
+
raise MutualTLSChannelError(
|
|
464
|
+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
|
465
|
+
)
|
|
466
|
+
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
|
|
467
|
+
|
|
468
|
+
@staticmethod
|
|
469
|
+
def _get_client_cert_source(provided_cert_source, use_cert_flag):
|
|
470
|
+
"""Return the client cert source to be used by the client.
|
|
471
|
+
|
|
472
|
+
Args:
|
|
473
|
+
provided_cert_source (bytes): The client certificate source provided.
|
|
474
|
+
use_cert_flag (bool): A flag indicating whether to use the client certificate.
|
|
475
|
+
|
|
476
|
+
Returns:
|
|
477
|
+
bytes or None: The client cert source to be used by the client.
|
|
478
|
+
"""
|
|
479
|
+
client_cert_source = None
|
|
480
|
+
if use_cert_flag:
|
|
481
|
+
if provided_cert_source:
|
|
482
|
+
client_cert_source = provided_cert_source
|
|
483
|
+
elif mtls.has_default_client_cert_source():
|
|
484
|
+
client_cert_source = mtls.default_client_cert_source()
|
|
485
|
+
return client_cert_source
|
|
486
|
+
|
|
487
|
+
@staticmethod
|
|
488
|
+
def _get_api_endpoint(
|
|
489
|
+
api_override, client_cert_source, universe_domain, use_mtls_endpoint
|
|
490
|
+
):
|
|
491
|
+
"""Return the API endpoint used by the client.
|
|
492
|
+
|
|
493
|
+
Args:
|
|
494
|
+
api_override (str): The API endpoint override. If specified, this is always
|
|
495
|
+
the return value of this function and the other arguments are not used.
|
|
496
|
+
client_cert_source (bytes): The client certificate source used by the client.
|
|
497
|
+
universe_domain (str): The universe domain used by the client.
|
|
498
|
+
use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
|
|
499
|
+
Possible values are "always", "auto", or "never".
|
|
500
|
+
|
|
501
|
+
Returns:
|
|
502
|
+
str: The API endpoint to be used by the client.
|
|
503
|
+
"""
|
|
504
|
+
if api_override is not None:
|
|
505
|
+
api_endpoint = api_override
|
|
506
|
+
elif use_mtls_endpoint == "always" or (
|
|
507
|
+
use_mtls_endpoint == "auto" and client_cert_source
|
|
508
|
+
):
|
|
509
|
+
_default_universe = NetworkSecurityClient._DEFAULT_UNIVERSE
|
|
510
|
+
if universe_domain != _default_universe:
|
|
511
|
+
raise MutualTLSChannelError(
|
|
512
|
+
f"mTLS is not supported in any universe other than {_default_universe}."
|
|
513
|
+
)
|
|
514
|
+
api_endpoint = NetworkSecurityClient.DEFAULT_MTLS_ENDPOINT
|
|
515
|
+
else:
|
|
516
|
+
api_endpoint = NetworkSecurityClient._DEFAULT_ENDPOINT_TEMPLATE.format(
|
|
517
|
+
UNIVERSE_DOMAIN=universe_domain
|
|
518
|
+
)
|
|
519
|
+
return api_endpoint
|
|
520
|
+
|
|
521
|
+
@staticmethod
|
|
522
|
+
def _get_universe_domain(
|
|
523
|
+
client_universe_domain: Optional[str], universe_domain_env: Optional[str]
|
|
524
|
+
) -> str:
|
|
525
|
+
"""Return the universe domain used by the client.
|
|
526
|
+
|
|
527
|
+
Args:
|
|
528
|
+
client_universe_domain (Optional[str]): The universe domain configured via the client options.
|
|
529
|
+
universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
|
|
530
|
+
|
|
531
|
+
Returns:
|
|
532
|
+
str: The universe domain to be used by the client.
|
|
533
|
+
|
|
534
|
+
Raises:
|
|
535
|
+
ValueError: If the universe domain is an empty string.
|
|
536
|
+
"""
|
|
537
|
+
universe_domain = NetworkSecurityClient._DEFAULT_UNIVERSE
|
|
538
|
+
if client_universe_domain is not None:
|
|
539
|
+
universe_domain = client_universe_domain
|
|
540
|
+
elif universe_domain_env is not None:
|
|
541
|
+
universe_domain = universe_domain_env
|
|
542
|
+
if len(universe_domain.strip()) == 0:
|
|
543
|
+
raise ValueError("Universe Domain cannot be an empty string.")
|
|
544
|
+
return universe_domain
|
|
545
|
+
|
|
546
|
+
def _validate_universe_domain(self):
|
|
547
|
+
"""Validates client's and credentials' universe domains are consistent.
|
|
548
|
+
|
|
549
|
+
Returns:
|
|
550
|
+
bool: True iff the configured universe domain is valid.
|
|
551
|
+
|
|
552
|
+
Raises:
|
|
553
|
+
ValueError: If the configured universe domain is not valid.
|
|
554
|
+
"""
|
|
555
|
+
|
|
556
|
+
# NOTE (b/349488459): universe validation is disabled until further notice.
|
|
557
|
+
return True
|
|
558
|
+
|
|
559
|
+
def _add_cred_info_for_auth_errors(
|
|
560
|
+
self, error: core_exceptions.GoogleAPICallError
|
|
561
|
+
) -> None:
|
|
562
|
+
"""Adds credential info string to error details for 401/403/404 errors.
|
|
563
|
+
|
|
564
|
+
Args:
|
|
565
|
+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
|
|
566
|
+
"""
|
|
567
|
+
if error.code not in [
|
|
568
|
+
HTTPStatus.UNAUTHORIZED,
|
|
569
|
+
HTTPStatus.FORBIDDEN,
|
|
570
|
+
HTTPStatus.NOT_FOUND,
|
|
571
|
+
]:
|
|
572
|
+
return
|
|
573
|
+
|
|
574
|
+
cred = self._transport._credentials
|
|
575
|
+
|
|
576
|
+
# get_cred_info is only available in google-auth>=2.35.0
|
|
577
|
+
if not hasattr(cred, "get_cred_info"):
|
|
578
|
+
return
|
|
579
|
+
|
|
580
|
+
# ignore the type check since pypy test fails when get_cred_info
|
|
581
|
+
# is not available
|
|
582
|
+
cred_info = cred.get_cred_info() # type: ignore
|
|
583
|
+
if cred_info and hasattr(error._details, "append"):
|
|
584
|
+
error._details.append(json.dumps(cred_info))
|
|
585
|
+
|
|
586
|
+
@property
|
|
587
|
+
def api_endpoint(self):
|
|
588
|
+
"""Return the API endpoint used by the client instance.
|
|
589
|
+
|
|
590
|
+
Returns:
|
|
591
|
+
str: The API endpoint used by the client instance.
|
|
592
|
+
"""
|
|
593
|
+
return self._api_endpoint
|
|
594
|
+
|
|
595
|
+
@property
|
|
596
|
+
def universe_domain(self) -> str:
|
|
597
|
+
"""Return the universe domain used by the client instance.
|
|
598
|
+
|
|
599
|
+
Returns:
|
|
600
|
+
str: The universe domain used by the client instance.
|
|
601
|
+
"""
|
|
602
|
+
return self._universe_domain
|
|
603
|
+
|
|
604
|
+
def __init__(
|
|
605
|
+
self,
|
|
606
|
+
*,
|
|
607
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
608
|
+
transport: Optional[
|
|
609
|
+
Union[
|
|
610
|
+
str, NetworkSecurityTransport, Callable[..., NetworkSecurityTransport]
|
|
611
|
+
]
|
|
612
|
+
] = None,
|
|
613
|
+
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
|
|
614
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
615
|
+
) -> None:
|
|
616
|
+
"""Instantiates the network security client.
|
|
617
|
+
|
|
618
|
+
Args:
|
|
619
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
620
|
+
authorization credentials to attach to requests. These
|
|
621
|
+
credentials identify the application to the service; if none
|
|
622
|
+
are specified, the client will attempt to ascertain the
|
|
623
|
+
credentials from the environment.
|
|
624
|
+
transport (Optional[Union[str,NetworkSecurityTransport,Callable[..., NetworkSecurityTransport]]]):
|
|
625
|
+
The transport to use, or a Callable that constructs and returns a new transport.
|
|
626
|
+
If a Callable is given, it will be called with the same set of initialization
|
|
627
|
+
arguments as used in the NetworkSecurityTransport constructor.
|
|
628
|
+
If set to None, a transport is chosen automatically.
|
|
629
|
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
|
630
|
+
Custom options for the client.
|
|
631
|
+
|
|
632
|
+
1. The ``api_endpoint`` property can be used to override the
|
|
633
|
+
default endpoint provided by the client when ``transport`` is
|
|
634
|
+
not explicitly provided. Only if this property is not set and
|
|
635
|
+
``transport`` was not explicitly provided, the endpoint is
|
|
636
|
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
|
637
|
+
variable, which have one of the following values:
|
|
638
|
+
"always" (always use the default mTLS endpoint), "never" (always
|
|
639
|
+
use the default regular endpoint) and "auto" (auto-switch to the
|
|
640
|
+
default mTLS endpoint if client certificate is present; this is
|
|
641
|
+
the default value).
|
|
642
|
+
|
|
643
|
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
|
644
|
+
is "true", then the ``client_cert_source`` property can be used
|
|
645
|
+
to provide a client certificate for mTLS transport. If
|
|
646
|
+
not provided, the default SSL client certificate will be used if
|
|
647
|
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
|
648
|
+
set, no client certificate will be used.
|
|
649
|
+
|
|
650
|
+
3. The ``universe_domain`` property can be used to override the
|
|
651
|
+
default "googleapis.com" universe. Note that the ``api_endpoint``
|
|
652
|
+
property still takes precedence; and ``universe_domain`` is
|
|
653
|
+
currently not supported for mTLS.
|
|
654
|
+
|
|
655
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
656
|
+
The client info used to send a user-agent string along with
|
|
657
|
+
API requests. If ``None``, then default info will be used.
|
|
658
|
+
Generally, you only need to set this if you're developing
|
|
659
|
+
your own client library.
|
|
660
|
+
|
|
661
|
+
Raises:
|
|
662
|
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
|
663
|
+
creation failed for any reason.
|
|
664
|
+
"""
|
|
665
|
+
self._client_options = client_options
|
|
666
|
+
if isinstance(self._client_options, dict):
|
|
667
|
+
self._client_options = client_options_lib.from_dict(self._client_options)
|
|
668
|
+
if self._client_options is None:
|
|
669
|
+
self._client_options = client_options_lib.ClientOptions()
|
|
670
|
+
self._client_options = cast(
|
|
671
|
+
client_options_lib.ClientOptions, self._client_options
|
|
672
|
+
)
|
|
673
|
+
|
|
674
|
+
universe_domain_opt = getattr(self._client_options, "universe_domain", None)
|
|
675
|
+
|
|
676
|
+
(
|
|
677
|
+
self._use_client_cert,
|
|
678
|
+
self._use_mtls_endpoint,
|
|
679
|
+
self._universe_domain_env,
|
|
680
|
+
) = NetworkSecurityClient._read_environment_variables()
|
|
681
|
+
self._client_cert_source = NetworkSecurityClient._get_client_cert_source(
|
|
682
|
+
self._client_options.client_cert_source, self._use_client_cert
|
|
683
|
+
)
|
|
684
|
+
self._universe_domain = NetworkSecurityClient._get_universe_domain(
|
|
685
|
+
universe_domain_opt, self._universe_domain_env
|
|
686
|
+
)
|
|
687
|
+
self._api_endpoint = None # updated below, depending on `transport`
|
|
688
|
+
|
|
689
|
+
# Initialize the universe domain validation.
|
|
690
|
+
self._is_universe_domain_valid = False
|
|
691
|
+
|
|
692
|
+
if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
|
|
693
|
+
# Setup logging.
|
|
694
|
+
client_logging.initialize_logging()
|
|
695
|
+
|
|
696
|
+
api_key_value = getattr(self._client_options, "api_key", None)
|
|
697
|
+
if api_key_value and credentials:
|
|
698
|
+
raise ValueError(
|
|
699
|
+
"client_options.api_key and credentials are mutually exclusive"
|
|
700
|
+
)
|
|
701
|
+
|
|
702
|
+
# Save or instantiate the transport.
|
|
703
|
+
# Ordinarily, we provide the transport, but allowing a custom transport
|
|
704
|
+
# instance provides an extensibility point for unusual situations.
|
|
705
|
+
transport_provided = isinstance(transport, NetworkSecurityTransport)
|
|
706
|
+
if transport_provided:
|
|
707
|
+
# transport is a NetworkSecurityTransport instance.
|
|
708
|
+
if credentials or self._client_options.credentials_file or api_key_value:
|
|
709
|
+
raise ValueError(
|
|
710
|
+
"When providing a transport instance, "
|
|
711
|
+
"provide its credentials directly."
|
|
712
|
+
)
|
|
713
|
+
if self._client_options.scopes:
|
|
714
|
+
raise ValueError(
|
|
715
|
+
"When providing a transport instance, provide its scopes "
|
|
716
|
+
"directly."
|
|
717
|
+
)
|
|
718
|
+
self._transport = cast(NetworkSecurityTransport, transport)
|
|
719
|
+
self._api_endpoint = self._transport.host
|
|
720
|
+
|
|
721
|
+
self._api_endpoint = (
|
|
722
|
+
self._api_endpoint
|
|
723
|
+
or NetworkSecurityClient._get_api_endpoint(
|
|
724
|
+
self._client_options.api_endpoint,
|
|
725
|
+
self._client_cert_source,
|
|
726
|
+
self._universe_domain,
|
|
727
|
+
self._use_mtls_endpoint,
|
|
728
|
+
)
|
|
729
|
+
)
|
|
730
|
+
|
|
731
|
+
if not transport_provided:
|
|
732
|
+
import google.auth._default # type: ignore
|
|
733
|
+
|
|
734
|
+
if api_key_value and hasattr(
|
|
735
|
+
google.auth._default, "get_api_key_credentials"
|
|
736
|
+
):
|
|
737
|
+
credentials = google.auth._default.get_api_key_credentials(
|
|
738
|
+
api_key_value
|
|
739
|
+
)
|
|
740
|
+
|
|
741
|
+
transport_init: Union[
|
|
742
|
+
Type[NetworkSecurityTransport], Callable[..., NetworkSecurityTransport]
|
|
743
|
+
] = (
|
|
744
|
+
NetworkSecurityClient.get_transport_class(transport)
|
|
745
|
+
if isinstance(transport, str) or transport is None
|
|
746
|
+
else cast(Callable[..., NetworkSecurityTransport], transport)
|
|
747
|
+
)
|
|
748
|
+
# initialize with the provided callable or the passed in class
|
|
749
|
+
self._transport = transport_init(
|
|
750
|
+
credentials=credentials,
|
|
751
|
+
credentials_file=self._client_options.credentials_file,
|
|
752
|
+
host=self._api_endpoint,
|
|
753
|
+
scopes=self._client_options.scopes,
|
|
754
|
+
client_cert_source_for_mtls=self._client_cert_source,
|
|
755
|
+
quota_project_id=self._client_options.quota_project_id,
|
|
756
|
+
client_info=client_info,
|
|
757
|
+
always_use_jwt_access=True,
|
|
758
|
+
api_audience=self._client_options.api_audience,
|
|
759
|
+
)
|
|
760
|
+
|
|
761
|
+
if "async" not in str(self._transport):
|
|
762
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
763
|
+
std_logging.DEBUG
|
|
764
|
+
): # pragma: NO COVER
|
|
765
|
+
_LOGGER.debug(
|
|
766
|
+
"Created client `google.cloud.networksecurity_v1.NetworkSecurityClient`.",
|
|
767
|
+
extra={
|
|
768
|
+
"serviceName": "google.cloud.networksecurity.v1.NetworkSecurity",
|
|
769
|
+
"universeDomain": getattr(
|
|
770
|
+
self._transport._credentials, "universe_domain", ""
|
|
771
|
+
),
|
|
772
|
+
"credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
|
|
773
|
+
"credentialsInfo": getattr(
|
|
774
|
+
self.transport._credentials, "get_cred_info", lambda: None
|
|
775
|
+
)(),
|
|
776
|
+
}
|
|
777
|
+
if hasattr(self._transport, "_credentials")
|
|
778
|
+
else {
|
|
779
|
+
"serviceName": "google.cloud.networksecurity.v1.NetworkSecurity",
|
|
780
|
+
"credentialsType": None,
|
|
781
|
+
},
|
|
782
|
+
)
|
|
783
|
+
|
|
784
|
+
def list_authorization_policies(
|
|
785
|
+
self,
|
|
786
|
+
request: Optional[
|
|
787
|
+
Union[authorization_policy.ListAuthorizationPoliciesRequest, dict]
|
|
788
|
+
] = None,
|
|
789
|
+
*,
|
|
790
|
+
parent: Optional[str] = None,
|
|
791
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
792
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
793
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
794
|
+
) -> pagers.ListAuthorizationPoliciesPager:
|
|
795
|
+
r"""Lists AuthorizationPolicies in a given project and
|
|
796
|
+
location.
|
|
797
|
+
|
|
798
|
+
.. code-block:: python
|
|
799
|
+
|
|
800
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
801
|
+
# code template only.
|
|
802
|
+
# It will require modifications to work:
|
|
803
|
+
# - It may require correct/in-range values for request initialization.
|
|
804
|
+
# - It may require specifying regional endpoints when creating the service
|
|
805
|
+
# client as shown in:
|
|
806
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
807
|
+
from google.cloud import network_security_v1
|
|
808
|
+
|
|
809
|
+
def sample_list_authorization_policies():
|
|
810
|
+
# Create a client
|
|
811
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
812
|
+
|
|
813
|
+
# Initialize request argument(s)
|
|
814
|
+
request = network_security_v1.ListAuthorizationPoliciesRequest(
|
|
815
|
+
parent="parent_value",
|
|
816
|
+
)
|
|
817
|
+
|
|
818
|
+
# Make the request
|
|
819
|
+
page_result = client.list_authorization_policies(request=request)
|
|
820
|
+
|
|
821
|
+
# Handle the response
|
|
822
|
+
for response in page_result:
|
|
823
|
+
print(response)
|
|
824
|
+
|
|
825
|
+
Args:
|
|
826
|
+
request (Union[google.cloud.network_security_v1.types.ListAuthorizationPoliciesRequest, dict]):
|
|
827
|
+
The request object. Request used with the
|
|
828
|
+
ListAuthorizationPolicies method.
|
|
829
|
+
parent (str):
|
|
830
|
+
Required. The project and location from which the
|
|
831
|
+
AuthorizationPolicies should be listed, specified in the
|
|
832
|
+
format ``projects/{project}/locations/{location}``.
|
|
833
|
+
|
|
834
|
+
This corresponds to the ``parent`` field
|
|
835
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
836
|
+
should not be set.
|
|
837
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
838
|
+
should be retried.
|
|
839
|
+
timeout (float): The timeout for this request.
|
|
840
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
841
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
842
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
843
|
+
be of type `bytes`.
|
|
844
|
+
|
|
845
|
+
Returns:
|
|
846
|
+
google.cloud.network_security_v1.services.network_security.pagers.ListAuthorizationPoliciesPager:
|
|
847
|
+
Response returned by the
|
|
848
|
+
ListAuthorizationPolicies method.
|
|
849
|
+
Iterating over this object will yield
|
|
850
|
+
results and resolve additional pages
|
|
851
|
+
automatically.
|
|
852
|
+
|
|
853
|
+
"""
|
|
854
|
+
# Create or coerce a protobuf request object.
|
|
855
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
856
|
+
# gotten any keyword arguments that map to the request.
|
|
857
|
+
flattened_params = [parent]
|
|
858
|
+
has_flattened_params = (
|
|
859
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
860
|
+
)
|
|
861
|
+
if request is not None and has_flattened_params:
|
|
862
|
+
raise ValueError(
|
|
863
|
+
"If the `request` argument is set, then none of "
|
|
864
|
+
"the individual field arguments should be set."
|
|
865
|
+
)
|
|
866
|
+
|
|
867
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
868
|
+
# there are no flattened fields), or create one.
|
|
869
|
+
if not isinstance(
|
|
870
|
+
request, authorization_policy.ListAuthorizationPoliciesRequest
|
|
871
|
+
):
|
|
872
|
+
request = authorization_policy.ListAuthorizationPoliciesRequest(request)
|
|
873
|
+
# If we have keyword arguments corresponding to fields on the
|
|
874
|
+
# request, apply these.
|
|
875
|
+
if parent is not None:
|
|
876
|
+
request.parent = parent
|
|
877
|
+
|
|
878
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
879
|
+
# and friendly error handling.
|
|
880
|
+
rpc = self._transport._wrapped_methods[
|
|
881
|
+
self._transport.list_authorization_policies
|
|
882
|
+
]
|
|
883
|
+
|
|
884
|
+
# Certain fields should be provided within the metadata header;
|
|
885
|
+
# add these here.
|
|
886
|
+
metadata = tuple(metadata) + (
|
|
887
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
888
|
+
)
|
|
889
|
+
|
|
890
|
+
# Validate the universe domain.
|
|
891
|
+
self._validate_universe_domain()
|
|
892
|
+
|
|
893
|
+
# Send the request.
|
|
894
|
+
response = rpc(
|
|
895
|
+
request,
|
|
896
|
+
retry=retry,
|
|
897
|
+
timeout=timeout,
|
|
898
|
+
metadata=metadata,
|
|
899
|
+
)
|
|
900
|
+
|
|
901
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
902
|
+
# an `__iter__` convenience method.
|
|
903
|
+
response = pagers.ListAuthorizationPoliciesPager(
|
|
904
|
+
method=rpc,
|
|
905
|
+
request=request,
|
|
906
|
+
response=response,
|
|
907
|
+
retry=retry,
|
|
908
|
+
timeout=timeout,
|
|
909
|
+
metadata=metadata,
|
|
910
|
+
)
|
|
911
|
+
|
|
912
|
+
# Done; return the response.
|
|
913
|
+
return response
|
|
914
|
+
|
|
915
|
+
def get_authorization_policy(
|
|
916
|
+
self,
|
|
917
|
+
request: Optional[
|
|
918
|
+
Union[authorization_policy.GetAuthorizationPolicyRequest, dict]
|
|
919
|
+
] = None,
|
|
920
|
+
*,
|
|
921
|
+
name: Optional[str] = None,
|
|
922
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
923
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
924
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
925
|
+
) -> authorization_policy.AuthorizationPolicy:
|
|
926
|
+
r"""Gets details of a single AuthorizationPolicy.
|
|
927
|
+
|
|
928
|
+
.. code-block:: python
|
|
929
|
+
|
|
930
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
931
|
+
# code template only.
|
|
932
|
+
# It will require modifications to work:
|
|
933
|
+
# - It may require correct/in-range values for request initialization.
|
|
934
|
+
# - It may require specifying regional endpoints when creating the service
|
|
935
|
+
# client as shown in:
|
|
936
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
937
|
+
from google.cloud import network_security_v1
|
|
938
|
+
|
|
939
|
+
def sample_get_authorization_policy():
|
|
940
|
+
# Create a client
|
|
941
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
942
|
+
|
|
943
|
+
# Initialize request argument(s)
|
|
944
|
+
request = network_security_v1.GetAuthorizationPolicyRequest(
|
|
945
|
+
name="name_value",
|
|
946
|
+
)
|
|
947
|
+
|
|
948
|
+
# Make the request
|
|
949
|
+
response = client.get_authorization_policy(request=request)
|
|
950
|
+
|
|
951
|
+
# Handle the response
|
|
952
|
+
print(response)
|
|
953
|
+
|
|
954
|
+
Args:
|
|
955
|
+
request (Union[google.cloud.network_security_v1.types.GetAuthorizationPolicyRequest, dict]):
|
|
956
|
+
The request object. Request used by the
|
|
957
|
+
GetAuthorizationPolicy method.
|
|
958
|
+
name (str):
|
|
959
|
+
Required. A name of the AuthorizationPolicy to get. Must
|
|
960
|
+
be in the format
|
|
961
|
+
``projects/{project}/locations/{location}/authorizationPolicies/*``.
|
|
962
|
+
|
|
963
|
+
This corresponds to the ``name`` field
|
|
964
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
965
|
+
should not be set.
|
|
966
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
967
|
+
should be retried.
|
|
968
|
+
timeout (float): The timeout for this request.
|
|
969
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
970
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
971
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
972
|
+
be of type `bytes`.
|
|
973
|
+
|
|
974
|
+
Returns:
|
|
975
|
+
google.cloud.network_security_v1.types.AuthorizationPolicy:
|
|
976
|
+
AuthorizationPolicy is a resource
|
|
977
|
+
that specifies how a server should
|
|
978
|
+
authorize incoming connections. This
|
|
979
|
+
resource in itself does not change the
|
|
980
|
+
configuration unless it's attached to a
|
|
981
|
+
target https proxy or endpoint config
|
|
982
|
+
selector resource.
|
|
983
|
+
|
|
984
|
+
"""
|
|
985
|
+
# Create or coerce a protobuf request object.
|
|
986
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
987
|
+
# gotten any keyword arguments that map to the request.
|
|
988
|
+
flattened_params = [name]
|
|
989
|
+
has_flattened_params = (
|
|
990
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
991
|
+
)
|
|
992
|
+
if request is not None and has_flattened_params:
|
|
993
|
+
raise ValueError(
|
|
994
|
+
"If the `request` argument is set, then none of "
|
|
995
|
+
"the individual field arguments should be set."
|
|
996
|
+
)
|
|
997
|
+
|
|
998
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
999
|
+
# there are no flattened fields), or create one.
|
|
1000
|
+
if not isinstance(request, authorization_policy.GetAuthorizationPolicyRequest):
|
|
1001
|
+
request = authorization_policy.GetAuthorizationPolicyRequest(request)
|
|
1002
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1003
|
+
# request, apply these.
|
|
1004
|
+
if name is not None:
|
|
1005
|
+
request.name = name
|
|
1006
|
+
|
|
1007
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1008
|
+
# and friendly error handling.
|
|
1009
|
+
rpc = self._transport._wrapped_methods[self._transport.get_authorization_policy]
|
|
1010
|
+
|
|
1011
|
+
# Certain fields should be provided within the metadata header;
|
|
1012
|
+
# add these here.
|
|
1013
|
+
metadata = tuple(metadata) + (
|
|
1014
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1015
|
+
)
|
|
1016
|
+
|
|
1017
|
+
# Validate the universe domain.
|
|
1018
|
+
self._validate_universe_domain()
|
|
1019
|
+
|
|
1020
|
+
# Send the request.
|
|
1021
|
+
response = rpc(
|
|
1022
|
+
request,
|
|
1023
|
+
retry=retry,
|
|
1024
|
+
timeout=timeout,
|
|
1025
|
+
metadata=metadata,
|
|
1026
|
+
)
|
|
1027
|
+
|
|
1028
|
+
# Done; return the response.
|
|
1029
|
+
return response
|
|
1030
|
+
|
|
1031
|
+
def create_authorization_policy(
|
|
1032
|
+
self,
|
|
1033
|
+
request: Optional[
|
|
1034
|
+
Union[gcn_authorization_policy.CreateAuthorizationPolicyRequest, dict]
|
|
1035
|
+
] = None,
|
|
1036
|
+
*,
|
|
1037
|
+
parent: Optional[str] = None,
|
|
1038
|
+
authorization_policy: Optional[
|
|
1039
|
+
gcn_authorization_policy.AuthorizationPolicy
|
|
1040
|
+
] = None,
|
|
1041
|
+
authorization_policy_id: Optional[str] = None,
|
|
1042
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1043
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1044
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1045
|
+
) -> operation.Operation:
|
|
1046
|
+
r"""Creates a new AuthorizationPolicy in a given project
|
|
1047
|
+
and location.
|
|
1048
|
+
|
|
1049
|
+
.. code-block:: python
|
|
1050
|
+
|
|
1051
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1052
|
+
# code template only.
|
|
1053
|
+
# It will require modifications to work:
|
|
1054
|
+
# - It may require correct/in-range values for request initialization.
|
|
1055
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1056
|
+
# client as shown in:
|
|
1057
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1058
|
+
from google.cloud import network_security_v1
|
|
1059
|
+
|
|
1060
|
+
def sample_create_authorization_policy():
|
|
1061
|
+
# Create a client
|
|
1062
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
1063
|
+
|
|
1064
|
+
# Initialize request argument(s)
|
|
1065
|
+
authorization_policy = network_security_v1.AuthorizationPolicy()
|
|
1066
|
+
authorization_policy.name = "name_value"
|
|
1067
|
+
authorization_policy.action = "DENY"
|
|
1068
|
+
|
|
1069
|
+
request = network_security_v1.CreateAuthorizationPolicyRequest(
|
|
1070
|
+
parent="parent_value",
|
|
1071
|
+
authorization_policy_id="authorization_policy_id_value",
|
|
1072
|
+
authorization_policy=authorization_policy,
|
|
1073
|
+
)
|
|
1074
|
+
|
|
1075
|
+
# Make the request
|
|
1076
|
+
operation = client.create_authorization_policy(request=request)
|
|
1077
|
+
|
|
1078
|
+
print("Waiting for operation to complete...")
|
|
1079
|
+
|
|
1080
|
+
response = operation.result()
|
|
1081
|
+
|
|
1082
|
+
# Handle the response
|
|
1083
|
+
print(response)
|
|
1084
|
+
|
|
1085
|
+
Args:
|
|
1086
|
+
request (Union[google.cloud.network_security_v1.types.CreateAuthorizationPolicyRequest, dict]):
|
|
1087
|
+
The request object. Request used by the
|
|
1088
|
+
CreateAuthorizationPolicy method.
|
|
1089
|
+
parent (str):
|
|
1090
|
+
Required. The parent resource of the
|
|
1091
|
+
AuthorizationPolicy. Must be in the format
|
|
1092
|
+
``projects/{project}/locations/{location}``.
|
|
1093
|
+
|
|
1094
|
+
This corresponds to the ``parent`` field
|
|
1095
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1096
|
+
should not be set.
|
|
1097
|
+
authorization_policy (google.cloud.network_security_v1.types.AuthorizationPolicy):
|
|
1098
|
+
Required. AuthorizationPolicy
|
|
1099
|
+
resource to be created.
|
|
1100
|
+
|
|
1101
|
+
This corresponds to the ``authorization_policy`` field
|
|
1102
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1103
|
+
should not be set.
|
|
1104
|
+
authorization_policy_id (str):
|
|
1105
|
+
Required. Short name of the AuthorizationPolicy resource
|
|
1106
|
+
to be created. This value should be 1-63 characters
|
|
1107
|
+
long, containing only letters, numbers, hyphens, and
|
|
1108
|
+
underscores, and should not start with a number. E.g.
|
|
1109
|
+
"authz_policy".
|
|
1110
|
+
|
|
1111
|
+
This corresponds to the ``authorization_policy_id`` field
|
|
1112
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1113
|
+
should not be set.
|
|
1114
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1115
|
+
should be retried.
|
|
1116
|
+
timeout (float): The timeout for this request.
|
|
1117
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1118
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1119
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1120
|
+
be of type `bytes`.
|
|
1121
|
+
|
|
1122
|
+
Returns:
|
|
1123
|
+
google.api_core.operation.Operation:
|
|
1124
|
+
An object representing a long-running operation.
|
|
1125
|
+
|
|
1126
|
+
The result type for the operation will be :class:`google.cloud.network_security_v1.types.AuthorizationPolicy` AuthorizationPolicy is a resource that specifies how a server
|
|
1127
|
+
should authorize incoming connections. This resource
|
|
1128
|
+
in itself does not change the configuration unless
|
|
1129
|
+
it's attached to a target https proxy or endpoint
|
|
1130
|
+
config selector resource.
|
|
1131
|
+
|
|
1132
|
+
"""
|
|
1133
|
+
# Create or coerce a protobuf request object.
|
|
1134
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1135
|
+
# gotten any keyword arguments that map to the request.
|
|
1136
|
+
flattened_params = [parent, authorization_policy, authorization_policy_id]
|
|
1137
|
+
has_flattened_params = (
|
|
1138
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1139
|
+
)
|
|
1140
|
+
if request is not None and has_flattened_params:
|
|
1141
|
+
raise ValueError(
|
|
1142
|
+
"If the `request` argument is set, then none of "
|
|
1143
|
+
"the individual field arguments should be set."
|
|
1144
|
+
)
|
|
1145
|
+
|
|
1146
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1147
|
+
# there are no flattened fields), or create one.
|
|
1148
|
+
if not isinstance(
|
|
1149
|
+
request, gcn_authorization_policy.CreateAuthorizationPolicyRequest
|
|
1150
|
+
):
|
|
1151
|
+
request = gcn_authorization_policy.CreateAuthorizationPolicyRequest(request)
|
|
1152
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1153
|
+
# request, apply these.
|
|
1154
|
+
if parent is not None:
|
|
1155
|
+
request.parent = parent
|
|
1156
|
+
if authorization_policy is not None:
|
|
1157
|
+
request.authorization_policy = authorization_policy
|
|
1158
|
+
if authorization_policy_id is not None:
|
|
1159
|
+
request.authorization_policy_id = authorization_policy_id
|
|
1160
|
+
|
|
1161
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1162
|
+
# and friendly error handling.
|
|
1163
|
+
rpc = self._transport._wrapped_methods[
|
|
1164
|
+
self._transport.create_authorization_policy
|
|
1165
|
+
]
|
|
1166
|
+
|
|
1167
|
+
# Certain fields should be provided within the metadata header;
|
|
1168
|
+
# add these here.
|
|
1169
|
+
metadata = tuple(metadata) + (
|
|
1170
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
1171
|
+
)
|
|
1172
|
+
|
|
1173
|
+
# Validate the universe domain.
|
|
1174
|
+
self._validate_universe_domain()
|
|
1175
|
+
|
|
1176
|
+
# Send the request.
|
|
1177
|
+
response = rpc(
|
|
1178
|
+
request,
|
|
1179
|
+
retry=retry,
|
|
1180
|
+
timeout=timeout,
|
|
1181
|
+
metadata=metadata,
|
|
1182
|
+
)
|
|
1183
|
+
|
|
1184
|
+
# Wrap the response in an operation future.
|
|
1185
|
+
response = operation.from_gapic(
|
|
1186
|
+
response,
|
|
1187
|
+
self._transport.operations_client,
|
|
1188
|
+
gcn_authorization_policy.AuthorizationPolicy,
|
|
1189
|
+
metadata_type=common.OperationMetadata,
|
|
1190
|
+
)
|
|
1191
|
+
|
|
1192
|
+
# Done; return the response.
|
|
1193
|
+
return response
|
|
1194
|
+
|
|
1195
|
+
def update_authorization_policy(
|
|
1196
|
+
self,
|
|
1197
|
+
request: Optional[
|
|
1198
|
+
Union[gcn_authorization_policy.UpdateAuthorizationPolicyRequest, dict]
|
|
1199
|
+
] = None,
|
|
1200
|
+
*,
|
|
1201
|
+
authorization_policy: Optional[
|
|
1202
|
+
gcn_authorization_policy.AuthorizationPolicy
|
|
1203
|
+
] = None,
|
|
1204
|
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
|
1205
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1206
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1207
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1208
|
+
) -> operation.Operation:
|
|
1209
|
+
r"""Updates the parameters of a single
|
|
1210
|
+
AuthorizationPolicy.
|
|
1211
|
+
|
|
1212
|
+
.. code-block:: python
|
|
1213
|
+
|
|
1214
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1215
|
+
# code template only.
|
|
1216
|
+
# It will require modifications to work:
|
|
1217
|
+
# - It may require correct/in-range values for request initialization.
|
|
1218
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1219
|
+
# client as shown in:
|
|
1220
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1221
|
+
from google.cloud import network_security_v1
|
|
1222
|
+
|
|
1223
|
+
def sample_update_authorization_policy():
|
|
1224
|
+
# Create a client
|
|
1225
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
1226
|
+
|
|
1227
|
+
# Initialize request argument(s)
|
|
1228
|
+
authorization_policy = network_security_v1.AuthorizationPolicy()
|
|
1229
|
+
authorization_policy.name = "name_value"
|
|
1230
|
+
authorization_policy.action = "DENY"
|
|
1231
|
+
|
|
1232
|
+
request = network_security_v1.UpdateAuthorizationPolicyRequest(
|
|
1233
|
+
authorization_policy=authorization_policy,
|
|
1234
|
+
)
|
|
1235
|
+
|
|
1236
|
+
# Make the request
|
|
1237
|
+
operation = client.update_authorization_policy(request=request)
|
|
1238
|
+
|
|
1239
|
+
print("Waiting for operation to complete...")
|
|
1240
|
+
|
|
1241
|
+
response = operation.result()
|
|
1242
|
+
|
|
1243
|
+
# Handle the response
|
|
1244
|
+
print(response)
|
|
1245
|
+
|
|
1246
|
+
Args:
|
|
1247
|
+
request (Union[google.cloud.network_security_v1.types.UpdateAuthorizationPolicyRequest, dict]):
|
|
1248
|
+
The request object. Request used by the
|
|
1249
|
+
UpdateAuthorizationPolicy method.
|
|
1250
|
+
authorization_policy (google.cloud.network_security_v1.types.AuthorizationPolicy):
|
|
1251
|
+
Required. Updated AuthorizationPolicy
|
|
1252
|
+
resource.
|
|
1253
|
+
|
|
1254
|
+
This corresponds to the ``authorization_policy`` field
|
|
1255
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1256
|
+
should not be set.
|
|
1257
|
+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
|
|
1258
|
+
Optional. Field mask is used to specify the fields to be
|
|
1259
|
+
overwritten in the AuthorizationPolicy resource by the
|
|
1260
|
+
update. The fields specified in the update_mask are
|
|
1261
|
+
relative to the resource, not the full request. A field
|
|
1262
|
+
will be overwritten if it is in the mask. If the user
|
|
1263
|
+
does not provide a mask then all fields will be
|
|
1264
|
+
overwritten.
|
|
1265
|
+
|
|
1266
|
+
This corresponds to the ``update_mask`` field
|
|
1267
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1268
|
+
should not be set.
|
|
1269
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1270
|
+
should be retried.
|
|
1271
|
+
timeout (float): The timeout for this request.
|
|
1272
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1273
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1274
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1275
|
+
be of type `bytes`.
|
|
1276
|
+
|
|
1277
|
+
Returns:
|
|
1278
|
+
google.api_core.operation.Operation:
|
|
1279
|
+
An object representing a long-running operation.
|
|
1280
|
+
|
|
1281
|
+
The result type for the operation will be :class:`google.cloud.network_security_v1.types.AuthorizationPolicy` AuthorizationPolicy is a resource that specifies how a server
|
|
1282
|
+
should authorize incoming connections. This resource
|
|
1283
|
+
in itself does not change the configuration unless
|
|
1284
|
+
it's attached to a target https proxy or endpoint
|
|
1285
|
+
config selector resource.
|
|
1286
|
+
|
|
1287
|
+
"""
|
|
1288
|
+
# Create or coerce a protobuf request object.
|
|
1289
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1290
|
+
# gotten any keyword arguments that map to the request.
|
|
1291
|
+
flattened_params = [authorization_policy, update_mask]
|
|
1292
|
+
has_flattened_params = (
|
|
1293
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1294
|
+
)
|
|
1295
|
+
if request is not None and has_flattened_params:
|
|
1296
|
+
raise ValueError(
|
|
1297
|
+
"If the `request` argument is set, then none of "
|
|
1298
|
+
"the individual field arguments should be set."
|
|
1299
|
+
)
|
|
1300
|
+
|
|
1301
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1302
|
+
# there are no flattened fields), or create one.
|
|
1303
|
+
if not isinstance(
|
|
1304
|
+
request, gcn_authorization_policy.UpdateAuthorizationPolicyRequest
|
|
1305
|
+
):
|
|
1306
|
+
request = gcn_authorization_policy.UpdateAuthorizationPolicyRequest(request)
|
|
1307
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1308
|
+
# request, apply these.
|
|
1309
|
+
if authorization_policy is not None:
|
|
1310
|
+
request.authorization_policy = authorization_policy
|
|
1311
|
+
if update_mask is not None:
|
|
1312
|
+
request.update_mask = update_mask
|
|
1313
|
+
|
|
1314
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1315
|
+
# and friendly error handling.
|
|
1316
|
+
rpc = self._transport._wrapped_methods[
|
|
1317
|
+
self._transport.update_authorization_policy
|
|
1318
|
+
]
|
|
1319
|
+
|
|
1320
|
+
# Certain fields should be provided within the metadata header;
|
|
1321
|
+
# add these here.
|
|
1322
|
+
metadata = tuple(metadata) + (
|
|
1323
|
+
gapic_v1.routing_header.to_grpc_metadata(
|
|
1324
|
+
(("authorization_policy.name", request.authorization_policy.name),)
|
|
1325
|
+
),
|
|
1326
|
+
)
|
|
1327
|
+
|
|
1328
|
+
# Validate the universe domain.
|
|
1329
|
+
self._validate_universe_domain()
|
|
1330
|
+
|
|
1331
|
+
# Send the request.
|
|
1332
|
+
response = rpc(
|
|
1333
|
+
request,
|
|
1334
|
+
retry=retry,
|
|
1335
|
+
timeout=timeout,
|
|
1336
|
+
metadata=metadata,
|
|
1337
|
+
)
|
|
1338
|
+
|
|
1339
|
+
# Wrap the response in an operation future.
|
|
1340
|
+
response = operation.from_gapic(
|
|
1341
|
+
response,
|
|
1342
|
+
self._transport.operations_client,
|
|
1343
|
+
gcn_authorization_policy.AuthorizationPolicy,
|
|
1344
|
+
metadata_type=common.OperationMetadata,
|
|
1345
|
+
)
|
|
1346
|
+
|
|
1347
|
+
# Done; return the response.
|
|
1348
|
+
return response
|
|
1349
|
+
|
|
1350
|
+
def delete_authorization_policy(
|
|
1351
|
+
self,
|
|
1352
|
+
request: Optional[
|
|
1353
|
+
Union[authorization_policy.DeleteAuthorizationPolicyRequest, dict]
|
|
1354
|
+
] = None,
|
|
1355
|
+
*,
|
|
1356
|
+
name: Optional[str] = None,
|
|
1357
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1358
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1359
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1360
|
+
) -> operation.Operation:
|
|
1361
|
+
r"""Deletes a single AuthorizationPolicy.
|
|
1362
|
+
|
|
1363
|
+
.. code-block:: python
|
|
1364
|
+
|
|
1365
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1366
|
+
# code template only.
|
|
1367
|
+
# It will require modifications to work:
|
|
1368
|
+
# - It may require correct/in-range values for request initialization.
|
|
1369
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1370
|
+
# client as shown in:
|
|
1371
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1372
|
+
from google.cloud import network_security_v1
|
|
1373
|
+
|
|
1374
|
+
def sample_delete_authorization_policy():
|
|
1375
|
+
# Create a client
|
|
1376
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
1377
|
+
|
|
1378
|
+
# Initialize request argument(s)
|
|
1379
|
+
request = network_security_v1.DeleteAuthorizationPolicyRequest(
|
|
1380
|
+
name="name_value",
|
|
1381
|
+
)
|
|
1382
|
+
|
|
1383
|
+
# Make the request
|
|
1384
|
+
operation = client.delete_authorization_policy(request=request)
|
|
1385
|
+
|
|
1386
|
+
print("Waiting for operation to complete...")
|
|
1387
|
+
|
|
1388
|
+
response = operation.result()
|
|
1389
|
+
|
|
1390
|
+
# Handle the response
|
|
1391
|
+
print(response)
|
|
1392
|
+
|
|
1393
|
+
Args:
|
|
1394
|
+
request (Union[google.cloud.network_security_v1.types.DeleteAuthorizationPolicyRequest, dict]):
|
|
1395
|
+
The request object. Request used by the
|
|
1396
|
+
DeleteAuthorizationPolicy method.
|
|
1397
|
+
name (str):
|
|
1398
|
+
Required. A name of the AuthorizationPolicy to delete.
|
|
1399
|
+
Must be in the format
|
|
1400
|
+
``projects/{project}/locations/{location}/authorizationPolicies/*``.
|
|
1401
|
+
|
|
1402
|
+
This corresponds to the ``name`` field
|
|
1403
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1404
|
+
should not be set.
|
|
1405
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1406
|
+
should be retried.
|
|
1407
|
+
timeout (float): The timeout for this request.
|
|
1408
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1409
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1410
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1411
|
+
be of type `bytes`.
|
|
1412
|
+
|
|
1413
|
+
Returns:
|
|
1414
|
+
google.api_core.operation.Operation:
|
|
1415
|
+
An object representing a long-running operation.
|
|
1416
|
+
|
|
1417
|
+
The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
|
|
1418
|
+
empty messages in your APIs. A typical example is to
|
|
1419
|
+
use it as the request or the response type of an API
|
|
1420
|
+
method. For instance:
|
|
1421
|
+
|
|
1422
|
+
service Foo {
|
|
1423
|
+
rpc Bar(google.protobuf.Empty) returns
|
|
1424
|
+
(google.protobuf.Empty);
|
|
1425
|
+
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
"""
|
|
1429
|
+
# Create or coerce a protobuf request object.
|
|
1430
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1431
|
+
# gotten any keyword arguments that map to the request.
|
|
1432
|
+
flattened_params = [name]
|
|
1433
|
+
has_flattened_params = (
|
|
1434
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1435
|
+
)
|
|
1436
|
+
if request is not None and has_flattened_params:
|
|
1437
|
+
raise ValueError(
|
|
1438
|
+
"If the `request` argument is set, then none of "
|
|
1439
|
+
"the individual field arguments should be set."
|
|
1440
|
+
)
|
|
1441
|
+
|
|
1442
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1443
|
+
# there are no flattened fields), or create one.
|
|
1444
|
+
if not isinstance(
|
|
1445
|
+
request, authorization_policy.DeleteAuthorizationPolicyRequest
|
|
1446
|
+
):
|
|
1447
|
+
request = authorization_policy.DeleteAuthorizationPolicyRequest(request)
|
|
1448
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1449
|
+
# request, apply these.
|
|
1450
|
+
if name is not None:
|
|
1451
|
+
request.name = name
|
|
1452
|
+
|
|
1453
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1454
|
+
# and friendly error handling.
|
|
1455
|
+
rpc = self._transport._wrapped_methods[
|
|
1456
|
+
self._transport.delete_authorization_policy
|
|
1457
|
+
]
|
|
1458
|
+
|
|
1459
|
+
# Certain fields should be provided within the metadata header;
|
|
1460
|
+
# add these here.
|
|
1461
|
+
metadata = tuple(metadata) + (
|
|
1462
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1463
|
+
)
|
|
1464
|
+
|
|
1465
|
+
# Validate the universe domain.
|
|
1466
|
+
self._validate_universe_domain()
|
|
1467
|
+
|
|
1468
|
+
# Send the request.
|
|
1469
|
+
response = rpc(
|
|
1470
|
+
request,
|
|
1471
|
+
retry=retry,
|
|
1472
|
+
timeout=timeout,
|
|
1473
|
+
metadata=metadata,
|
|
1474
|
+
)
|
|
1475
|
+
|
|
1476
|
+
# Wrap the response in an operation future.
|
|
1477
|
+
response = operation.from_gapic(
|
|
1478
|
+
response,
|
|
1479
|
+
self._transport.operations_client,
|
|
1480
|
+
empty_pb2.Empty,
|
|
1481
|
+
metadata_type=common.OperationMetadata,
|
|
1482
|
+
)
|
|
1483
|
+
|
|
1484
|
+
# Done; return the response.
|
|
1485
|
+
return response
|
|
1486
|
+
|
|
1487
|
+
def list_server_tls_policies(
|
|
1488
|
+
self,
|
|
1489
|
+
request: Optional[
|
|
1490
|
+
Union[server_tls_policy.ListServerTlsPoliciesRequest, dict]
|
|
1491
|
+
] = None,
|
|
1492
|
+
*,
|
|
1493
|
+
parent: Optional[str] = None,
|
|
1494
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1495
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1496
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1497
|
+
) -> pagers.ListServerTlsPoliciesPager:
|
|
1498
|
+
r"""Lists ServerTlsPolicies in a given project and
|
|
1499
|
+
location.
|
|
1500
|
+
|
|
1501
|
+
.. code-block:: python
|
|
1502
|
+
|
|
1503
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1504
|
+
# code template only.
|
|
1505
|
+
# It will require modifications to work:
|
|
1506
|
+
# - It may require correct/in-range values for request initialization.
|
|
1507
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1508
|
+
# client as shown in:
|
|
1509
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1510
|
+
from google.cloud import network_security_v1
|
|
1511
|
+
|
|
1512
|
+
def sample_list_server_tls_policies():
|
|
1513
|
+
# Create a client
|
|
1514
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
1515
|
+
|
|
1516
|
+
# Initialize request argument(s)
|
|
1517
|
+
request = network_security_v1.ListServerTlsPoliciesRequest(
|
|
1518
|
+
parent="parent_value",
|
|
1519
|
+
)
|
|
1520
|
+
|
|
1521
|
+
# Make the request
|
|
1522
|
+
page_result = client.list_server_tls_policies(request=request)
|
|
1523
|
+
|
|
1524
|
+
# Handle the response
|
|
1525
|
+
for response in page_result:
|
|
1526
|
+
print(response)
|
|
1527
|
+
|
|
1528
|
+
Args:
|
|
1529
|
+
request (Union[google.cloud.network_security_v1.types.ListServerTlsPoliciesRequest, dict]):
|
|
1530
|
+
The request object. Request used by the
|
|
1531
|
+
ListServerTlsPolicies method.
|
|
1532
|
+
parent (str):
|
|
1533
|
+
Required. The project and location from which the
|
|
1534
|
+
ServerTlsPolicies should be listed, specified in the
|
|
1535
|
+
format ``projects/*/locations/{location}``.
|
|
1536
|
+
|
|
1537
|
+
This corresponds to the ``parent`` field
|
|
1538
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1539
|
+
should not be set.
|
|
1540
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1541
|
+
should be retried.
|
|
1542
|
+
timeout (float): The timeout for this request.
|
|
1543
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1544
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1545
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1546
|
+
be of type `bytes`.
|
|
1547
|
+
|
|
1548
|
+
Returns:
|
|
1549
|
+
google.cloud.network_security_v1.services.network_security.pagers.ListServerTlsPoliciesPager:
|
|
1550
|
+
Response returned by the
|
|
1551
|
+
ListServerTlsPolicies method.
|
|
1552
|
+
Iterating over this object will yield
|
|
1553
|
+
results and resolve additional pages
|
|
1554
|
+
automatically.
|
|
1555
|
+
|
|
1556
|
+
"""
|
|
1557
|
+
# Create or coerce a protobuf request object.
|
|
1558
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1559
|
+
# gotten any keyword arguments that map to the request.
|
|
1560
|
+
flattened_params = [parent]
|
|
1561
|
+
has_flattened_params = (
|
|
1562
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1563
|
+
)
|
|
1564
|
+
if request is not None and has_flattened_params:
|
|
1565
|
+
raise ValueError(
|
|
1566
|
+
"If the `request` argument is set, then none of "
|
|
1567
|
+
"the individual field arguments should be set."
|
|
1568
|
+
)
|
|
1569
|
+
|
|
1570
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1571
|
+
# there are no flattened fields), or create one.
|
|
1572
|
+
if not isinstance(request, server_tls_policy.ListServerTlsPoliciesRequest):
|
|
1573
|
+
request = server_tls_policy.ListServerTlsPoliciesRequest(request)
|
|
1574
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1575
|
+
# request, apply these.
|
|
1576
|
+
if parent is not None:
|
|
1577
|
+
request.parent = parent
|
|
1578
|
+
|
|
1579
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1580
|
+
# and friendly error handling.
|
|
1581
|
+
rpc = self._transport._wrapped_methods[self._transport.list_server_tls_policies]
|
|
1582
|
+
|
|
1583
|
+
# Certain fields should be provided within the metadata header;
|
|
1584
|
+
# add these here.
|
|
1585
|
+
metadata = tuple(metadata) + (
|
|
1586
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
1587
|
+
)
|
|
1588
|
+
|
|
1589
|
+
# Validate the universe domain.
|
|
1590
|
+
self._validate_universe_domain()
|
|
1591
|
+
|
|
1592
|
+
# Send the request.
|
|
1593
|
+
response = rpc(
|
|
1594
|
+
request,
|
|
1595
|
+
retry=retry,
|
|
1596
|
+
timeout=timeout,
|
|
1597
|
+
metadata=metadata,
|
|
1598
|
+
)
|
|
1599
|
+
|
|
1600
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
1601
|
+
# an `__iter__` convenience method.
|
|
1602
|
+
response = pagers.ListServerTlsPoliciesPager(
|
|
1603
|
+
method=rpc,
|
|
1604
|
+
request=request,
|
|
1605
|
+
response=response,
|
|
1606
|
+
retry=retry,
|
|
1607
|
+
timeout=timeout,
|
|
1608
|
+
metadata=metadata,
|
|
1609
|
+
)
|
|
1610
|
+
|
|
1611
|
+
# Done; return the response.
|
|
1612
|
+
return response
|
|
1613
|
+
|
|
1614
|
+
def get_server_tls_policy(
|
|
1615
|
+
self,
|
|
1616
|
+
request: Optional[
|
|
1617
|
+
Union[server_tls_policy.GetServerTlsPolicyRequest, dict]
|
|
1618
|
+
] = None,
|
|
1619
|
+
*,
|
|
1620
|
+
name: Optional[str] = None,
|
|
1621
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1622
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1623
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1624
|
+
) -> server_tls_policy.ServerTlsPolicy:
|
|
1625
|
+
r"""Gets details of a single ServerTlsPolicy.
|
|
1626
|
+
|
|
1627
|
+
.. code-block:: python
|
|
1628
|
+
|
|
1629
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1630
|
+
# code template only.
|
|
1631
|
+
# It will require modifications to work:
|
|
1632
|
+
# - It may require correct/in-range values for request initialization.
|
|
1633
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1634
|
+
# client as shown in:
|
|
1635
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1636
|
+
from google.cloud import network_security_v1
|
|
1637
|
+
|
|
1638
|
+
def sample_get_server_tls_policy():
|
|
1639
|
+
# Create a client
|
|
1640
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
1641
|
+
|
|
1642
|
+
# Initialize request argument(s)
|
|
1643
|
+
request = network_security_v1.GetServerTlsPolicyRequest(
|
|
1644
|
+
name="name_value",
|
|
1645
|
+
)
|
|
1646
|
+
|
|
1647
|
+
# Make the request
|
|
1648
|
+
response = client.get_server_tls_policy(request=request)
|
|
1649
|
+
|
|
1650
|
+
# Handle the response
|
|
1651
|
+
print(response)
|
|
1652
|
+
|
|
1653
|
+
Args:
|
|
1654
|
+
request (Union[google.cloud.network_security_v1.types.GetServerTlsPolicyRequest, dict]):
|
|
1655
|
+
The request object. Request used by the
|
|
1656
|
+
GetServerTlsPolicy method.
|
|
1657
|
+
name (str):
|
|
1658
|
+
Required. A name of the ServerTlsPolicy to get. Must be
|
|
1659
|
+
in the format
|
|
1660
|
+
``projects/*/locations/{location}/serverTlsPolicies/*``.
|
|
1661
|
+
|
|
1662
|
+
This corresponds to the ``name`` field
|
|
1663
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1664
|
+
should not be set.
|
|
1665
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1666
|
+
should be retried.
|
|
1667
|
+
timeout (float): The timeout for this request.
|
|
1668
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1669
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1670
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1671
|
+
be of type `bytes`.
|
|
1672
|
+
|
|
1673
|
+
Returns:
|
|
1674
|
+
google.cloud.network_security_v1.types.ServerTlsPolicy:
|
|
1675
|
+
ServerTlsPolicy is a resource that
|
|
1676
|
+
specifies how a server should
|
|
1677
|
+
authenticate incoming requests. This
|
|
1678
|
+
resource itself does not affect
|
|
1679
|
+
configuration unless it is attached to a
|
|
1680
|
+
target https proxy or endpoint config
|
|
1681
|
+
selector resource.
|
|
1682
|
+
|
|
1683
|
+
"""
|
|
1684
|
+
# Create or coerce a protobuf request object.
|
|
1685
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1686
|
+
# gotten any keyword arguments that map to the request.
|
|
1687
|
+
flattened_params = [name]
|
|
1688
|
+
has_flattened_params = (
|
|
1689
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1690
|
+
)
|
|
1691
|
+
if request is not None and has_flattened_params:
|
|
1692
|
+
raise ValueError(
|
|
1693
|
+
"If the `request` argument is set, then none of "
|
|
1694
|
+
"the individual field arguments should be set."
|
|
1695
|
+
)
|
|
1696
|
+
|
|
1697
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1698
|
+
# there are no flattened fields), or create one.
|
|
1699
|
+
if not isinstance(request, server_tls_policy.GetServerTlsPolicyRequest):
|
|
1700
|
+
request = server_tls_policy.GetServerTlsPolicyRequest(request)
|
|
1701
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1702
|
+
# request, apply these.
|
|
1703
|
+
if name is not None:
|
|
1704
|
+
request.name = name
|
|
1705
|
+
|
|
1706
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1707
|
+
# and friendly error handling.
|
|
1708
|
+
rpc = self._transport._wrapped_methods[self._transport.get_server_tls_policy]
|
|
1709
|
+
|
|
1710
|
+
# Certain fields should be provided within the metadata header;
|
|
1711
|
+
# add these here.
|
|
1712
|
+
metadata = tuple(metadata) + (
|
|
1713
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1714
|
+
)
|
|
1715
|
+
|
|
1716
|
+
# Validate the universe domain.
|
|
1717
|
+
self._validate_universe_domain()
|
|
1718
|
+
|
|
1719
|
+
# Send the request.
|
|
1720
|
+
response = rpc(
|
|
1721
|
+
request,
|
|
1722
|
+
retry=retry,
|
|
1723
|
+
timeout=timeout,
|
|
1724
|
+
metadata=metadata,
|
|
1725
|
+
)
|
|
1726
|
+
|
|
1727
|
+
# Done; return the response.
|
|
1728
|
+
return response
|
|
1729
|
+
|
|
1730
|
+
def create_server_tls_policy(
|
|
1731
|
+
self,
|
|
1732
|
+
request: Optional[
|
|
1733
|
+
Union[gcn_server_tls_policy.CreateServerTlsPolicyRequest, dict]
|
|
1734
|
+
] = None,
|
|
1735
|
+
*,
|
|
1736
|
+
parent: Optional[str] = None,
|
|
1737
|
+
server_tls_policy: Optional[gcn_server_tls_policy.ServerTlsPolicy] = None,
|
|
1738
|
+
server_tls_policy_id: Optional[str] = None,
|
|
1739
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1740
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1741
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1742
|
+
) -> operation.Operation:
|
|
1743
|
+
r"""Creates a new ServerTlsPolicy in a given project and
|
|
1744
|
+
location.
|
|
1745
|
+
|
|
1746
|
+
.. code-block:: python
|
|
1747
|
+
|
|
1748
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1749
|
+
# code template only.
|
|
1750
|
+
# It will require modifications to work:
|
|
1751
|
+
# - It may require correct/in-range values for request initialization.
|
|
1752
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1753
|
+
# client as shown in:
|
|
1754
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1755
|
+
from google.cloud import network_security_v1
|
|
1756
|
+
|
|
1757
|
+
def sample_create_server_tls_policy():
|
|
1758
|
+
# Create a client
|
|
1759
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
1760
|
+
|
|
1761
|
+
# Initialize request argument(s)
|
|
1762
|
+
server_tls_policy = network_security_v1.ServerTlsPolicy()
|
|
1763
|
+
server_tls_policy.name = "name_value"
|
|
1764
|
+
|
|
1765
|
+
request = network_security_v1.CreateServerTlsPolicyRequest(
|
|
1766
|
+
parent="parent_value",
|
|
1767
|
+
server_tls_policy_id="server_tls_policy_id_value",
|
|
1768
|
+
server_tls_policy=server_tls_policy,
|
|
1769
|
+
)
|
|
1770
|
+
|
|
1771
|
+
# Make the request
|
|
1772
|
+
operation = client.create_server_tls_policy(request=request)
|
|
1773
|
+
|
|
1774
|
+
print("Waiting for operation to complete...")
|
|
1775
|
+
|
|
1776
|
+
response = operation.result()
|
|
1777
|
+
|
|
1778
|
+
# Handle the response
|
|
1779
|
+
print(response)
|
|
1780
|
+
|
|
1781
|
+
Args:
|
|
1782
|
+
request (Union[google.cloud.network_security_v1.types.CreateServerTlsPolicyRequest, dict]):
|
|
1783
|
+
The request object. Request used by the
|
|
1784
|
+
CreateServerTlsPolicy method.
|
|
1785
|
+
parent (str):
|
|
1786
|
+
Required. The parent resource of the ServerTlsPolicy.
|
|
1787
|
+
Must be in the format
|
|
1788
|
+
``projects/*/locations/{location}``.
|
|
1789
|
+
|
|
1790
|
+
This corresponds to the ``parent`` field
|
|
1791
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1792
|
+
should not be set.
|
|
1793
|
+
server_tls_policy (google.cloud.network_security_v1.types.ServerTlsPolicy):
|
|
1794
|
+
Required. ServerTlsPolicy resource to
|
|
1795
|
+
be created.
|
|
1796
|
+
|
|
1797
|
+
This corresponds to the ``server_tls_policy`` field
|
|
1798
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1799
|
+
should not be set.
|
|
1800
|
+
server_tls_policy_id (str):
|
|
1801
|
+
Required. Short name of the ServerTlsPolicy resource to
|
|
1802
|
+
be created. This value should be 1-63 characters long,
|
|
1803
|
+
containing only letters, numbers, hyphens, and
|
|
1804
|
+
underscores, and should not start with a number. E.g.
|
|
1805
|
+
"server_mtls_policy".
|
|
1806
|
+
|
|
1807
|
+
This corresponds to the ``server_tls_policy_id`` field
|
|
1808
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1809
|
+
should not be set.
|
|
1810
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1811
|
+
should be retried.
|
|
1812
|
+
timeout (float): The timeout for this request.
|
|
1813
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1814
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1815
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1816
|
+
be of type `bytes`.
|
|
1817
|
+
|
|
1818
|
+
Returns:
|
|
1819
|
+
google.api_core.operation.Operation:
|
|
1820
|
+
An object representing a long-running operation.
|
|
1821
|
+
|
|
1822
|
+
The result type for the operation will be :class:`google.cloud.network_security_v1.types.ServerTlsPolicy` ServerTlsPolicy is a resource that specifies how a server should authenticate
|
|
1823
|
+
incoming requests. This resource itself does not
|
|
1824
|
+
affect configuration unless it is attached to a
|
|
1825
|
+
target https proxy or endpoint config selector
|
|
1826
|
+
resource.
|
|
1827
|
+
|
|
1828
|
+
"""
|
|
1829
|
+
# Create or coerce a protobuf request object.
|
|
1830
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1831
|
+
# gotten any keyword arguments that map to the request.
|
|
1832
|
+
flattened_params = [parent, server_tls_policy, server_tls_policy_id]
|
|
1833
|
+
has_flattened_params = (
|
|
1834
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1835
|
+
)
|
|
1836
|
+
if request is not None and has_flattened_params:
|
|
1837
|
+
raise ValueError(
|
|
1838
|
+
"If the `request` argument is set, then none of "
|
|
1839
|
+
"the individual field arguments should be set."
|
|
1840
|
+
)
|
|
1841
|
+
|
|
1842
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1843
|
+
# there are no flattened fields), or create one.
|
|
1844
|
+
if not isinstance(request, gcn_server_tls_policy.CreateServerTlsPolicyRequest):
|
|
1845
|
+
request = gcn_server_tls_policy.CreateServerTlsPolicyRequest(request)
|
|
1846
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1847
|
+
# request, apply these.
|
|
1848
|
+
if parent is not None:
|
|
1849
|
+
request.parent = parent
|
|
1850
|
+
if server_tls_policy is not None:
|
|
1851
|
+
request.server_tls_policy = server_tls_policy
|
|
1852
|
+
if server_tls_policy_id is not None:
|
|
1853
|
+
request.server_tls_policy_id = server_tls_policy_id
|
|
1854
|
+
|
|
1855
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1856
|
+
# and friendly error handling.
|
|
1857
|
+
rpc = self._transport._wrapped_methods[self._transport.create_server_tls_policy]
|
|
1858
|
+
|
|
1859
|
+
# Certain fields should be provided within the metadata header;
|
|
1860
|
+
# add these here.
|
|
1861
|
+
metadata = tuple(metadata) + (
|
|
1862
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
1863
|
+
)
|
|
1864
|
+
|
|
1865
|
+
# Validate the universe domain.
|
|
1866
|
+
self._validate_universe_domain()
|
|
1867
|
+
|
|
1868
|
+
# Send the request.
|
|
1869
|
+
response = rpc(
|
|
1870
|
+
request,
|
|
1871
|
+
retry=retry,
|
|
1872
|
+
timeout=timeout,
|
|
1873
|
+
metadata=metadata,
|
|
1874
|
+
)
|
|
1875
|
+
|
|
1876
|
+
# Wrap the response in an operation future.
|
|
1877
|
+
response = operation.from_gapic(
|
|
1878
|
+
response,
|
|
1879
|
+
self._transport.operations_client,
|
|
1880
|
+
gcn_server_tls_policy.ServerTlsPolicy,
|
|
1881
|
+
metadata_type=common.OperationMetadata,
|
|
1882
|
+
)
|
|
1883
|
+
|
|
1884
|
+
# Done; return the response.
|
|
1885
|
+
return response
|
|
1886
|
+
|
|
1887
|
+
def update_server_tls_policy(
|
|
1888
|
+
self,
|
|
1889
|
+
request: Optional[
|
|
1890
|
+
Union[gcn_server_tls_policy.UpdateServerTlsPolicyRequest, dict]
|
|
1891
|
+
] = None,
|
|
1892
|
+
*,
|
|
1893
|
+
server_tls_policy: Optional[gcn_server_tls_policy.ServerTlsPolicy] = None,
|
|
1894
|
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
|
1895
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1896
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1897
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1898
|
+
) -> operation.Operation:
|
|
1899
|
+
r"""Updates the parameters of a single ServerTlsPolicy.
|
|
1900
|
+
|
|
1901
|
+
.. code-block:: python
|
|
1902
|
+
|
|
1903
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1904
|
+
# code template only.
|
|
1905
|
+
# It will require modifications to work:
|
|
1906
|
+
# - It may require correct/in-range values for request initialization.
|
|
1907
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1908
|
+
# client as shown in:
|
|
1909
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1910
|
+
from google.cloud import network_security_v1
|
|
1911
|
+
|
|
1912
|
+
def sample_update_server_tls_policy():
|
|
1913
|
+
# Create a client
|
|
1914
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
1915
|
+
|
|
1916
|
+
# Initialize request argument(s)
|
|
1917
|
+
server_tls_policy = network_security_v1.ServerTlsPolicy()
|
|
1918
|
+
server_tls_policy.name = "name_value"
|
|
1919
|
+
|
|
1920
|
+
request = network_security_v1.UpdateServerTlsPolicyRequest(
|
|
1921
|
+
server_tls_policy=server_tls_policy,
|
|
1922
|
+
)
|
|
1923
|
+
|
|
1924
|
+
# Make the request
|
|
1925
|
+
operation = client.update_server_tls_policy(request=request)
|
|
1926
|
+
|
|
1927
|
+
print("Waiting for operation to complete...")
|
|
1928
|
+
|
|
1929
|
+
response = operation.result()
|
|
1930
|
+
|
|
1931
|
+
# Handle the response
|
|
1932
|
+
print(response)
|
|
1933
|
+
|
|
1934
|
+
Args:
|
|
1935
|
+
request (Union[google.cloud.network_security_v1.types.UpdateServerTlsPolicyRequest, dict]):
|
|
1936
|
+
The request object. Request used by UpdateServerTlsPolicy
|
|
1937
|
+
method.
|
|
1938
|
+
server_tls_policy (google.cloud.network_security_v1.types.ServerTlsPolicy):
|
|
1939
|
+
Required. Updated ServerTlsPolicy
|
|
1940
|
+
resource.
|
|
1941
|
+
|
|
1942
|
+
This corresponds to the ``server_tls_policy`` field
|
|
1943
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1944
|
+
should not be set.
|
|
1945
|
+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
|
|
1946
|
+
Optional. Field mask is used to specify the fields to be
|
|
1947
|
+
overwritten in the ServerTlsPolicy resource by the
|
|
1948
|
+
update. The fields specified in the update_mask are
|
|
1949
|
+
relative to the resource, not the full request. A field
|
|
1950
|
+
will be overwritten if it is in the mask. If the user
|
|
1951
|
+
does not provide a mask then all fields will be
|
|
1952
|
+
overwritten.
|
|
1953
|
+
|
|
1954
|
+
This corresponds to the ``update_mask`` field
|
|
1955
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1956
|
+
should not be set.
|
|
1957
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1958
|
+
should be retried.
|
|
1959
|
+
timeout (float): The timeout for this request.
|
|
1960
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1961
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1962
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1963
|
+
be of type `bytes`.
|
|
1964
|
+
|
|
1965
|
+
Returns:
|
|
1966
|
+
google.api_core.operation.Operation:
|
|
1967
|
+
An object representing a long-running operation.
|
|
1968
|
+
|
|
1969
|
+
The result type for the operation will be :class:`google.cloud.network_security_v1.types.ServerTlsPolicy` ServerTlsPolicy is a resource that specifies how a server should authenticate
|
|
1970
|
+
incoming requests. This resource itself does not
|
|
1971
|
+
affect configuration unless it is attached to a
|
|
1972
|
+
target https proxy or endpoint config selector
|
|
1973
|
+
resource.
|
|
1974
|
+
|
|
1975
|
+
"""
|
|
1976
|
+
# Create or coerce a protobuf request object.
|
|
1977
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1978
|
+
# gotten any keyword arguments that map to the request.
|
|
1979
|
+
flattened_params = [server_tls_policy, update_mask]
|
|
1980
|
+
has_flattened_params = (
|
|
1981
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
1982
|
+
)
|
|
1983
|
+
if request is not None and has_flattened_params:
|
|
1984
|
+
raise ValueError(
|
|
1985
|
+
"If the `request` argument is set, then none of "
|
|
1986
|
+
"the individual field arguments should be set."
|
|
1987
|
+
)
|
|
1988
|
+
|
|
1989
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1990
|
+
# there are no flattened fields), or create one.
|
|
1991
|
+
if not isinstance(request, gcn_server_tls_policy.UpdateServerTlsPolicyRequest):
|
|
1992
|
+
request = gcn_server_tls_policy.UpdateServerTlsPolicyRequest(request)
|
|
1993
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1994
|
+
# request, apply these.
|
|
1995
|
+
if server_tls_policy is not None:
|
|
1996
|
+
request.server_tls_policy = server_tls_policy
|
|
1997
|
+
if update_mask is not None:
|
|
1998
|
+
request.update_mask = update_mask
|
|
1999
|
+
|
|
2000
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2001
|
+
# and friendly error handling.
|
|
2002
|
+
rpc = self._transport._wrapped_methods[self._transport.update_server_tls_policy]
|
|
2003
|
+
|
|
2004
|
+
# Certain fields should be provided within the metadata header;
|
|
2005
|
+
# add these here.
|
|
2006
|
+
metadata = tuple(metadata) + (
|
|
2007
|
+
gapic_v1.routing_header.to_grpc_metadata(
|
|
2008
|
+
(("server_tls_policy.name", request.server_tls_policy.name),)
|
|
2009
|
+
),
|
|
2010
|
+
)
|
|
2011
|
+
|
|
2012
|
+
# Validate the universe domain.
|
|
2013
|
+
self._validate_universe_domain()
|
|
2014
|
+
|
|
2015
|
+
# Send the request.
|
|
2016
|
+
response = rpc(
|
|
2017
|
+
request,
|
|
2018
|
+
retry=retry,
|
|
2019
|
+
timeout=timeout,
|
|
2020
|
+
metadata=metadata,
|
|
2021
|
+
)
|
|
2022
|
+
|
|
2023
|
+
# Wrap the response in an operation future.
|
|
2024
|
+
response = operation.from_gapic(
|
|
2025
|
+
response,
|
|
2026
|
+
self._transport.operations_client,
|
|
2027
|
+
gcn_server_tls_policy.ServerTlsPolicy,
|
|
2028
|
+
metadata_type=common.OperationMetadata,
|
|
2029
|
+
)
|
|
2030
|
+
|
|
2031
|
+
# Done; return the response.
|
|
2032
|
+
return response
|
|
2033
|
+
|
|
2034
|
+
def delete_server_tls_policy(
|
|
2035
|
+
self,
|
|
2036
|
+
request: Optional[
|
|
2037
|
+
Union[server_tls_policy.DeleteServerTlsPolicyRequest, dict]
|
|
2038
|
+
] = None,
|
|
2039
|
+
*,
|
|
2040
|
+
name: Optional[str] = None,
|
|
2041
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2042
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2043
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2044
|
+
) -> operation.Operation:
|
|
2045
|
+
r"""Deletes a single ServerTlsPolicy.
|
|
2046
|
+
|
|
2047
|
+
.. code-block:: python
|
|
2048
|
+
|
|
2049
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2050
|
+
# code template only.
|
|
2051
|
+
# It will require modifications to work:
|
|
2052
|
+
# - It may require correct/in-range values for request initialization.
|
|
2053
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2054
|
+
# client as shown in:
|
|
2055
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2056
|
+
from google.cloud import network_security_v1
|
|
2057
|
+
|
|
2058
|
+
def sample_delete_server_tls_policy():
|
|
2059
|
+
# Create a client
|
|
2060
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
2061
|
+
|
|
2062
|
+
# Initialize request argument(s)
|
|
2063
|
+
request = network_security_v1.DeleteServerTlsPolicyRequest(
|
|
2064
|
+
name="name_value",
|
|
2065
|
+
)
|
|
2066
|
+
|
|
2067
|
+
# Make the request
|
|
2068
|
+
operation = client.delete_server_tls_policy(request=request)
|
|
2069
|
+
|
|
2070
|
+
print("Waiting for operation to complete...")
|
|
2071
|
+
|
|
2072
|
+
response = operation.result()
|
|
2073
|
+
|
|
2074
|
+
# Handle the response
|
|
2075
|
+
print(response)
|
|
2076
|
+
|
|
2077
|
+
Args:
|
|
2078
|
+
request (Union[google.cloud.network_security_v1.types.DeleteServerTlsPolicyRequest, dict]):
|
|
2079
|
+
The request object. Request used by the
|
|
2080
|
+
DeleteServerTlsPolicy method.
|
|
2081
|
+
name (str):
|
|
2082
|
+
Required. A name of the ServerTlsPolicy to delete. Must
|
|
2083
|
+
be in the format
|
|
2084
|
+
``projects/*/locations/{location}/serverTlsPolicies/*``.
|
|
2085
|
+
|
|
2086
|
+
This corresponds to the ``name`` field
|
|
2087
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2088
|
+
should not be set.
|
|
2089
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2090
|
+
should be retried.
|
|
2091
|
+
timeout (float): The timeout for this request.
|
|
2092
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2093
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2094
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2095
|
+
be of type `bytes`.
|
|
2096
|
+
|
|
2097
|
+
Returns:
|
|
2098
|
+
google.api_core.operation.Operation:
|
|
2099
|
+
An object representing a long-running operation.
|
|
2100
|
+
|
|
2101
|
+
The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
|
|
2102
|
+
empty messages in your APIs. A typical example is to
|
|
2103
|
+
use it as the request or the response type of an API
|
|
2104
|
+
method. For instance:
|
|
2105
|
+
|
|
2106
|
+
service Foo {
|
|
2107
|
+
rpc Bar(google.protobuf.Empty) returns
|
|
2108
|
+
(google.protobuf.Empty);
|
|
2109
|
+
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
"""
|
|
2113
|
+
# Create or coerce a protobuf request object.
|
|
2114
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2115
|
+
# gotten any keyword arguments that map to the request.
|
|
2116
|
+
flattened_params = [name]
|
|
2117
|
+
has_flattened_params = (
|
|
2118
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2119
|
+
)
|
|
2120
|
+
if request is not None and has_flattened_params:
|
|
2121
|
+
raise ValueError(
|
|
2122
|
+
"If the `request` argument is set, then none of "
|
|
2123
|
+
"the individual field arguments should be set."
|
|
2124
|
+
)
|
|
2125
|
+
|
|
2126
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2127
|
+
# there are no flattened fields), or create one.
|
|
2128
|
+
if not isinstance(request, server_tls_policy.DeleteServerTlsPolicyRequest):
|
|
2129
|
+
request = server_tls_policy.DeleteServerTlsPolicyRequest(request)
|
|
2130
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2131
|
+
# request, apply these.
|
|
2132
|
+
if name is not None:
|
|
2133
|
+
request.name = name
|
|
2134
|
+
|
|
2135
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2136
|
+
# and friendly error handling.
|
|
2137
|
+
rpc = self._transport._wrapped_methods[self._transport.delete_server_tls_policy]
|
|
2138
|
+
|
|
2139
|
+
# Certain fields should be provided within the metadata header;
|
|
2140
|
+
# add these here.
|
|
2141
|
+
metadata = tuple(metadata) + (
|
|
2142
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
2143
|
+
)
|
|
2144
|
+
|
|
2145
|
+
# Validate the universe domain.
|
|
2146
|
+
self._validate_universe_domain()
|
|
2147
|
+
|
|
2148
|
+
# Send the request.
|
|
2149
|
+
response = rpc(
|
|
2150
|
+
request,
|
|
2151
|
+
retry=retry,
|
|
2152
|
+
timeout=timeout,
|
|
2153
|
+
metadata=metadata,
|
|
2154
|
+
)
|
|
2155
|
+
|
|
2156
|
+
# Wrap the response in an operation future.
|
|
2157
|
+
response = operation.from_gapic(
|
|
2158
|
+
response,
|
|
2159
|
+
self._transport.operations_client,
|
|
2160
|
+
empty_pb2.Empty,
|
|
2161
|
+
metadata_type=common.OperationMetadata,
|
|
2162
|
+
)
|
|
2163
|
+
|
|
2164
|
+
# Done; return the response.
|
|
2165
|
+
return response
|
|
2166
|
+
|
|
2167
|
+
def list_client_tls_policies(
|
|
2168
|
+
self,
|
|
2169
|
+
request: Optional[
|
|
2170
|
+
Union[client_tls_policy.ListClientTlsPoliciesRequest, dict]
|
|
2171
|
+
] = None,
|
|
2172
|
+
*,
|
|
2173
|
+
parent: Optional[str] = None,
|
|
2174
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2175
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2176
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2177
|
+
) -> pagers.ListClientTlsPoliciesPager:
|
|
2178
|
+
r"""Lists ClientTlsPolicies in a given project and
|
|
2179
|
+
location.
|
|
2180
|
+
|
|
2181
|
+
.. code-block:: python
|
|
2182
|
+
|
|
2183
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2184
|
+
# code template only.
|
|
2185
|
+
# It will require modifications to work:
|
|
2186
|
+
# - It may require correct/in-range values for request initialization.
|
|
2187
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2188
|
+
# client as shown in:
|
|
2189
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2190
|
+
from google.cloud import network_security_v1
|
|
2191
|
+
|
|
2192
|
+
def sample_list_client_tls_policies():
|
|
2193
|
+
# Create a client
|
|
2194
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
2195
|
+
|
|
2196
|
+
# Initialize request argument(s)
|
|
2197
|
+
request = network_security_v1.ListClientTlsPoliciesRequest(
|
|
2198
|
+
parent="parent_value",
|
|
2199
|
+
)
|
|
2200
|
+
|
|
2201
|
+
# Make the request
|
|
2202
|
+
page_result = client.list_client_tls_policies(request=request)
|
|
2203
|
+
|
|
2204
|
+
# Handle the response
|
|
2205
|
+
for response in page_result:
|
|
2206
|
+
print(response)
|
|
2207
|
+
|
|
2208
|
+
Args:
|
|
2209
|
+
request (Union[google.cloud.network_security_v1.types.ListClientTlsPoliciesRequest, dict]):
|
|
2210
|
+
The request object. Request used by the
|
|
2211
|
+
ListClientTlsPolicies method.
|
|
2212
|
+
parent (str):
|
|
2213
|
+
Required. The project and location from which the
|
|
2214
|
+
ClientTlsPolicies should be listed, specified in the
|
|
2215
|
+
format ``projects/*/locations/{location}``.
|
|
2216
|
+
|
|
2217
|
+
This corresponds to the ``parent`` field
|
|
2218
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2219
|
+
should not be set.
|
|
2220
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2221
|
+
should be retried.
|
|
2222
|
+
timeout (float): The timeout for this request.
|
|
2223
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2224
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2225
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2226
|
+
be of type `bytes`.
|
|
2227
|
+
|
|
2228
|
+
Returns:
|
|
2229
|
+
google.cloud.network_security_v1.services.network_security.pagers.ListClientTlsPoliciesPager:
|
|
2230
|
+
Response returned by the
|
|
2231
|
+
ListClientTlsPolicies method.
|
|
2232
|
+
Iterating over this object will yield
|
|
2233
|
+
results and resolve additional pages
|
|
2234
|
+
automatically.
|
|
2235
|
+
|
|
2236
|
+
"""
|
|
2237
|
+
# Create or coerce a protobuf request object.
|
|
2238
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2239
|
+
# gotten any keyword arguments that map to the request.
|
|
2240
|
+
flattened_params = [parent]
|
|
2241
|
+
has_flattened_params = (
|
|
2242
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2243
|
+
)
|
|
2244
|
+
if request is not None and has_flattened_params:
|
|
2245
|
+
raise ValueError(
|
|
2246
|
+
"If the `request` argument is set, then none of "
|
|
2247
|
+
"the individual field arguments should be set."
|
|
2248
|
+
)
|
|
2249
|
+
|
|
2250
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2251
|
+
# there are no flattened fields), or create one.
|
|
2252
|
+
if not isinstance(request, client_tls_policy.ListClientTlsPoliciesRequest):
|
|
2253
|
+
request = client_tls_policy.ListClientTlsPoliciesRequest(request)
|
|
2254
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2255
|
+
# request, apply these.
|
|
2256
|
+
if parent is not None:
|
|
2257
|
+
request.parent = parent
|
|
2258
|
+
|
|
2259
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2260
|
+
# and friendly error handling.
|
|
2261
|
+
rpc = self._transport._wrapped_methods[self._transport.list_client_tls_policies]
|
|
2262
|
+
|
|
2263
|
+
# Certain fields should be provided within the metadata header;
|
|
2264
|
+
# add these here.
|
|
2265
|
+
metadata = tuple(metadata) + (
|
|
2266
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
2267
|
+
)
|
|
2268
|
+
|
|
2269
|
+
# Validate the universe domain.
|
|
2270
|
+
self._validate_universe_domain()
|
|
2271
|
+
|
|
2272
|
+
# Send the request.
|
|
2273
|
+
response = rpc(
|
|
2274
|
+
request,
|
|
2275
|
+
retry=retry,
|
|
2276
|
+
timeout=timeout,
|
|
2277
|
+
metadata=metadata,
|
|
2278
|
+
)
|
|
2279
|
+
|
|
2280
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
2281
|
+
# an `__iter__` convenience method.
|
|
2282
|
+
response = pagers.ListClientTlsPoliciesPager(
|
|
2283
|
+
method=rpc,
|
|
2284
|
+
request=request,
|
|
2285
|
+
response=response,
|
|
2286
|
+
retry=retry,
|
|
2287
|
+
timeout=timeout,
|
|
2288
|
+
metadata=metadata,
|
|
2289
|
+
)
|
|
2290
|
+
|
|
2291
|
+
# Done; return the response.
|
|
2292
|
+
return response
|
|
2293
|
+
|
|
2294
|
+
def get_client_tls_policy(
|
|
2295
|
+
self,
|
|
2296
|
+
request: Optional[
|
|
2297
|
+
Union[client_tls_policy.GetClientTlsPolicyRequest, dict]
|
|
2298
|
+
] = None,
|
|
2299
|
+
*,
|
|
2300
|
+
name: Optional[str] = None,
|
|
2301
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2302
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2303
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2304
|
+
) -> client_tls_policy.ClientTlsPolicy:
|
|
2305
|
+
r"""Gets details of a single ClientTlsPolicy.
|
|
2306
|
+
|
|
2307
|
+
.. code-block:: python
|
|
2308
|
+
|
|
2309
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2310
|
+
# code template only.
|
|
2311
|
+
# It will require modifications to work:
|
|
2312
|
+
# - It may require correct/in-range values for request initialization.
|
|
2313
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2314
|
+
# client as shown in:
|
|
2315
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2316
|
+
from google.cloud import network_security_v1
|
|
2317
|
+
|
|
2318
|
+
def sample_get_client_tls_policy():
|
|
2319
|
+
# Create a client
|
|
2320
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
2321
|
+
|
|
2322
|
+
# Initialize request argument(s)
|
|
2323
|
+
request = network_security_v1.GetClientTlsPolicyRequest(
|
|
2324
|
+
name="name_value",
|
|
2325
|
+
)
|
|
2326
|
+
|
|
2327
|
+
# Make the request
|
|
2328
|
+
response = client.get_client_tls_policy(request=request)
|
|
2329
|
+
|
|
2330
|
+
# Handle the response
|
|
2331
|
+
print(response)
|
|
2332
|
+
|
|
2333
|
+
Args:
|
|
2334
|
+
request (Union[google.cloud.network_security_v1.types.GetClientTlsPolicyRequest, dict]):
|
|
2335
|
+
The request object. Request used by the
|
|
2336
|
+
GetClientTlsPolicy method.
|
|
2337
|
+
name (str):
|
|
2338
|
+
Required. A name of the ClientTlsPolicy to get. Must be
|
|
2339
|
+
in the format
|
|
2340
|
+
``projects/*/locations/{location}/clientTlsPolicies/*``.
|
|
2341
|
+
|
|
2342
|
+
This corresponds to the ``name`` field
|
|
2343
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2344
|
+
should not be set.
|
|
2345
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2346
|
+
should be retried.
|
|
2347
|
+
timeout (float): The timeout for this request.
|
|
2348
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2349
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2350
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2351
|
+
be of type `bytes`.
|
|
2352
|
+
|
|
2353
|
+
Returns:
|
|
2354
|
+
google.cloud.network_security_v1.types.ClientTlsPolicy:
|
|
2355
|
+
ClientTlsPolicy is a resource that
|
|
2356
|
+
specifies how a client should
|
|
2357
|
+
authenticate connections to backends of
|
|
2358
|
+
a service. This resource itself does not
|
|
2359
|
+
affect configuration unless it is
|
|
2360
|
+
attached to a backend service resource.
|
|
2361
|
+
|
|
2362
|
+
"""
|
|
2363
|
+
# Create or coerce a protobuf request object.
|
|
2364
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2365
|
+
# gotten any keyword arguments that map to the request.
|
|
2366
|
+
flattened_params = [name]
|
|
2367
|
+
has_flattened_params = (
|
|
2368
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2369
|
+
)
|
|
2370
|
+
if request is not None and has_flattened_params:
|
|
2371
|
+
raise ValueError(
|
|
2372
|
+
"If the `request` argument is set, then none of "
|
|
2373
|
+
"the individual field arguments should be set."
|
|
2374
|
+
)
|
|
2375
|
+
|
|
2376
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2377
|
+
# there are no flattened fields), or create one.
|
|
2378
|
+
if not isinstance(request, client_tls_policy.GetClientTlsPolicyRequest):
|
|
2379
|
+
request = client_tls_policy.GetClientTlsPolicyRequest(request)
|
|
2380
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2381
|
+
# request, apply these.
|
|
2382
|
+
if name is not None:
|
|
2383
|
+
request.name = name
|
|
2384
|
+
|
|
2385
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2386
|
+
# and friendly error handling.
|
|
2387
|
+
rpc = self._transport._wrapped_methods[self._transport.get_client_tls_policy]
|
|
2388
|
+
|
|
2389
|
+
# Certain fields should be provided within the metadata header;
|
|
2390
|
+
# add these here.
|
|
2391
|
+
metadata = tuple(metadata) + (
|
|
2392
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
2393
|
+
)
|
|
2394
|
+
|
|
2395
|
+
# Validate the universe domain.
|
|
2396
|
+
self._validate_universe_domain()
|
|
2397
|
+
|
|
2398
|
+
# Send the request.
|
|
2399
|
+
response = rpc(
|
|
2400
|
+
request,
|
|
2401
|
+
retry=retry,
|
|
2402
|
+
timeout=timeout,
|
|
2403
|
+
metadata=metadata,
|
|
2404
|
+
)
|
|
2405
|
+
|
|
2406
|
+
# Done; return the response.
|
|
2407
|
+
return response
|
|
2408
|
+
|
|
2409
|
+
def create_client_tls_policy(
|
|
2410
|
+
self,
|
|
2411
|
+
request: Optional[
|
|
2412
|
+
Union[gcn_client_tls_policy.CreateClientTlsPolicyRequest, dict]
|
|
2413
|
+
] = None,
|
|
2414
|
+
*,
|
|
2415
|
+
parent: Optional[str] = None,
|
|
2416
|
+
client_tls_policy: Optional[gcn_client_tls_policy.ClientTlsPolicy] = None,
|
|
2417
|
+
client_tls_policy_id: Optional[str] = None,
|
|
2418
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2419
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2420
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2421
|
+
) -> operation.Operation:
|
|
2422
|
+
r"""Creates a new ClientTlsPolicy in a given project and
|
|
2423
|
+
location.
|
|
2424
|
+
|
|
2425
|
+
.. code-block:: python
|
|
2426
|
+
|
|
2427
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2428
|
+
# code template only.
|
|
2429
|
+
# It will require modifications to work:
|
|
2430
|
+
# - It may require correct/in-range values for request initialization.
|
|
2431
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2432
|
+
# client as shown in:
|
|
2433
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2434
|
+
from google.cloud import network_security_v1
|
|
2435
|
+
|
|
2436
|
+
def sample_create_client_tls_policy():
|
|
2437
|
+
# Create a client
|
|
2438
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
2439
|
+
|
|
2440
|
+
# Initialize request argument(s)
|
|
2441
|
+
client_tls_policy = network_security_v1.ClientTlsPolicy()
|
|
2442
|
+
client_tls_policy.name = "name_value"
|
|
2443
|
+
|
|
2444
|
+
request = network_security_v1.CreateClientTlsPolicyRequest(
|
|
2445
|
+
parent="parent_value",
|
|
2446
|
+
client_tls_policy_id="client_tls_policy_id_value",
|
|
2447
|
+
client_tls_policy=client_tls_policy,
|
|
2448
|
+
)
|
|
2449
|
+
|
|
2450
|
+
# Make the request
|
|
2451
|
+
operation = client.create_client_tls_policy(request=request)
|
|
2452
|
+
|
|
2453
|
+
print("Waiting for operation to complete...")
|
|
2454
|
+
|
|
2455
|
+
response = operation.result()
|
|
2456
|
+
|
|
2457
|
+
# Handle the response
|
|
2458
|
+
print(response)
|
|
2459
|
+
|
|
2460
|
+
Args:
|
|
2461
|
+
request (Union[google.cloud.network_security_v1.types.CreateClientTlsPolicyRequest, dict]):
|
|
2462
|
+
The request object. Request used by the
|
|
2463
|
+
CreateClientTlsPolicy method.
|
|
2464
|
+
parent (str):
|
|
2465
|
+
Required. The parent resource of the ClientTlsPolicy.
|
|
2466
|
+
Must be in the format
|
|
2467
|
+
``projects/*/locations/{location}``.
|
|
2468
|
+
|
|
2469
|
+
This corresponds to the ``parent`` field
|
|
2470
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2471
|
+
should not be set.
|
|
2472
|
+
client_tls_policy (google.cloud.network_security_v1.types.ClientTlsPolicy):
|
|
2473
|
+
Required. ClientTlsPolicy resource to
|
|
2474
|
+
be created.
|
|
2475
|
+
|
|
2476
|
+
This corresponds to the ``client_tls_policy`` field
|
|
2477
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2478
|
+
should not be set.
|
|
2479
|
+
client_tls_policy_id (str):
|
|
2480
|
+
Required. Short name of the ClientTlsPolicy resource to
|
|
2481
|
+
be created. This value should be 1-63 characters long,
|
|
2482
|
+
containing only letters, numbers, hyphens, and
|
|
2483
|
+
underscores, and should not start with a number. E.g.
|
|
2484
|
+
"client_mtls_policy".
|
|
2485
|
+
|
|
2486
|
+
This corresponds to the ``client_tls_policy_id`` field
|
|
2487
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2488
|
+
should not be set.
|
|
2489
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2490
|
+
should be retried.
|
|
2491
|
+
timeout (float): The timeout for this request.
|
|
2492
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2493
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2494
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2495
|
+
be of type `bytes`.
|
|
2496
|
+
|
|
2497
|
+
Returns:
|
|
2498
|
+
google.api_core.operation.Operation:
|
|
2499
|
+
An object representing a long-running operation.
|
|
2500
|
+
|
|
2501
|
+
The result type for the operation will be :class:`google.cloud.network_security_v1.types.ClientTlsPolicy` ClientTlsPolicy is a resource that specifies how a client should authenticate
|
|
2502
|
+
connections to backends of a service. This resource
|
|
2503
|
+
itself does not affect configuration unless it is
|
|
2504
|
+
attached to a backend service resource.
|
|
2505
|
+
|
|
2506
|
+
"""
|
|
2507
|
+
# Create or coerce a protobuf request object.
|
|
2508
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2509
|
+
# gotten any keyword arguments that map to the request.
|
|
2510
|
+
flattened_params = [parent, client_tls_policy, client_tls_policy_id]
|
|
2511
|
+
has_flattened_params = (
|
|
2512
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2513
|
+
)
|
|
2514
|
+
if request is not None and has_flattened_params:
|
|
2515
|
+
raise ValueError(
|
|
2516
|
+
"If the `request` argument is set, then none of "
|
|
2517
|
+
"the individual field arguments should be set."
|
|
2518
|
+
)
|
|
2519
|
+
|
|
2520
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2521
|
+
# there are no flattened fields), or create one.
|
|
2522
|
+
if not isinstance(request, gcn_client_tls_policy.CreateClientTlsPolicyRequest):
|
|
2523
|
+
request = gcn_client_tls_policy.CreateClientTlsPolicyRequest(request)
|
|
2524
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2525
|
+
# request, apply these.
|
|
2526
|
+
if parent is not None:
|
|
2527
|
+
request.parent = parent
|
|
2528
|
+
if client_tls_policy is not None:
|
|
2529
|
+
request.client_tls_policy = client_tls_policy
|
|
2530
|
+
if client_tls_policy_id is not None:
|
|
2531
|
+
request.client_tls_policy_id = client_tls_policy_id
|
|
2532
|
+
|
|
2533
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2534
|
+
# and friendly error handling.
|
|
2535
|
+
rpc = self._transport._wrapped_methods[self._transport.create_client_tls_policy]
|
|
2536
|
+
|
|
2537
|
+
# Certain fields should be provided within the metadata header;
|
|
2538
|
+
# add these here.
|
|
2539
|
+
metadata = tuple(metadata) + (
|
|
2540
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
2541
|
+
)
|
|
2542
|
+
|
|
2543
|
+
# Validate the universe domain.
|
|
2544
|
+
self._validate_universe_domain()
|
|
2545
|
+
|
|
2546
|
+
# Send the request.
|
|
2547
|
+
response = rpc(
|
|
2548
|
+
request,
|
|
2549
|
+
retry=retry,
|
|
2550
|
+
timeout=timeout,
|
|
2551
|
+
metadata=metadata,
|
|
2552
|
+
)
|
|
2553
|
+
|
|
2554
|
+
# Wrap the response in an operation future.
|
|
2555
|
+
response = operation.from_gapic(
|
|
2556
|
+
response,
|
|
2557
|
+
self._transport.operations_client,
|
|
2558
|
+
gcn_client_tls_policy.ClientTlsPolicy,
|
|
2559
|
+
metadata_type=common.OperationMetadata,
|
|
2560
|
+
)
|
|
2561
|
+
|
|
2562
|
+
# Done; return the response.
|
|
2563
|
+
return response
|
|
2564
|
+
|
|
2565
|
+
def update_client_tls_policy(
|
|
2566
|
+
self,
|
|
2567
|
+
request: Optional[
|
|
2568
|
+
Union[gcn_client_tls_policy.UpdateClientTlsPolicyRequest, dict]
|
|
2569
|
+
] = None,
|
|
2570
|
+
*,
|
|
2571
|
+
client_tls_policy: Optional[gcn_client_tls_policy.ClientTlsPolicy] = None,
|
|
2572
|
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
|
2573
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2574
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2575
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2576
|
+
) -> operation.Operation:
|
|
2577
|
+
r"""Updates the parameters of a single ClientTlsPolicy.
|
|
2578
|
+
|
|
2579
|
+
.. code-block:: python
|
|
2580
|
+
|
|
2581
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2582
|
+
# code template only.
|
|
2583
|
+
# It will require modifications to work:
|
|
2584
|
+
# - It may require correct/in-range values for request initialization.
|
|
2585
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2586
|
+
# client as shown in:
|
|
2587
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2588
|
+
from google.cloud import network_security_v1
|
|
2589
|
+
|
|
2590
|
+
def sample_update_client_tls_policy():
|
|
2591
|
+
# Create a client
|
|
2592
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
2593
|
+
|
|
2594
|
+
# Initialize request argument(s)
|
|
2595
|
+
client_tls_policy = network_security_v1.ClientTlsPolicy()
|
|
2596
|
+
client_tls_policy.name = "name_value"
|
|
2597
|
+
|
|
2598
|
+
request = network_security_v1.UpdateClientTlsPolicyRequest(
|
|
2599
|
+
client_tls_policy=client_tls_policy,
|
|
2600
|
+
)
|
|
2601
|
+
|
|
2602
|
+
# Make the request
|
|
2603
|
+
operation = client.update_client_tls_policy(request=request)
|
|
2604
|
+
|
|
2605
|
+
print("Waiting for operation to complete...")
|
|
2606
|
+
|
|
2607
|
+
response = operation.result()
|
|
2608
|
+
|
|
2609
|
+
# Handle the response
|
|
2610
|
+
print(response)
|
|
2611
|
+
|
|
2612
|
+
Args:
|
|
2613
|
+
request (Union[google.cloud.network_security_v1.types.UpdateClientTlsPolicyRequest, dict]):
|
|
2614
|
+
The request object. Request used by UpdateClientTlsPolicy
|
|
2615
|
+
method.
|
|
2616
|
+
client_tls_policy (google.cloud.network_security_v1.types.ClientTlsPolicy):
|
|
2617
|
+
Required. Updated ClientTlsPolicy
|
|
2618
|
+
resource.
|
|
2619
|
+
|
|
2620
|
+
This corresponds to the ``client_tls_policy`` field
|
|
2621
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2622
|
+
should not be set.
|
|
2623
|
+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
|
|
2624
|
+
Optional. Field mask is used to specify the fields to be
|
|
2625
|
+
overwritten in the ClientTlsPolicy resource by the
|
|
2626
|
+
update. The fields specified in the update_mask are
|
|
2627
|
+
relative to the resource, not the full request. A field
|
|
2628
|
+
will be overwritten if it is in the mask. If the user
|
|
2629
|
+
does not provide a mask then all fields will be
|
|
2630
|
+
overwritten.
|
|
2631
|
+
|
|
2632
|
+
This corresponds to the ``update_mask`` field
|
|
2633
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2634
|
+
should not be set.
|
|
2635
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2636
|
+
should be retried.
|
|
2637
|
+
timeout (float): The timeout for this request.
|
|
2638
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2639
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2640
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2641
|
+
be of type `bytes`.
|
|
2642
|
+
|
|
2643
|
+
Returns:
|
|
2644
|
+
google.api_core.operation.Operation:
|
|
2645
|
+
An object representing a long-running operation.
|
|
2646
|
+
|
|
2647
|
+
The result type for the operation will be :class:`google.cloud.network_security_v1.types.ClientTlsPolicy` ClientTlsPolicy is a resource that specifies how a client should authenticate
|
|
2648
|
+
connections to backends of a service. This resource
|
|
2649
|
+
itself does not affect configuration unless it is
|
|
2650
|
+
attached to a backend service resource.
|
|
2651
|
+
|
|
2652
|
+
"""
|
|
2653
|
+
# Create or coerce a protobuf request object.
|
|
2654
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2655
|
+
# gotten any keyword arguments that map to the request.
|
|
2656
|
+
flattened_params = [client_tls_policy, update_mask]
|
|
2657
|
+
has_flattened_params = (
|
|
2658
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2659
|
+
)
|
|
2660
|
+
if request is not None and has_flattened_params:
|
|
2661
|
+
raise ValueError(
|
|
2662
|
+
"If the `request` argument is set, then none of "
|
|
2663
|
+
"the individual field arguments should be set."
|
|
2664
|
+
)
|
|
2665
|
+
|
|
2666
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2667
|
+
# there are no flattened fields), or create one.
|
|
2668
|
+
if not isinstance(request, gcn_client_tls_policy.UpdateClientTlsPolicyRequest):
|
|
2669
|
+
request = gcn_client_tls_policy.UpdateClientTlsPolicyRequest(request)
|
|
2670
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2671
|
+
# request, apply these.
|
|
2672
|
+
if client_tls_policy is not None:
|
|
2673
|
+
request.client_tls_policy = client_tls_policy
|
|
2674
|
+
if update_mask is not None:
|
|
2675
|
+
request.update_mask = update_mask
|
|
2676
|
+
|
|
2677
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2678
|
+
# and friendly error handling.
|
|
2679
|
+
rpc = self._transport._wrapped_methods[self._transport.update_client_tls_policy]
|
|
2680
|
+
|
|
2681
|
+
# Certain fields should be provided within the metadata header;
|
|
2682
|
+
# add these here.
|
|
2683
|
+
metadata = tuple(metadata) + (
|
|
2684
|
+
gapic_v1.routing_header.to_grpc_metadata(
|
|
2685
|
+
(("client_tls_policy.name", request.client_tls_policy.name),)
|
|
2686
|
+
),
|
|
2687
|
+
)
|
|
2688
|
+
|
|
2689
|
+
# Validate the universe domain.
|
|
2690
|
+
self._validate_universe_domain()
|
|
2691
|
+
|
|
2692
|
+
# Send the request.
|
|
2693
|
+
response = rpc(
|
|
2694
|
+
request,
|
|
2695
|
+
retry=retry,
|
|
2696
|
+
timeout=timeout,
|
|
2697
|
+
metadata=metadata,
|
|
2698
|
+
)
|
|
2699
|
+
|
|
2700
|
+
# Wrap the response in an operation future.
|
|
2701
|
+
response = operation.from_gapic(
|
|
2702
|
+
response,
|
|
2703
|
+
self._transport.operations_client,
|
|
2704
|
+
gcn_client_tls_policy.ClientTlsPolicy,
|
|
2705
|
+
metadata_type=common.OperationMetadata,
|
|
2706
|
+
)
|
|
2707
|
+
|
|
2708
|
+
# Done; return the response.
|
|
2709
|
+
return response
|
|
2710
|
+
|
|
2711
|
+
def delete_client_tls_policy(
|
|
2712
|
+
self,
|
|
2713
|
+
request: Optional[
|
|
2714
|
+
Union[client_tls_policy.DeleteClientTlsPolicyRequest, dict]
|
|
2715
|
+
] = None,
|
|
2716
|
+
*,
|
|
2717
|
+
name: Optional[str] = None,
|
|
2718
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2719
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2720
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2721
|
+
) -> operation.Operation:
|
|
2722
|
+
r"""Deletes a single ClientTlsPolicy.
|
|
2723
|
+
|
|
2724
|
+
.. code-block:: python
|
|
2725
|
+
|
|
2726
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
2727
|
+
# code template only.
|
|
2728
|
+
# It will require modifications to work:
|
|
2729
|
+
# - It may require correct/in-range values for request initialization.
|
|
2730
|
+
# - It may require specifying regional endpoints when creating the service
|
|
2731
|
+
# client as shown in:
|
|
2732
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
2733
|
+
from google.cloud import network_security_v1
|
|
2734
|
+
|
|
2735
|
+
def sample_delete_client_tls_policy():
|
|
2736
|
+
# Create a client
|
|
2737
|
+
client = network_security_v1.NetworkSecurityClient()
|
|
2738
|
+
|
|
2739
|
+
# Initialize request argument(s)
|
|
2740
|
+
request = network_security_v1.DeleteClientTlsPolicyRequest(
|
|
2741
|
+
name="name_value",
|
|
2742
|
+
)
|
|
2743
|
+
|
|
2744
|
+
# Make the request
|
|
2745
|
+
operation = client.delete_client_tls_policy(request=request)
|
|
2746
|
+
|
|
2747
|
+
print("Waiting for operation to complete...")
|
|
2748
|
+
|
|
2749
|
+
response = operation.result()
|
|
2750
|
+
|
|
2751
|
+
# Handle the response
|
|
2752
|
+
print(response)
|
|
2753
|
+
|
|
2754
|
+
Args:
|
|
2755
|
+
request (Union[google.cloud.network_security_v1.types.DeleteClientTlsPolicyRequest, dict]):
|
|
2756
|
+
The request object. Request used by the
|
|
2757
|
+
DeleteClientTlsPolicy method.
|
|
2758
|
+
name (str):
|
|
2759
|
+
Required. A name of the ClientTlsPolicy to delete. Must
|
|
2760
|
+
be in the format
|
|
2761
|
+
``projects/*/locations/{location}/clientTlsPolicies/*``.
|
|
2762
|
+
|
|
2763
|
+
This corresponds to the ``name`` field
|
|
2764
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
2765
|
+
should not be set.
|
|
2766
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
2767
|
+
should be retried.
|
|
2768
|
+
timeout (float): The timeout for this request.
|
|
2769
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2770
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2771
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2772
|
+
be of type `bytes`.
|
|
2773
|
+
|
|
2774
|
+
Returns:
|
|
2775
|
+
google.api_core.operation.Operation:
|
|
2776
|
+
An object representing a long-running operation.
|
|
2777
|
+
|
|
2778
|
+
The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
|
|
2779
|
+
empty messages in your APIs. A typical example is to
|
|
2780
|
+
use it as the request or the response type of an API
|
|
2781
|
+
method. For instance:
|
|
2782
|
+
|
|
2783
|
+
service Foo {
|
|
2784
|
+
rpc Bar(google.protobuf.Empty) returns
|
|
2785
|
+
(google.protobuf.Empty);
|
|
2786
|
+
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
"""
|
|
2790
|
+
# Create or coerce a protobuf request object.
|
|
2791
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
2792
|
+
# gotten any keyword arguments that map to the request.
|
|
2793
|
+
flattened_params = [name]
|
|
2794
|
+
has_flattened_params = (
|
|
2795
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
2796
|
+
)
|
|
2797
|
+
if request is not None and has_flattened_params:
|
|
2798
|
+
raise ValueError(
|
|
2799
|
+
"If the `request` argument is set, then none of "
|
|
2800
|
+
"the individual field arguments should be set."
|
|
2801
|
+
)
|
|
2802
|
+
|
|
2803
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
2804
|
+
# there are no flattened fields), or create one.
|
|
2805
|
+
if not isinstance(request, client_tls_policy.DeleteClientTlsPolicyRequest):
|
|
2806
|
+
request = client_tls_policy.DeleteClientTlsPolicyRequest(request)
|
|
2807
|
+
# If we have keyword arguments corresponding to fields on the
|
|
2808
|
+
# request, apply these.
|
|
2809
|
+
if name is not None:
|
|
2810
|
+
request.name = name
|
|
2811
|
+
|
|
2812
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2813
|
+
# and friendly error handling.
|
|
2814
|
+
rpc = self._transport._wrapped_methods[self._transport.delete_client_tls_policy]
|
|
2815
|
+
|
|
2816
|
+
# Certain fields should be provided within the metadata header;
|
|
2817
|
+
# add these here.
|
|
2818
|
+
metadata = tuple(metadata) + (
|
|
2819
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
2820
|
+
)
|
|
2821
|
+
|
|
2822
|
+
# Validate the universe domain.
|
|
2823
|
+
self._validate_universe_domain()
|
|
2824
|
+
|
|
2825
|
+
# Send the request.
|
|
2826
|
+
response = rpc(
|
|
2827
|
+
request,
|
|
2828
|
+
retry=retry,
|
|
2829
|
+
timeout=timeout,
|
|
2830
|
+
metadata=metadata,
|
|
2831
|
+
)
|
|
2832
|
+
|
|
2833
|
+
# Wrap the response in an operation future.
|
|
2834
|
+
response = operation.from_gapic(
|
|
2835
|
+
response,
|
|
2836
|
+
self._transport.operations_client,
|
|
2837
|
+
empty_pb2.Empty,
|
|
2838
|
+
metadata_type=common.OperationMetadata,
|
|
2839
|
+
)
|
|
2840
|
+
|
|
2841
|
+
# Done; return the response.
|
|
2842
|
+
return response
|
|
2843
|
+
|
|
2844
|
+
def __enter__(self) -> "NetworkSecurityClient":
|
|
2845
|
+
return self
|
|
2846
|
+
|
|
2847
|
+
def __exit__(self, type, value, traceback):
|
|
2848
|
+
"""Releases underlying transport's resources.
|
|
2849
|
+
|
|
2850
|
+
.. warning::
|
|
2851
|
+
ONLY use as a context manager if the transport is NOT shared
|
|
2852
|
+
with other clients! Exiting the with block will CLOSE the transport
|
|
2853
|
+
and may cause errors in other clients!
|
|
2854
|
+
"""
|
|
2855
|
+
self.transport.close()
|
|
2856
|
+
|
|
2857
|
+
def list_operations(
|
|
2858
|
+
self,
|
|
2859
|
+
request: Optional[operations_pb2.ListOperationsRequest] = None,
|
|
2860
|
+
*,
|
|
2861
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2862
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2863
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2864
|
+
) -> operations_pb2.ListOperationsResponse:
|
|
2865
|
+
r"""Lists operations that match the specified filter in the request.
|
|
2866
|
+
|
|
2867
|
+
Args:
|
|
2868
|
+
request (:class:`~.operations_pb2.ListOperationsRequest`):
|
|
2869
|
+
The request object. Request message for
|
|
2870
|
+
`ListOperations` method.
|
|
2871
|
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
|
2872
|
+
if any, should be retried.
|
|
2873
|
+
timeout (float): The timeout for this request.
|
|
2874
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2875
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2876
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2877
|
+
be of type `bytes`.
|
|
2878
|
+
Returns:
|
|
2879
|
+
~.operations_pb2.ListOperationsResponse:
|
|
2880
|
+
Response message for ``ListOperations`` method.
|
|
2881
|
+
"""
|
|
2882
|
+
# Create or coerce a protobuf request object.
|
|
2883
|
+
# The request isn't a proto-plus wrapped type,
|
|
2884
|
+
# so it must be constructed via keyword expansion.
|
|
2885
|
+
if isinstance(request, dict):
|
|
2886
|
+
request = operations_pb2.ListOperationsRequest(**request)
|
|
2887
|
+
|
|
2888
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2889
|
+
# and friendly error handling.
|
|
2890
|
+
rpc = self._transport._wrapped_methods[self._transport.list_operations]
|
|
2891
|
+
|
|
2892
|
+
# Certain fields should be provided within the metadata header;
|
|
2893
|
+
# add these here.
|
|
2894
|
+
metadata = tuple(metadata) + (
|
|
2895
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
2896
|
+
)
|
|
2897
|
+
|
|
2898
|
+
# Validate the universe domain.
|
|
2899
|
+
self._validate_universe_domain()
|
|
2900
|
+
|
|
2901
|
+
try:
|
|
2902
|
+
# Send the request.
|
|
2903
|
+
response = rpc(
|
|
2904
|
+
request,
|
|
2905
|
+
retry=retry,
|
|
2906
|
+
timeout=timeout,
|
|
2907
|
+
metadata=metadata,
|
|
2908
|
+
)
|
|
2909
|
+
|
|
2910
|
+
# Done; return the response.
|
|
2911
|
+
return response
|
|
2912
|
+
except core_exceptions.GoogleAPICallError as e:
|
|
2913
|
+
self._add_cred_info_for_auth_errors(e)
|
|
2914
|
+
raise e
|
|
2915
|
+
|
|
2916
|
+
def get_operation(
|
|
2917
|
+
self,
|
|
2918
|
+
request: Optional[operations_pb2.GetOperationRequest] = None,
|
|
2919
|
+
*,
|
|
2920
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2921
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2922
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2923
|
+
) -> operations_pb2.Operation:
|
|
2924
|
+
r"""Gets the latest state of a long-running operation.
|
|
2925
|
+
|
|
2926
|
+
Args:
|
|
2927
|
+
request (:class:`~.operations_pb2.GetOperationRequest`):
|
|
2928
|
+
The request object. Request message for
|
|
2929
|
+
`GetOperation` method.
|
|
2930
|
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
|
2931
|
+
if any, should be retried.
|
|
2932
|
+
timeout (float): The timeout for this request.
|
|
2933
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2934
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2935
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
2936
|
+
be of type `bytes`.
|
|
2937
|
+
Returns:
|
|
2938
|
+
~.operations_pb2.Operation:
|
|
2939
|
+
An ``Operation`` object.
|
|
2940
|
+
"""
|
|
2941
|
+
# Create or coerce a protobuf request object.
|
|
2942
|
+
# The request isn't a proto-plus wrapped type,
|
|
2943
|
+
# so it must be constructed via keyword expansion.
|
|
2944
|
+
if isinstance(request, dict):
|
|
2945
|
+
request = operations_pb2.GetOperationRequest(**request)
|
|
2946
|
+
|
|
2947
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2948
|
+
# and friendly error handling.
|
|
2949
|
+
rpc = self._transport._wrapped_methods[self._transport.get_operation]
|
|
2950
|
+
|
|
2951
|
+
# Certain fields should be provided within the metadata header;
|
|
2952
|
+
# add these here.
|
|
2953
|
+
metadata = tuple(metadata) + (
|
|
2954
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
2955
|
+
)
|
|
2956
|
+
|
|
2957
|
+
# Validate the universe domain.
|
|
2958
|
+
self._validate_universe_domain()
|
|
2959
|
+
|
|
2960
|
+
try:
|
|
2961
|
+
# Send the request.
|
|
2962
|
+
response = rpc(
|
|
2963
|
+
request,
|
|
2964
|
+
retry=retry,
|
|
2965
|
+
timeout=timeout,
|
|
2966
|
+
metadata=metadata,
|
|
2967
|
+
)
|
|
2968
|
+
|
|
2969
|
+
# Done; return the response.
|
|
2970
|
+
return response
|
|
2971
|
+
except core_exceptions.GoogleAPICallError as e:
|
|
2972
|
+
self._add_cred_info_for_auth_errors(e)
|
|
2973
|
+
raise e
|
|
2974
|
+
|
|
2975
|
+
def delete_operation(
|
|
2976
|
+
self,
|
|
2977
|
+
request: Optional[operations_pb2.DeleteOperationRequest] = None,
|
|
2978
|
+
*,
|
|
2979
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2980
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2981
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
2982
|
+
) -> None:
|
|
2983
|
+
r"""Deletes a long-running operation.
|
|
2984
|
+
|
|
2985
|
+
This method indicates that the client is no longer interested
|
|
2986
|
+
in the operation result. It does not cancel the operation.
|
|
2987
|
+
If the server doesn't support this method, it returns
|
|
2988
|
+
`google.rpc.Code.UNIMPLEMENTED`.
|
|
2989
|
+
|
|
2990
|
+
Args:
|
|
2991
|
+
request (:class:`~.operations_pb2.DeleteOperationRequest`):
|
|
2992
|
+
The request object. Request message for
|
|
2993
|
+
`DeleteOperation` method.
|
|
2994
|
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
|
2995
|
+
if any, should be retried.
|
|
2996
|
+
timeout (float): The timeout for this request.
|
|
2997
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
2998
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
2999
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3000
|
+
be of type `bytes`.
|
|
3001
|
+
Returns:
|
|
3002
|
+
None
|
|
3003
|
+
"""
|
|
3004
|
+
# Create or coerce a protobuf request object.
|
|
3005
|
+
# The request isn't a proto-plus wrapped type,
|
|
3006
|
+
# so it must be constructed via keyword expansion.
|
|
3007
|
+
if isinstance(request, dict):
|
|
3008
|
+
request = operations_pb2.DeleteOperationRequest(**request)
|
|
3009
|
+
|
|
3010
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3011
|
+
# and friendly error handling.
|
|
3012
|
+
rpc = self._transport._wrapped_methods[self._transport.delete_operation]
|
|
3013
|
+
|
|
3014
|
+
# Certain fields should be provided within the metadata header;
|
|
3015
|
+
# add these here.
|
|
3016
|
+
metadata = tuple(metadata) + (
|
|
3017
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
3018
|
+
)
|
|
3019
|
+
|
|
3020
|
+
# Validate the universe domain.
|
|
3021
|
+
self._validate_universe_domain()
|
|
3022
|
+
|
|
3023
|
+
# Send the request.
|
|
3024
|
+
rpc(
|
|
3025
|
+
request,
|
|
3026
|
+
retry=retry,
|
|
3027
|
+
timeout=timeout,
|
|
3028
|
+
metadata=metadata,
|
|
3029
|
+
)
|
|
3030
|
+
|
|
3031
|
+
def cancel_operation(
|
|
3032
|
+
self,
|
|
3033
|
+
request: Optional[operations_pb2.CancelOperationRequest] = None,
|
|
3034
|
+
*,
|
|
3035
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3036
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3037
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3038
|
+
) -> None:
|
|
3039
|
+
r"""Starts asynchronous cancellation on a long-running operation.
|
|
3040
|
+
|
|
3041
|
+
The server makes a best effort to cancel the operation, but success
|
|
3042
|
+
is not guaranteed. If the server doesn't support this method, it returns
|
|
3043
|
+
`google.rpc.Code.UNIMPLEMENTED`.
|
|
3044
|
+
|
|
3045
|
+
Args:
|
|
3046
|
+
request (:class:`~.operations_pb2.CancelOperationRequest`):
|
|
3047
|
+
The request object. Request message for
|
|
3048
|
+
`CancelOperation` method.
|
|
3049
|
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
|
3050
|
+
if any, should be retried.
|
|
3051
|
+
timeout (float): The timeout for this request.
|
|
3052
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3053
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3054
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3055
|
+
be of type `bytes`.
|
|
3056
|
+
Returns:
|
|
3057
|
+
None
|
|
3058
|
+
"""
|
|
3059
|
+
# Create or coerce a protobuf request object.
|
|
3060
|
+
# The request isn't a proto-plus wrapped type,
|
|
3061
|
+
# so it must be constructed via keyword expansion.
|
|
3062
|
+
if isinstance(request, dict):
|
|
3063
|
+
request = operations_pb2.CancelOperationRequest(**request)
|
|
3064
|
+
|
|
3065
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3066
|
+
# and friendly error handling.
|
|
3067
|
+
rpc = self._transport._wrapped_methods[self._transport.cancel_operation]
|
|
3068
|
+
|
|
3069
|
+
# Certain fields should be provided within the metadata header;
|
|
3070
|
+
# add these here.
|
|
3071
|
+
metadata = tuple(metadata) + (
|
|
3072
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
3073
|
+
)
|
|
3074
|
+
|
|
3075
|
+
# Validate the universe domain.
|
|
3076
|
+
self._validate_universe_domain()
|
|
3077
|
+
|
|
3078
|
+
# Send the request.
|
|
3079
|
+
rpc(
|
|
3080
|
+
request,
|
|
3081
|
+
retry=retry,
|
|
3082
|
+
timeout=timeout,
|
|
3083
|
+
metadata=metadata,
|
|
3084
|
+
)
|
|
3085
|
+
|
|
3086
|
+
def set_iam_policy(
|
|
3087
|
+
self,
|
|
3088
|
+
request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
|
|
3089
|
+
*,
|
|
3090
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3091
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3092
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3093
|
+
) -> policy_pb2.Policy:
|
|
3094
|
+
r"""Sets the IAM access control policy on the specified function.
|
|
3095
|
+
|
|
3096
|
+
Replaces any existing policy.
|
|
3097
|
+
|
|
3098
|
+
Args:
|
|
3099
|
+
request (:class:`~.iam_policy_pb2.SetIamPolicyRequest`):
|
|
3100
|
+
The request object. Request message for `SetIamPolicy`
|
|
3101
|
+
method.
|
|
3102
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
3103
|
+
should be retried.
|
|
3104
|
+
timeout (float): The timeout for this request.
|
|
3105
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3106
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3107
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3108
|
+
be of type `bytes`.
|
|
3109
|
+
Returns:
|
|
3110
|
+
~.policy_pb2.Policy:
|
|
3111
|
+
Defines an Identity and Access Management (IAM) policy.
|
|
3112
|
+
It is used to specify access control policies for Cloud
|
|
3113
|
+
Platform resources.
|
|
3114
|
+
A ``Policy`` is a collection of ``bindings``. A
|
|
3115
|
+
``binding`` binds one or more ``members`` to a single
|
|
3116
|
+
``role``. Members can be user accounts, service
|
|
3117
|
+
accounts, Google groups, and domains (such as G Suite).
|
|
3118
|
+
A ``role`` is a named list of permissions (defined by
|
|
3119
|
+
IAM or configured by users). A ``binding`` can
|
|
3120
|
+
optionally specify a ``condition``, which is a logic
|
|
3121
|
+
expression that further constrains the role binding
|
|
3122
|
+
based on attributes about the request and/or target
|
|
3123
|
+
resource.
|
|
3124
|
+
|
|
3125
|
+
**JSON Example**
|
|
3126
|
+
|
|
3127
|
+
::
|
|
3128
|
+
|
|
3129
|
+
{
|
|
3130
|
+
"bindings": [
|
|
3131
|
+
{
|
|
3132
|
+
"role": "roles/resourcemanager.organizationAdmin",
|
|
3133
|
+
"members": [
|
|
3134
|
+
"user:mike@example.com",
|
|
3135
|
+
"group:admins@example.com",
|
|
3136
|
+
"domain:google.com",
|
|
3137
|
+
"serviceAccount:my-project-id@appspot.gserviceaccount.com"
|
|
3138
|
+
]
|
|
3139
|
+
},
|
|
3140
|
+
{
|
|
3141
|
+
"role": "roles/resourcemanager.organizationViewer",
|
|
3142
|
+
"members": ["user:eve@example.com"],
|
|
3143
|
+
"condition": {
|
|
3144
|
+
"title": "expirable access",
|
|
3145
|
+
"description": "Does not grant access after Sep 2020",
|
|
3146
|
+
"expression": "request.time <
|
|
3147
|
+
timestamp('2020-10-01T00:00:00.000Z')",
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
]
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
**YAML Example**
|
|
3154
|
+
|
|
3155
|
+
::
|
|
3156
|
+
|
|
3157
|
+
bindings:
|
|
3158
|
+
- members:
|
|
3159
|
+
- user:mike@example.com
|
|
3160
|
+
- group:admins@example.com
|
|
3161
|
+
- domain:google.com
|
|
3162
|
+
- serviceAccount:my-project-id@appspot.gserviceaccount.com
|
|
3163
|
+
role: roles/resourcemanager.organizationAdmin
|
|
3164
|
+
- members:
|
|
3165
|
+
- user:eve@example.com
|
|
3166
|
+
role: roles/resourcemanager.organizationViewer
|
|
3167
|
+
condition:
|
|
3168
|
+
title: expirable access
|
|
3169
|
+
description: Does not grant access after Sep 2020
|
|
3170
|
+
expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
|
|
3171
|
+
|
|
3172
|
+
For a description of IAM and its features, see the `IAM
|
|
3173
|
+
developer's
|
|
3174
|
+
guide <https://cloud.google.com/iam/docs>`__.
|
|
3175
|
+
"""
|
|
3176
|
+
# Create or coerce a protobuf request object.
|
|
3177
|
+
|
|
3178
|
+
# The request isn't a proto-plus wrapped type,
|
|
3179
|
+
# so it must be constructed via keyword expansion.
|
|
3180
|
+
if isinstance(request, dict):
|
|
3181
|
+
request = iam_policy_pb2.SetIamPolicyRequest(**request)
|
|
3182
|
+
|
|
3183
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3184
|
+
# and friendly error handling.
|
|
3185
|
+
rpc = self._transport._wrapped_methods[self._transport.set_iam_policy]
|
|
3186
|
+
|
|
3187
|
+
# Certain fields should be provided within the metadata header;
|
|
3188
|
+
# add these here.
|
|
3189
|
+
metadata = tuple(metadata) + (
|
|
3190
|
+
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
|
|
3191
|
+
)
|
|
3192
|
+
|
|
3193
|
+
# Validate the universe domain.
|
|
3194
|
+
self._validate_universe_domain()
|
|
3195
|
+
|
|
3196
|
+
try:
|
|
3197
|
+
# Send the request.
|
|
3198
|
+
response = rpc(
|
|
3199
|
+
request,
|
|
3200
|
+
retry=retry,
|
|
3201
|
+
timeout=timeout,
|
|
3202
|
+
metadata=metadata,
|
|
3203
|
+
)
|
|
3204
|
+
|
|
3205
|
+
# Done; return the response.
|
|
3206
|
+
return response
|
|
3207
|
+
except core_exceptions.GoogleAPICallError as e:
|
|
3208
|
+
self._add_cred_info_for_auth_errors(e)
|
|
3209
|
+
raise e
|
|
3210
|
+
|
|
3211
|
+
def get_iam_policy(
|
|
3212
|
+
self,
|
|
3213
|
+
request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
|
|
3214
|
+
*,
|
|
3215
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3216
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3217
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3218
|
+
) -> policy_pb2.Policy:
|
|
3219
|
+
r"""Gets the IAM access control policy for a function.
|
|
3220
|
+
|
|
3221
|
+
Returns an empty policy if the function exists and does not have a
|
|
3222
|
+
policy set.
|
|
3223
|
+
|
|
3224
|
+
Args:
|
|
3225
|
+
request (:class:`~.iam_policy_pb2.GetIamPolicyRequest`):
|
|
3226
|
+
The request object. Request message for `GetIamPolicy`
|
|
3227
|
+
method.
|
|
3228
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if
|
|
3229
|
+
any, should be retried.
|
|
3230
|
+
timeout (float): The timeout for this request.
|
|
3231
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3232
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3233
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3234
|
+
be of type `bytes`.
|
|
3235
|
+
Returns:
|
|
3236
|
+
~.policy_pb2.Policy:
|
|
3237
|
+
Defines an Identity and Access Management (IAM) policy.
|
|
3238
|
+
It is used to specify access control policies for Cloud
|
|
3239
|
+
Platform resources.
|
|
3240
|
+
A ``Policy`` is a collection of ``bindings``. A
|
|
3241
|
+
``binding`` binds one or more ``members`` to a single
|
|
3242
|
+
``role``. Members can be user accounts, service
|
|
3243
|
+
accounts, Google groups, and domains (such as G Suite).
|
|
3244
|
+
A ``role`` is a named list of permissions (defined by
|
|
3245
|
+
IAM or configured by users). A ``binding`` can
|
|
3246
|
+
optionally specify a ``condition``, which is a logic
|
|
3247
|
+
expression that further constrains the role binding
|
|
3248
|
+
based on attributes about the request and/or target
|
|
3249
|
+
resource.
|
|
3250
|
+
|
|
3251
|
+
**JSON Example**
|
|
3252
|
+
|
|
3253
|
+
::
|
|
3254
|
+
|
|
3255
|
+
{
|
|
3256
|
+
"bindings": [
|
|
3257
|
+
{
|
|
3258
|
+
"role": "roles/resourcemanager.organizationAdmin",
|
|
3259
|
+
"members": [
|
|
3260
|
+
"user:mike@example.com",
|
|
3261
|
+
"group:admins@example.com",
|
|
3262
|
+
"domain:google.com",
|
|
3263
|
+
"serviceAccount:my-project-id@appspot.gserviceaccount.com"
|
|
3264
|
+
]
|
|
3265
|
+
},
|
|
3266
|
+
{
|
|
3267
|
+
"role": "roles/resourcemanager.organizationViewer",
|
|
3268
|
+
"members": ["user:eve@example.com"],
|
|
3269
|
+
"condition": {
|
|
3270
|
+
"title": "expirable access",
|
|
3271
|
+
"description": "Does not grant access after Sep 2020",
|
|
3272
|
+
"expression": "request.time <
|
|
3273
|
+
timestamp('2020-10-01T00:00:00.000Z')",
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
]
|
|
3277
|
+
}
|
|
3278
|
+
|
|
3279
|
+
**YAML Example**
|
|
3280
|
+
|
|
3281
|
+
::
|
|
3282
|
+
|
|
3283
|
+
bindings:
|
|
3284
|
+
- members:
|
|
3285
|
+
- user:mike@example.com
|
|
3286
|
+
- group:admins@example.com
|
|
3287
|
+
- domain:google.com
|
|
3288
|
+
- serviceAccount:my-project-id@appspot.gserviceaccount.com
|
|
3289
|
+
role: roles/resourcemanager.organizationAdmin
|
|
3290
|
+
- members:
|
|
3291
|
+
- user:eve@example.com
|
|
3292
|
+
role: roles/resourcemanager.organizationViewer
|
|
3293
|
+
condition:
|
|
3294
|
+
title: expirable access
|
|
3295
|
+
description: Does not grant access after Sep 2020
|
|
3296
|
+
expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
|
|
3297
|
+
|
|
3298
|
+
For a description of IAM and its features, see the `IAM
|
|
3299
|
+
developer's
|
|
3300
|
+
guide <https://cloud.google.com/iam/docs>`__.
|
|
3301
|
+
"""
|
|
3302
|
+
# Create or coerce a protobuf request object.
|
|
3303
|
+
|
|
3304
|
+
# The request isn't a proto-plus wrapped type,
|
|
3305
|
+
# so it must be constructed via keyword expansion.
|
|
3306
|
+
if isinstance(request, dict):
|
|
3307
|
+
request = iam_policy_pb2.GetIamPolicyRequest(**request)
|
|
3308
|
+
|
|
3309
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3310
|
+
# and friendly error handling.
|
|
3311
|
+
rpc = self._transport._wrapped_methods[self._transport.get_iam_policy]
|
|
3312
|
+
|
|
3313
|
+
# Certain fields should be provided within the metadata header;
|
|
3314
|
+
# add these here.
|
|
3315
|
+
metadata = tuple(metadata) + (
|
|
3316
|
+
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
|
|
3317
|
+
)
|
|
3318
|
+
|
|
3319
|
+
# Validate the universe domain.
|
|
3320
|
+
self._validate_universe_domain()
|
|
3321
|
+
|
|
3322
|
+
try:
|
|
3323
|
+
# Send the request.
|
|
3324
|
+
response = rpc(
|
|
3325
|
+
request,
|
|
3326
|
+
retry=retry,
|
|
3327
|
+
timeout=timeout,
|
|
3328
|
+
metadata=metadata,
|
|
3329
|
+
)
|
|
3330
|
+
|
|
3331
|
+
# Done; return the response.
|
|
3332
|
+
return response
|
|
3333
|
+
except core_exceptions.GoogleAPICallError as e:
|
|
3334
|
+
self._add_cred_info_for_auth_errors(e)
|
|
3335
|
+
raise e
|
|
3336
|
+
|
|
3337
|
+
def test_iam_permissions(
|
|
3338
|
+
self,
|
|
3339
|
+
request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
|
|
3340
|
+
*,
|
|
3341
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3342
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3343
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3344
|
+
) -> iam_policy_pb2.TestIamPermissionsResponse:
|
|
3345
|
+
r"""Tests the specified IAM permissions against the IAM access control
|
|
3346
|
+
policy for a function.
|
|
3347
|
+
|
|
3348
|
+
If the function does not exist, this will return an empty set
|
|
3349
|
+
of permissions, not a NOT_FOUND error.
|
|
3350
|
+
|
|
3351
|
+
Args:
|
|
3352
|
+
request (:class:`~.iam_policy_pb2.TestIamPermissionsRequest`):
|
|
3353
|
+
The request object. Request message for
|
|
3354
|
+
`TestIamPermissions` method.
|
|
3355
|
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
|
3356
|
+
if any, should be retried.
|
|
3357
|
+
timeout (float): The timeout for this request.
|
|
3358
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3359
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3360
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3361
|
+
be of type `bytes`.
|
|
3362
|
+
Returns:
|
|
3363
|
+
~.iam_policy_pb2.TestIamPermissionsResponse:
|
|
3364
|
+
Response message for ``TestIamPermissions`` method.
|
|
3365
|
+
"""
|
|
3366
|
+
# Create or coerce a protobuf request object.
|
|
3367
|
+
|
|
3368
|
+
# The request isn't a proto-plus wrapped type,
|
|
3369
|
+
# so it must be constructed via keyword expansion.
|
|
3370
|
+
if isinstance(request, dict):
|
|
3371
|
+
request = iam_policy_pb2.TestIamPermissionsRequest(**request)
|
|
3372
|
+
|
|
3373
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3374
|
+
# and friendly error handling.
|
|
3375
|
+
rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions]
|
|
3376
|
+
|
|
3377
|
+
# Certain fields should be provided within the metadata header;
|
|
3378
|
+
# add these here.
|
|
3379
|
+
metadata = tuple(metadata) + (
|
|
3380
|
+
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
|
|
3381
|
+
)
|
|
3382
|
+
|
|
3383
|
+
# Validate the universe domain.
|
|
3384
|
+
self._validate_universe_domain()
|
|
3385
|
+
|
|
3386
|
+
try:
|
|
3387
|
+
# Send the request.
|
|
3388
|
+
response = rpc(
|
|
3389
|
+
request,
|
|
3390
|
+
retry=retry,
|
|
3391
|
+
timeout=timeout,
|
|
3392
|
+
metadata=metadata,
|
|
3393
|
+
)
|
|
3394
|
+
|
|
3395
|
+
# Done; return the response.
|
|
3396
|
+
return response
|
|
3397
|
+
except core_exceptions.GoogleAPICallError as e:
|
|
3398
|
+
self._add_cred_info_for_auth_errors(e)
|
|
3399
|
+
raise e
|
|
3400
|
+
|
|
3401
|
+
def get_location(
|
|
3402
|
+
self,
|
|
3403
|
+
request: Optional[locations_pb2.GetLocationRequest] = None,
|
|
3404
|
+
*,
|
|
3405
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3406
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3407
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3408
|
+
) -> locations_pb2.Location:
|
|
3409
|
+
r"""Gets information about a location.
|
|
3410
|
+
|
|
3411
|
+
Args:
|
|
3412
|
+
request (:class:`~.location_pb2.GetLocationRequest`):
|
|
3413
|
+
The request object. Request message for
|
|
3414
|
+
`GetLocation` method.
|
|
3415
|
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
|
3416
|
+
if any, should be retried.
|
|
3417
|
+
timeout (float): The timeout for this request.
|
|
3418
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3419
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3420
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3421
|
+
be of type `bytes`.
|
|
3422
|
+
Returns:
|
|
3423
|
+
~.location_pb2.Location:
|
|
3424
|
+
Location object.
|
|
3425
|
+
"""
|
|
3426
|
+
# Create or coerce a protobuf request object.
|
|
3427
|
+
# The request isn't a proto-plus wrapped type,
|
|
3428
|
+
# so it must be constructed via keyword expansion.
|
|
3429
|
+
if isinstance(request, dict):
|
|
3430
|
+
request = locations_pb2.GetLocationRequest(**request)
|
|
3431
|
+
|
|
3432
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3433
|
+
# and friendly error handling.
|
|
3434
|
+
rpc = self._transport._wrapped_methods[self._transport.get_location]
|
|
3435
|
+
|
|
3436
|
+
# Certain fields should be provided within the metadata header;
|
|
3437
|
+
# add these here.
|
|
3438
|
+
metadata = tuple(metadata) + (
|
|
3439
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
3440
|
+
)
|
|
3441
|
+
|
|
3442
|
+
# Validate the universe domain.
|
|
3443
|
+
self._validate_universe_domain()
|
|
3444
|
+
|
|
3445
|
+
try:
|
|
3446
|
+
# Send the request.
|
|
3447
|
+
response = rpc(
|
|
3448
|
+
request,
|
|
3449
|
+
retry=retry,
|
|
3450
|
+
timeout=timeout,
|
|
3451
|
+
metadata=metadata,
|
|
3452
|
+
)
|
|
3453
|
+
|
|
3454
|
+
# Done; return the response.
|
|
3455
|
+
return response
|
|
3456
|
+
except core_exceptions.GoogleAPICallError as e:
|
|
3457
|
+
self._add_cred_info_for_auth_errors(e)
|
|
3458
|
+
raise e
|
|
3459
|
+
|
|
3460
|
+
def list_locations(
|
|
3461
|
+
self,
|
|
3462
|
+
request: Optional[locations_pb2.ListLocationsRequest] = None,
|
|
3463
|
+
*,
|
|
3464
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
3465
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
3466
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
3467
|
+
) -> locations_pb2.ListLocationsResponse:
|
|
3468
|
+
r"""Lists information about the supported locations for this service.
|
|
3469
|
+
|
|
3470
|
+
Args:
|
|
3471
|
+
request (:class:`~.location_pb2.ListLocationsRequest`):
|
|
3472
|
+
The request object. Request message for
|
|
3473
|
+
`ListLocations` method.
|
|
3474
|
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
|
3475
|
+
if any, should be retried.
|
|
3476
|
+
timeout (float): The timeout for this request.
|
|
3477
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
3478
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
3479
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
3480
|
+
be of type `bytes`.
|
|
3481
|
+
Returns:
|
|
3482
|
+
~.location_pb2.ListLocationsResponse:
|
|
3483
|
+
Response message for ``ListLocations`` method.
|
|
3484
|
+
"""
|
|
3485
|
+
# Create or coerce a protobuf request object.
|
|
3486
|
+
# The request isn't a proto-plus wrapped type,
|
|
3487
|
+
# so it must be constructed via keyword expansion.
|
|
3488
|
+
if isinstance(request, dict):
|
|
3489
|
+
request = locations_pb2.ListLocationsRequest(**request)
|
|
3490
|
+
|
|
3491
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
3492
|
+
# and friendly error handling.
|
|
3493
|
+
rpc = self._transport._wrapped_methods[self._transport.list_locations]
|
|
3494
|
+
|
|
3495
|
+
# Certain fields should be provided within the metadata header;
|
|
3496
|
+
# add these here.
|
|
3497
|
+
metadata = tuple(metadata) + (
|
|
3498
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
3499
|
+
)
|
|
3500
|
+
|
|
3501
|
+
# Validate the universe domain.
|
|
3502
|
+
self._validate_universe_domain()
|
|
3503
|
+
|
|
3504
|
+
try:
|
|
3505
|
+
# Send the request.
|
|
3506
|
+
response = rpc(
|
|
3507
|
+
request,
|
|
3508
|
+
retry=retry,
|
|
3509
|
+
timeout=timeout,
|
|
3510
|
+
metadata=metadata,
|
|
3511
|
+
)
|
|
3512
|
+
|
|
3513
|
+
# Done; return the response.
|
|
3514
|
+
return response
|
|
3515
|
+
except core_exceptions.GoogleAPICallError as e:
|
|
3516
|
+
self._add_cred_info_for_auth_errors(e)
|
|
3517
|
+
raise e
|
|
3518
|
+
|
|
3519
|
+
|
|
3520
|
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
3521
|
+
gapic_version=package_version.__version__
|
|
3522
|
+
)
|
|
3523
|
+
|
|
3524
|
+
|
|
3525
|
+
__all__ = ("NetworkSecurityClient",)
|