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