google-cloud-privilegedaccessmanager 0.1.0__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/privilegedaccessmanager/__init__.py +87 -0
- google/cloud/privilegedaccessmanager/gapic_version.py +16 -0
- google/cloud/privilegedaccessmanager/py.typed +2 -0
- google/cloud/privilegedaccessmanager_v1/__init__.py +85 -0
- google/cloud/privilegedaccessmanager_v1/gapic_metadata.json +238 -0
- google/cloud/privilegedaccessmanager_v1/gapic_version.py +16 -0
- google/cloud/privilegedaccessmanager_v1/py.typed +2 -0
- google/cloud/privilegedaccessmanager_v1/services/__init__.py +15 -0
- google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/__init__.py +22 -0
- google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/async_client.py +2184 -0
- google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/client.py +2595 -0
- google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/pagers.py +549 -0
- google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/__init__.py +41 -0
- google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/base.py +414 -0
- google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/grpc.py +806 -0
- google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/grpc_asyncio.py +891 -0
- google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/transports/rest.py +2765 -0
- google/cloud/privilegedaccessmanager_v1/types/__init__.py +74 -0
- google/cloud/privilegedaccessmanager_v1/types/privilegedaccessmanager.py +1730 -0
- google_cloud_privilegedaccessmanager-0.1.0.dist-info/LICENSE +202 -0
- google_cloud_privilegedaccessmanager-0.1.0.dist-info/METADATA +137 -0
- google_cloud_privilegedaccessmanager-0.1.0.dist-info/RECORD +24 -0
- google_cloud_privilegedaccessmanager-0.1.0.dist-info/WHEEL +5 -0
- google_cloud_privilegedaccessmanager-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,2184 @@
|
|
|
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 functools
|
|
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.privilegedaccessmanager_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.longrunning import operations_pb2 # type: ignore
|
|
50
|
+
from google.protobuf import duration_pb2 # type: ignore
|
|
51
|
+
from google.protobuf import field_mask_pb2 # type: ignore
|
|
52
|
+
from google.protobuf import timestamp_pb2 # type: ignore
|
|
53
|
+
|
|
54
|
+
from google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager import (
|
|
55
|
+
pagers,
|
|
56
|
+
)
|
|
57
|
+
from google.cloud.privilegedaccessmanager_v1.types import privilegedaccessmanager
|
|
58
|
+
|
|
59
|
+
from .client import PrivilegedAccessManagerClient
|
|
60
|
+
from .transports.base import DEFAULT_CLIENT_INFO, PrivilegedAccessManagerTransport
|
|
61
|
+
from .transports.grpc_asyncio import PrivilegedAccessManagerGrpcAsyncIOTransport
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class PrivilegedAccessManagerAsyncClient:
|
|
65
|
+
"""This API allows customers to manage temporary, request based
|
|
66
|
+
privileged access to their resources.
|
|
67
|
+
|
|
68
|
+
It defines the following resource model:
|
|
69
|
+
|
|
70
|
+
- A collection of ``Entitlement`` resources. An entitlement allows
|
|
71
|
+
configuring (among other things):
|
|
72
|
+
|
|
73
|
+
- Some kind of privileged access that users can request.
|
|
74
|
+
- A set of users called *requesters* who can request this
|
|
75
|
+
access.
|
|
76
|
+
- A maximum duration for which the access can be requested.
|
|
77
|
+
- An optional approval workflow which must be satisfied before
|
|
78
|
+
access is granted.
|
|
79
|
+
|
|
80
|
+
- A collection of ``Grant`` resources. A grant is a request by a
|
|
81
|
+
requester to get the privileged access specified in an
|
|
82
|
+
entitlement for some duration.
|
|
83
|
+
|
|
84
|
+
After the approval workflow as specified in the entitlement is
|
|
85
|
+
satisfied, the specified access is given to the requester. The
|
|
86
|
+
access is automatically taken back after the requested duration
|
|
87
|
+
is over.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
_client: PrivilegedAccessManagerClient
|
|
91
|
+
|
|
92
|
+
# Copy defaults from the synchronous client for use here.
|
|
93
|
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
|
94
|
+
DEFAULT_ENDPOINT = PrivilegedAccessManagerClient.DEFAULT_ENDPOINT
|
|
95
|
+
DEFAULT_MTLS_ENDPOINT = PrivilegedAccessManagerClient.DEFAULT_MTLS_ENDPOINT
|
|
96
|
+
_DEFAULT_ENDPOINT_TEMPLATE = (
|
|
97
|
+
PrivilegedAccessManagerClient._DEFAULT_ENDPOINT_TEMPLATE
|
|
98
|
+
)
|
|
99
|
+
_DEFAULT_UNIVERSE = PrivilegedAccessManagerClient._DEFAULT_UNIVERSE
|
|
100
|
+
|
|
101
|
+
entitlement_path = staticmethod(PrivilegedAccessManagerClient.entitlement_path)
|
|
102
|
+
parse_entitlement_path = staticmethod(
|
|
103
|
+
PrivilegedAccessManagerClient.parse_entitlement_path
|
|
104
|
+
)
|
|
105
|
+
grant_path = staticmethod(PrivilegedAccessManagerClient.grant_path)
|
|
106
|
+
parse_grant_path = staticmethod(PrivilegedAccessManagerClient.parse_grant_path)
|
|
107
|
+
common_billing_account_path = staticmethod(
|
|
108
|
+
PrivilegedAccessManagerClient.common_billing_account_path
|
|
109
|
+
)
|
|
110
|
+
parse_common_billing_account_path = staticmethod(
|
|
111
|
+
PrivilegedAccessManagerClient.parse_common_billing_account_path
|
|
112
|
+
)
|
|
113
|
+
common_folder_path = staticmethod(PrivilegedAccessManagerClient.common_folder_path)
|
|
114
|
+
parse_common_folder_path = staticmethod(
|
|
115
|
+
PrivilegedAccessManagerClient.parse_common_folder_path
|
|
116
|
+
)
|
|
117
|
+
common_organization_path = staticmethod(
|
|
118
|
+
PrivilegedAccessManagerClient.common_organization_path
|
|
119
|
+
)
|
|
120
|
+
parse_common_organization_path = staticmethod(
|
|
121
|
+
PrivilegedAccessManagerClient.parse_common_organization_path
|
|
122
|
+
)
|
|
123
|
+
common_project_path = staticmethod(
|
|
124
|
+
PrivilegedAccessManagerClient.common_project_path
|
|
125
|
+
)
|
|
126
|
+
parse_common_project_path = staticmethod(
|
|
127
|
+
PrivilegedAccessManagerClient.parse_common_project_path
|
|
128
|
+
)
|
|
129
|
+
common_location_path = staticmethod(
|
|
130
|
+
PrivilegedAccessManagerClient.common_location_path
|
|
131
|
+
)
|
|
132
|
+
parse_common_location_path = staticmethod(
|
|
133
|
+
PrivilegedAccessManagerClient.parse_common_location_path
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
@classmethod
|
|
137
|
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
|
138
|
+
"""Creates an instance of this client using the provided credentials
|
|
139
|
+
info.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
info (dict): The service account private key info.
|
|
143
|
+
args: Additional arguments to pass to the constructor.
|
|
144
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
PrivilegedAccessManagerAsyncClient: The constructed client.
|
|
148
|
+
"""
|
|
149
|
+
return PrivilegedAccessManagerClient.from_service_account_info.__func__(PrivilegedAccessManagerAsyncClient, info, *args, **kwargs) # type: ignore
|
|
150
|
+
|
|
151
|
+
@classmethod
|
|
152
|
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
|
153
|
+
"""Creates an instance of this client using the provided credentials
|
|
154
|
+
file.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
filename (str): The path to the service account private key json
|
|
158
|
+
file.
|
|
159
|
+
args: Additional arguments to pass to the constructor.
|
|
160
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
PrivilegedAccessManagerAsyncClient: The constructed client.
|
|
164
|
+
"""
|
|
165
|
+
return PrivilegedAccessManagerClient.from_service_account_file.__func__(PrivilegedAccessManagerAsyncClient, filename, *args, **kwargs) # type: ignore
|
|
166
|
+
|
|
167
|
+
from_service_account_json = from_service_account_file
|
|
168
|
+
|
|
169
|
+
@classmethod
|
|
170
|
+
def get_mtls_endpoint_and_cert_source(
|
|
171
|
+
cls, client_options: Optional[ClientOptions] = None
|
|
172
|
+
):
|
|
173
|
+
"""Return the API endpoint and client cert source for mutual TLS.
|
|
174
|
+
|
|
175
|
+
The client cert source is determined in the following order:
|
|
176
|
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
|
177
|
+
client cert source is None.
|
|
178
|
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
|
179
|
+
default client cert source exists, use the default one; otherwise the client cert
|
|
180
|
+
source is None.
|
|
181
|
+
|
|
182
|
+
The API endpoint is determined in the following order:
|
|
183
|
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
|
184
|
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
|
185
|
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
|
186
|
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
|
187
|
+
use the default API endpoint.
|
|
188
|
+
|
|
189
|
+
More details can be found at https://google.aip.dev/auth/4114.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
|
193
|
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
|
194
|
+
in this method.
|
|
195
|
+
|
|
196
|
+
Returns:
|
|
197
|
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
|
198
|
+
client cert source to use.
|
|
199
|
+
|
|
200
|
+
Raises:
|
|
201
|
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
|
202
|
+
"""
|
|
203
|
+
return PrivilegedAccessManagerClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
|
|
204
|
+
|
|
205
|
+
@property
|
|
206
|
+
def transport(self) -> PrivilegedAccessManagerTransport:
|
|
207
|
+
"""Returns the transport used by the client instance.
|
|
208
|
+
|
|
209
|
+
Returns:
|
|
210
|
+
PrivilegedAccessManagerTransport: The transport used by the client instance.
|
|
211
|
+
"""
|
|
212
|
+
return self._client.transport
|
|
213
|
+
|
|
214
|
+
@property
|
|
215
|
+
def api_endpoint(self):
|
|
216
|
+
"""Return the API endpoint used by the client instance.
|
|
217
|
+
|
|
218
|
+
Returns:
|
|
219
|
+
str: The API endpoint used by the client instance.
|
|
220
|
+
"""
|
|
221
|
+
return self._client._api_endpoint
|
|
222
|
+
|
|
223
|
+
@property
|
|
224
|
+
def universe_domain(self) -> str:
|
|
225
|
+
"""Return the universe domain used by the client instance.
|
|
226
|
+
|
|
227
|
+
Returns:
|
|
228
|
+
str: The universe domain used
|
|
229
|
+
by the client instance.
|
|
230
|
+
"""
|
|
231
|
+
return self._client._universe_domain
|
|
232
|
+
|
|
233
|
+
get_transport_class = functools.partial(
|
|
234
|
+
type(PrivilegedAccessManagerClient).get_transport_class,
|
|
235
|
+
type(PrivilegedAccessManagerClient),
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
def __init__(
|
|
239
|
+
self,
|
|
240
|
+
*,
|
|
241
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
242
|
+
transport: Optional[
|
|
243
|
+
Union[
|
|
244
|
+
str,
|
|
245
|
+
PrivilegedAccessManagerTransport,
|
|
246
|
+
Callable[..., PrivilegedAccessManagerTransport],
|
|
247
|
+
]
|
|
248
|
+
] = "grpc_asyncio",
|
|
249
|
+
client_options: Optional[ClientOptions] = None,
|
|
250
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
251
|
+
) -> None:
|
|
252
|
+
"""Instantiates the privileged access manager async client.
|
|
253
|
+
|
|
254
|
+
Args:
|
|
255
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
256
|
+
authorization credentials to attach to requests. These
|
|
257
|
+
credentials identify the application to the service; if none
|
|
258
|
+
are specified, the client will attempt to ascertain the
|
|
259
|
+
credentials from the environment.
|
|
260
|
+
transport (Optional[Union[str,PrivilegedAccessManagerTransport,Callable[..., PrivilegedAccessManagerTransport]]]):
|
|
261
|
+
The transport to use, or a Callable that constructs and returns a new transport to use.
|
|
262
|
+
If a Callable is given, it will be called with the same set of initialization
|
|
263
|
+
arguments as used in the PrivilegedAccessManagerTransport constructor.
|
|
264
|
+
If set to None, a transport is chosen automatically.
|
|
265
|
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
|
266
|
+
Custom options for the client.
|
|
267
|
+
|
|
268
|
+
1. The ``api_endpoint`` property can be used to override the
|
|
269
|
+
default endpoint provided by the client when ``transport`` is
|
|
270
|
+
not explicitly provided. Only if this property is not set and
|
|
271
|
+
``transport`` was not explicitly provided, the endpoint is
|
|
272
|
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
|
273
|
+
variable, which have one of the following values:
|
|
274
|
+
"always" (always use the default mTLS endpoint), "never" (always
|
|
275
|
+
use the default regular endpoint) and "auto" (auto-switch to the
|
|
276
|
+
default mTLS endpoint if client certificate is present; this is
|
|
277
|
+
the default value).
|
|
278
|
+
|
|
279
|
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
|
280
|
+
is "true", then the ``client_cert_source`` property can be used
|
|
281
|
+
to provide a client certificate for mTLS transport. If
|
|
282
|
+
not provided, the default SSL client certificate will be used if
|
|
283
|
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
|
284
|
+
set, no client certificate will be used.
|
|
285
|
+
|
|
286
|
+
3. The ``universe_domain`` property can be used to override the
|
|
287
|
+
default "googleapis.com" universe. Note that ``api_endpoint``
|
|
288
|
+
property still takes precedence; and ``universe_domain`` is
|
|
289
|
+
currently not supported for mTLS.
|
|
290
|
+
|
|
291
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
292
|
+
The client info used to send a user-agent string along with
|
|
293
|
+
API requests. If ``None``, then default info will be used.
|
|
294
|
+
Generally, you only need to set this if you're developing
|
|
295
|
+
your own client library.
|
|
296
|
+
|
|
297
|
+
Raises:
|
|
298
|
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
|
299
|
+
creation failed for any reason.
|
|
300
|
+
"""
|
|
301
|
+
self._client = PrivilegedAccessManagerClient(
|
|
302
|
+
credentials=credentials,
|
|
303
|
+
transport=transport,
|
|
304
|
+
client_options=client_options,
|
|
305
|
+
client_info=client_info,
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
async def check_onboarding_status(
|
|
309
|
+
self,
|
|
310
|
+
request: Optional[
|
|
311
|
+
Union[privilegedaccessmanager.CheckOnboardingStatusRequest, dict]
|
|
312
|
+
] = None,
|
|
313
|
+
*,
|
|
314
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
315
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
316
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
317
|
+
) -> privilegedaccessmanager.CheckOnboardingStatusResponse:
|
|
318
|
+
r"""CheckOnboardingStatus reports the onboarding status
|
|
319
|
+
for a project/folder/organization. Any findings reported
|
|
320
|
+
by this API need to be fixed before PAM can be used on
|
|
321
|
+
the resource.
|
|
322
|
+
|
|
323
|
+
.. code-block:: python
|
|
324
|
+
|
|
325
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
326
|
+
# code template only.
|
|
327
|
+
# It will require modifications to work:
|
|
328
|
+
# - It may require correct/in-range values for request initialization.
|
|
329
|
+
# - It may require specifying regional endpoints when creating the service
|
|
330
|
+
# client as shown in:
|
|
331
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
332
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
333
|
+
|
|
334
|
+
async def sample_check_onboarding_status():
|
|
335
|
+
# Create a client
|
|
336
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
337
|
+
|
|
338
|
+
# Initialize request argument(s)
|
|
339
|
+
request = privilegedaccessmanager_v1.CheckOnboardingStatusRequest(
|
|
340
|
+
parent="parent_value",
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
# Make the request
|
|
344
|
+
response = await client.check_onboarding_status(request=request)
|
|
345
|
+
|
|
346
|
+
# Handle the response
|
|
347
|
+
print(response)
|
|
348
|
+
|
|
349
|
+
Args:
|
|
350
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.CheckOnboardingStatusRequest, dict]]):
|
|
351
|
+
The request object. Request message for ``CheckOnboardingStatus`` method.
|
|
352
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
353
|
+
should be retried.
|
|
354
|
+
timeout (float): The timeout for this request.
|
|
355
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
356
|
+
sent along with the request as metadata.
|
|
357
|
+
|
|
358
|
+
Returns:
|
|
359
|
+
google.cloud.privilegedaccessmanager_v1.types.CheckOnboardingStatusResponse:
|
|
360
|
+
Response message for CheckOnboardingStatus method.
|
|
361
|
+
"""
|
|
362
|
+
# Create or coerce a protobuf request object.
|
|
363
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
364
|
+
# there are no flattened fields), or create one.
|
|
365
|
+
if not isinstance(
|
|
366
|
+
request, privilegedaccessmanager.CheckOnboardingStatusRequest
|
|
367
|
+
):
|
|
368
|
+
request = privilegedaccessmanager.CheckOnboardingStatusRequest(request)
|
|
369
|
+
|
|
370
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
371
|
+
# and friendly error handling.
|
|
372
|
+
rpc = self._client._transport._wrapped_methods[
|
|
373
|
+
self._client._transport.check_onboarding_status
|
|
374
|
+
]
|
|
375
|
+
|
|
376
|
+
# Certain fields should be provided within the metadata header;
|
|
377
|
+
# add these here.
|
|
378
|
+
metadata = tuple(metadata) + (
|
|
379
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
# Validate the universe domain.
|
|
383
|
+
self._client._validate_universe_domain()
|
|
384
|
+
|
|
385
|
+
# Send the request.
|
|
386
|
+
response = await rpc(
|
|
387
|
+
request,
|
|
388
|
+
retry=retry,
|
|
389
|
+
timeout=timeout,
|
|
390
|
+
metadata=metadata,
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
# Done; return the response.
|
|
394
|
+
return response
|
|
395
|
+
|
|
396
|
+
async def list_entitlements(
|
|
397
|
+
self,
|
|
398
|
+
request: Optional[
|
|
399
|
+
Union[privilegedaccessmanager.ListEntitlementsRequest, dict]
|
|
400
|
+
] = None,
|
|
401
|
+
*,
|
|
402
|
+
parent: Optional[str] = None,
|
|
403
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
404
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
405
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
406
|
+
) -> pagers.ListEntitlementsAsyncPager:
|
|
407
|
+
r"""Lists entitlements in a given
|
|
408
|
+
project/folder/organization and location.
|
|
409
|
+
|
|
410
|
+
.. code-block:: python
|
|
411
|
+
|
|
412
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
413
|
+
# code template only.
|
|
414
|
+
# It will require modifications to work:
|
|
415
|
+
# - It may require correct/in-range values for request initialization.
|
|
416
|
+
# - It may require specifying regional endpoints when creating the service
|
|
417
|
+
# client as shown in:
|
|
418
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
419
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
420
|
+
|
|
421
|
+
async def sample_list_entitlements():
|
|
422
|
+
# Create a client
|
|
423
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
424
|
+
|
|
425
|
+
# Initialize request argument(s)
|
|
426
|
+
request = privilegedaccessmanager_v1.ListEntitlementsRequest(
|
|
427
|
+
parent="parent_value",
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
# Make the request
|
|
431
|
+
page_result = client.list_entitlements(request=request)
|
|
432
|
+
|
|
433
|
+
# Handle the response
|
|
434
|
+
async for response in page_result:
|
|
435
|
+
print(response)
|
|
436
|
+
|
|
437
|
+
Args:
|
|
438
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.ListEntitlementsRequest, dict]]):
|
|
439
|
+
The request object. Message for requesting list of
|
|
440
|
+
entitlements.
|
|
441
|
+
parent (:class:`str`):
|
|
442
|
+
Required. The parent which owns the
|
|
443
|
+
entitlement resources.
|
|
444
|
+
|
|
445
|
+
This corresponds to the ``parent`` field
|
|
446
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
447
|
+
should not be set.
|
|
448
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
449
|
+
should be retried.
|
|
450
|
+
timeout (float): The timeout for this request.
|
|
451
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
452
|
+
sent along with the request as metadata.
|
|
453
|
+
|
|
454
|
+
Returns:
|
|
455
|
+
google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.ListEntitlementsAsyncPager:
|
|
456
|
+
Message for response to listing
|
|
457
|
+
entitlements.
|
|
458
|
+
Iterating over this object will yield
|
|
459
|
+
results and resolve additional pages
|
|
460
|
+
automatically.
|
|
461
|
+
|
|
462
|
+
"""
|
|
463
|
+
# Create or coerce a protobuf request object.
|
|
464
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
465
|
+
# gotten any keyword arguments that map to the request.
|
|
466
|
+
has_flattened_params = any([parent])
|
|
467
|
+
if request is not None and has_flattened_params:
|
|
468
|
+
raise ValueError(
|
|
469
|
+
"If the `request` argument is set, then none of "
|
|
470
|
+
"the individual field arguments should be set."
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
474
|
+
# there are no flattened fields), or create one.
|
|
475
|
+
if not isinstance(request, privilegedaccessmanager.ListEntitlementsRequest):
|
|
476
|
+
request = privilegedaccessmanager.ListEntitlementsRequest(request)
|
|
477
|
+
|
|
478
|
+
# If we have keyword arguments corresponding to fields on the
|
|
479
|
+
# request, apply these.
|
|
480
|
+
if parent is not None:
|
|
481
|
+
request.parent = parent
|
|
482
|
+
|
|
483
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
484
|
+
# and friendly error handling.
|
|
485
|
+
rpc = self._client._transport._wrapped_methods[
|
|
486
|
+
self._client._transport.list_entitlements
|
|
487
|
+
]
|
|
488
|
+
|
|
489
|
+
# Certain fields should be provided within the metadata header;
|
|
490
|
+
# add these here.
|
|
491
|
+
metadata = tuple(metadata) + (
|
|
492
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
493
|
+
)
|
|
494
|
+
|
|
495
|
+
# Validate the universe domain.
|
|
496
|
+
self._client._validate_universe_domain()
|
|
497
|
+
|
|
498
|
+
# Send the request.
|
|
499
|
+
response = await rpc(
|
|
500
|
+
request,
|
|
501
|
+
retry=retry,
|
|
502
|
+
timeout=timeout,
|
|
503
|
+
metadata=metadata,
|
|
504
|
+
)
|
|
505
|
+
|
|
506
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
507
|
+
# an `__aiter__` convenience method.
|
|
508
|
+
response = pagers.ListEntitlementsAsyncPager(
|
|
509
|
+
method=rpc,
|
|
510
|
+
request=request,
|
|
511
|
+
response=response,
|
|
512
|
+
metadata=metadata,
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
# Done; return the response.
|
|
516
|
+
return response
|
|
517
|
+
|
|
518
|
+
async def search_entitlements(
|
|
519
|
+
self,
|
|
520
|
+
request: Optional[
|
|
521
|
+
Union[privilegedaccessmanager.SearchEntitlementsRequest, dict]
|
|
522
|
+
] = None,
|
|
523
|
+
*,
|
|
524
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
525
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
526
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
527
|
+
) -> pagers.SearchEntitlementsAsyncPager:
|
|
528
|
+
r"""``SearchEntitlements`` returns entitlements on which the caller
|
|
529
|
+
has the specified access.
|
|
530
|
+
|
|
531
|
+
.. code-block:: python
|
|
532
|
+
|
|
533
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
534
|
+
# code template only.
|
|
535
|
+
# It will require modifications to work:
|
|
536
|
+
# - It may require correct/in-range values for request initialization.
|
|
537
|
+
# - It may require specifying regional endpoints when creating the service
|
|
538
|
+
# client as shown in:
|
|
539
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
540
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
541
|
+
|
|
542
|
+
async def sample_search_entitlements():
|
|
543
|
+
# Create a client
|
|
544
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
545
|
+
|
|
546
|
+
# Initialize request argument(s)
|
|
547
|
+
request = privilegedaccessmanager_v1.SearchEntitlementsRequest(
|
|
548
|
+
parent="parent_value",
|
|
549
|
+
caller_access_type="GRANT_APPROVER",
|
|
550
|
+
)
|
|
551
|
+
|
|
552
|
+
# Make the request
|
|
553
|
+
page_result = client.search_entitlements(request=request)
|
|
554
|
+
|
|
555
|
+
# Handle the response
|
|
556
|
+
async for response in page_result:
|
|
557
|
+
print(response)
|
|
558
|
+
|
|
559
|
+
Args:
|
|
560
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.SearchEntitlementsRequest, dict]]):
|
|
561
|
+
The request object. Request message for ``SearchEntitlements`` method.
|
|
562
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
563
|
+
should be retried.
|
|
564
|
+
timeout (float): The timeout for this request.
|
|
565
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
566
|
+
sent along with the request as metadata.
|
|
567
|
+
|
|
568
|
+
Returns:
|
|
569
|
+
google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.SearchEntitlementsAsyncPager:
|
|
570
|
+
Response message for SearchEntitlements method.
|
|
571
|
+
|
|
572
|
+
Iterating over this object will yield results and
|
|
573
|
+
resolve additional pages automatically.
|
|
574
|
+
|
|
575
|
+
"""
|
|
576
|
+
# Create or coerce a protobuf request object.
|
|
577
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
578
|
+
# there are no flattened fields), or create one.
|
|
579
|
+
if not isinstance(request, privilegedaccessmanager.SearchEntitlementsRequest):
|
|
580
|
+
request = privilegedaccessmanager.SearchEntitlementsRequest(request)
|
|
581
|
+
|
|
582
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
583
|
+
# and friendly error handling.
|
|
584
|
+
rpc = self._client._transport._wrapped_methods[
|
|
585
|
+
self._client._transport.search_entitlements
|
|
586
|
+
]
|
|
587
|
+
|
|
588
|
+
# Certain fields should be provided within the metadata header;
|
|
589
|
+
# add these here.
|
|
590
|
+
metadata = tuple(metadata) + (
|
|
591
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
592
|
+
)
|
|
593
|
+
|
|
594
|
+
# Validate the universe domain.
|
|
595
|
+
self._client._validate_universe_domain()
|
|
596
|
+
|
|
597
|
+
# Send the request.
|
|
598
|
+
response = await rpc(
|
|
599
|
+
request,
|
|
600
|
+
retry=retry,
|
|
601
|
+
timeout=timeout,
|
|
602
|
+
metadata=metadata,
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
606
|
+
# an `__aiter__` convenience method.
|
|
607
|
+
response = pagers.SearchEntitlementsAsyncPager(
|
|
608
|
+
method=rpc,
|
|
609
|
+
request=request,
|
|
610
|
+
response=response,
|
|
611
|
+
metadata=metadata,
|
|
612
|
+
)
|
|
613
|
+
|
|
614
|
+
# Done; return the response.
|
|
615
|
+
return response
|
|
616
|
+
|
|
617
|
+
async def get_entitlement(
|
|
618
|
+
self,
|
|
619
|
+
request: Optional[
|
|
620
|
+
Union[privilegedaccessmanager.GetEntitlementRequest, dict]
|
|
621
|
+
] = None,
|
|
622
|
+
*,
|
|
623
|
+
name: Optional[str] = None,
|
|
624
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
625
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
626
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
627
|
+
) -> privilegedaccessmanager.Entitlement:
|
|
628
|
+
r"""Gets details of a single entitlement.
|
|
629
|
+
|
|
630
|
+
.. code-block:: python
|
|
631
|
+
|
|
632
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
633
|
+
# code template only.
|
|
634
|
+
# It will require modifications to work:
|
|
635
|
+
# - It may require correct/in-range values for request initialization.
|
|
636
|
+
# - It may require specifying regional endpoints when creating the service
|
|
637
|
+
# client as shown in:
|
|
638
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
639
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
640
|
+
|
|
641
|
+
async def sample_get_entitlement():
|
|
642
|
+
# Create a client
|
|
643
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
644
|
+
|
|
645
|
+
# Initialize request argument(s)
|
|
646
|
+
request = privilegedaccessmanager_v1.GetEntitlementRequest(
|
|
647
|
+
name="name_value",
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
# Make the request
|
|
651
|
+
response = await client.get_entitlement(request=request)
|
|
652
|
+
|
|
653
|
+
# Handle the response
|
|
654
|
+
print(response)
|
|
655
|
+
|
|
656
|
+
Args:
|
|
657
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.GetEntitlementRequest, dict]]):
|
|
658
|
+
The request object. Message for getting an entitlement.
|
|
659
|
+
name (:class:`str`):
|
|
660
|
+
Required. Name of the resource.
|
|
661
|
+
This corresponds to the ``name`` field
|
|
662
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
663
|
+
should not be set.
|
|
664
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
665
|
+
should be retried.
|
|
666
|
+
timeout (float): The timeout for this request.
|
|
667
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
668
|
+
sent along with the request as metadata.
|
|
669
|
+
|
|
670
|
+
Returns:
|
|
671
|
+
google.cloud.privilegedaccessmanager_v1.types.Entitlement:
|
|
672
|
+
An entitlement defines the
|
|
673
|
+
eligibility of a set of users to obtain
|
|
674
|
+
predefined access for some time possibly
|
|
675
|
+
after going through an approval
|
|
676
|
+
workflow.
|
|
677
|
+
|
|
678
|
+
"""
|
|
679
|
+
# Create or coerce a protobuf request object.
|
|
680
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
681
|
+
# gotten any keyword arguments that map to the request.
|
|
682
|
+
has_flattened_params = any([name])
|
|
683
|
+
if request is not None and has_flattened_params:
|
|
684
|
+
raise ValueError(
|
|
685
|
+
"If the `request` argument is set, then none of "
|
|
686
|
+
"the individual field arguments should be set."
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
690
|
+
# there are no flattened fields), or create one.
|
|
691
|
+
if not isinstance(request, privilegedaccessmanager.GetEntitlementRequest):
|
|
692
|
+
request = privilegedaccessmanager.GetEntitlementRequest(request)
|
|
693
|
+
|
|
694
|
+
# If we have keyword arguments corresponding to fields on the
|
|
695
|
+
# request, apply these.
|
|
696
|
+
if name is not None:
|
|
697
|
+
request.name = name
|
|
698
|
+
|
|
699
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
700
|
+
# and friendly error handling.
|
|
701
|
+
rpc = self._client._transport._wrapped_methods[
|
|
702
|
+
self._client._transport.get_entitlement
|
|
703
|
+
]
|
|
704
|
+
|
|
705
|
+
# Certain fields should be provided within the metadata header;
|
|
706
|
+
# add these here.
|
|
707
|
+
metadata = tuple(metadata) + (
|
|
708
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
709
|
+
)
|
|
710
|
+
|
|
711
|
+
# Validate the universe domain.
|
|
712
|
+
self._client._validate_universe_domain()
|
|
713
|
+
|
|
714
|
+
# Send the request.
|
|
715
|
+
response = await rpc(
|
|
716
|
+
request,
|
|
717
|
+
retry=retry,
|
|
718
|
+
timeout=timeout,
|
|
719
|
+
metadata=metadata,
|
|
720
|
+
)
|
|
721
|
+
|
|
722
|
+
# Done; return the response.
|
|
723
|
+
return response
|
|
724
|
+
|
|
725
|
+
async def create_entitlement(
|
|
726
|
+
self,
|
|
727
|
+
request: Optional[
|
|
728
|
+
Union[privilegedaccessmanager.CreateEntitlementRequest, dict]
|
|
729
|
+
] = None,
|
|
730
|
+
*,
|
|
731
|
+
parent: Optional[str] = None,
|
|
732
|
+
entitlement: Optional[privilegedaccessmanager.Entitlement] = None,
|
|
733
|
+
entitlement_id: Optional[str] = None,
|
|
734
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
735
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
736
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
737
|
+
) -> operation_async.AsyncOperation:
|
|
738
|
+
r"""Creates a new entitlement in a given
|
|
739
|
+
project/folder/organization and location.
|
|
740
|
+
|
|
741
|
+
.. code-block:: python
|
|
742
|
+
|
|
743
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
744
|
+
# code template only.
|
|
745
|
+
# It will require modifications to work:
|
|
746
|
+
# - It may require correct/in-range values for request initialization.
|
|
747
|
+
# - It may require specifying regional endpoints when creating the service
|
|
748
|
+
# client as shown in:
|
|
749
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
750
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
751
|
+
|
|
752
|
+
async def sample_create_entitlement():
|
|
753
|
+
# Create a client
|
|
754
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
755
|
+
|
|
756
|
+
# Initialize request argument(s)
|
|
757
|
+
request = privilegedaccessmanager_v1.CreateEntitlementRequest(
|
|
758
|
+
parent="parent_value",
|
|
759
|
+
entitlement_id="entitlement_id_value",
|
|
760
|
+
)
|
|
761
|
+
|
|
762
|
+
# Make the request
|
|
763
|
+
operation = client.create_entitlement(request=request)
|
|
764
|
+
|
|
765
|
+
print("Waiting for operation to complete...")
|
|
766
|
+
|
|
767
|
+
response = (await operation).result()
|
|
768
|
+
|
|
769
|
+
# Handle the response
|
|
770
|
+
print(response)
|
|
771
|
+
|
|
772
|
+
Args:
|
|
773
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.CreateEntitlementRequest, dict]]):
|
|
774
|
+
The request object. Message for creating an entitlement.
|
|
775
|
+
parent (:class:`str`):
|
|
776
|
+
Required. Name of the parent resource for the
|
|
777
|
+
entitlement. Possible formats:
|
|
778
|
+
|
|
779
|
+
- ``organizations/{organization-number}/locations/{region}``
|
|
780
|
+
- ``folders/{folder-number}/locations/{region}``
|
|
781
|
+
- ``projects/{project-id|project-number}/locations/{region}``
|
|
782
|
+
|
|
783
|
+
This corresponds to the ``parent`` field
|
|
784
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
785
|
+
should not be set.
|
|
786
|
+
entitlement (:class:`google.cloud.privilegedaccessmanager_v1.types.Entitlement`):
|
|
787
|
+
Required. The resource being created
|
|
788
|
+
This corresponds to the ``entitlement`` field
|
|
789
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
790
|
+
should not be set.
|
|
791
|
+
entitlement_id (:class:`str`):
|
|
792
|
+
Required. The ID to use for this entitlement. This
|
|
793
|
+
becomes the last part of the resource name.
|
|
794
|
+
|
|
795
|
+
This value should be 4-63 characters in length, and
|
|
796
|
+
valid characters are "[a-z]", "[0-9]", and "-". The
|
|
797
|
+
first character should be from [a-z].
|
|
798
|
+
|
|
799
|
+
This value should be unique among all other entitlements
|
|
800
|
+
under the specified ``parent``.
|
|
801
|
+
|
|
802
|
+
This corresponds to the ``entitlement_id`` field
|
|
803
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
804
|
+
should not be set.
|
|
805
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
806
|
+
should be retried.
|
|
807
|
+
timeout (float): The timeout for this request.
|
|
808
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
809
|
+
sent along with the request as metadata.
|
|
810
|
+
|
|
811
|
+
Returns:
|
|
812
|
+
google.api_core.operation_async.AsyncOperation:
|
|
813
|
+
An object representing a long-running operation.
|
|
814
|
+
|
|
815
|
+
The result type for the operation will be :class:`google.cloud.privilegedaccessmanager_v1.types.Entitlement` An entitlement defines the eligibility of a set of users to obtain
|
|
816
|
+
predefined access for some time possibly after going
|
|
817
|
+
through an approval workflow.
|
|
818
|
+
|
|
819
|
+
"""
|
|
820
|
+
# Create or coerce a protobuf request object.
|
|
821
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
822
|
+
# gotten any keyword arguments that map to the request.
|
|
823
|
+
has_flattened_params = any([parent, entitlement, entitlement_id])
|
|
824
|
+
if request is not None and has_flattened_params:
|
|
825
|
+
raise ValueError(
|
|
826
|
+
"If the `request` argument is set, then none of "
|
|
827
|
+
"the individual field arguments should be set."
|
|
828
|
+
)
|
|
829
|
+
|
|
830
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
831
|
+
# there are no flattened fields), or create one.
|
|
832
|
+
if not isinstance(request, privilegedaccessmanager.CreateEntitlementRequest):
|
|
833
|
+
request = privilegedaccessmanager.CreateEntitlementRequest(request)
|
|
834
|
+
|
|
835
|
+
# If we have keyword arguments corresponding to fields on the
|
|
836
|
+
# request, apply these.
|
|
837
|
+
if parent is not None:
|
|
838
|
+
request.parent = parent
|
|
839
|
+
if entitlement is not None:
|
|
840
|
+
request.entitlement = entitlement
|
|
841
|
+
if entitlement_id is not None:
|
|
842
|
+
request.entitlement_id = entitlement_id
|
|
843
|
+
|
|
844
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
845
|
+
# and friendly error handling.
|
|
846
|
+
rpc = self._client._transport._wrapped_methods[
|
|
847
|
+
self._client._transport.create_entitlement
|
|
848
|
+
]
|
|
849
|
+
|
|
850
|
+
# Certain fields should be provided within the metadata header;
|
|
851
|
+
# add these here.
|
|
852
|
+
metadata = tuple(metadata) + (
|
|
853
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
854
|
+
)
|
|
855
|
+
|
|
856
|
+
# Validate the universe domain.
|
|
857
|
+
self._client._validate_universe_domain()
|
|
858
|
+
|
|
859
|
+
# Send the request.
|
|
860
|
+
response = await rpc(
|
|
861
|
+
request,
|
|
862
|
+
retry=retry,
|
|
863
|
+
timeout=timeout,
|
|
864
|
+
metadata=metadata,
|
|
865
|
+
)
|
|
866
|
+
|
|
867
|
+
# Wrap the response in an operation future.
|
|
868
|
+
response = operation_async.from_gapic(
|
|
869
|
+
response,
|
|
870
|
+
self._client._transport.operations_client,
|
|
871
|
+
privilegedaccessmanager.Entitlement,
|
|
872
|
+
metadata_type=privilegedaccessmanager.OperationMetadata,
|
|
873
|
+
)
|
|
874
|
+
|
|
875
|
+
# Done; return the response.
|
|
876
|
+
return response
|
|
877
|
+
|
|
878
|
+
async def delete_entitlement(
|
|
879
|
+
self,
|
|
880
|
+
request: Optional[
|
|
881
|
+
Union[privilegedaccessmanager.DeleteEntitlementRequest, dict]
|
|
882
|
+
] = None,
|
|
883
|
+
*,
|
|
884
|
+
name: Optional[str] = None,
|
|
885
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
886
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
887
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
888
|
+
) -> operation_async.AsyncOperation:
|
|
889
|
+
r"""Deletes a single entitlement. This method can only be
|
|
890
|
+
called when there are no in-progress
|
|
891
|
+
(ACTIVE/ACTIVATING/REVOKING) grants under the
|
|
892
|
+
entitlement.
|
|
893
|
+
|
|
894
|
+
.. code-block:: python
|
|
895
|
+
|
|
896
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
897
|
+
# code template only.
|
|
898
|
+
# It will require modifications to work:
|
|
899
|
+
# - It may require correct/in-range values for request initialization.
|
|
900
|
+
# - It may require specifying regional endpoints when creating the service
|
|
901
|
+
# client as shown in:
|
|
902
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
903
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
904
|
+
|
|
905
|
+
async def sample_delete_entitlement():
|
|
906
|
+
# Create a client
|
|
907
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
908
|
+
|
|
909
|
+
# Initialize request argument(s)
|
|
910
|
+
request = privilegedaccessmanager_v1.DeleteEntitlementRequest(
|
|
911
|
+
name="name_value",
|
|
912
|
+
)
|
|
913
|
+
|
|
914
|
+
# Make the request
|
|
915
|
+
operation = client.delete_entitlement(request=request)
|
|
916
|
+
|
|
917
|
+
print("Waiting for operation to complete...")
|
|
918
|
+
|
|
919
|
+
response = (await operation).result()
|
|
920
|
+
|
|
921
|
+
# Handle the response
|
|
922
|
+
print(response)
|
|
923
|
+
|
|
924
|
+
Args:
|
|
925
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.DeleteEntitlementRequest, dict]]):
|
|
926
|
+
The request object. Message for deleting an entitlement.
|
|
927
|
+
name (:class:`str`):
|
|
928
|
+
Required. Name of the resource.
|
|
929
|
+
This corresponds to the ``name`` field
|
|
930
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
931
|
+
should not be set.
|
|
932
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
933
|
+
should be retried.
|
|
934
|
+
timeout (float): The timeout for this request.
|
|
935
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
936
|
+
sent along with the request as metadata.
|
|
937
|
+
|
|
938
|
+
Returns:
|
|
939
|
+
google.api_core.operation_async.AsyncOperation:
|
|
940
|
+
An object representing a long-running operation.
|
|
941
|
+
|
|
942
|
+
The result type for the operation will be :class:`google.cloud.privilegedaccessmanager_v1.types.Entitlement` An entitlement defines the eligibility of a set of users to obtain
|
|
943
|
+
predefined access for some time possibly after going
|
|
944
|
+
through an approval workflow.
|
|
945
|
+
|
|
946
|
+
"""
|
|
947
|
+
# Create or coerce a protobuf request object.
|
|
948
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
949
|
+
# gotten any keyword arguments that map to the request.
|
|
950
|
+
has_flattened_params = any([name])
|
|
951
|
+
if request is not None and has_flattened_params:
|
|
952
|
+
raise ValueError(
|
|
953
|
+
"If the `request` argument is set, then none of "
|
|
954
|
+
"the individual field arguments should be set."
|
|
955
|
+
)
|
|
956
|
+
|
|
957
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
958
|
+
# there are no flattened fields), or create one.
|
|
959
|
+
if not isinstance(request, privilegedaccessmanager.DeleteEntitlementRequest):
|
|
960
|
+
request = privilegedaccessmanager.DeleteEntitlementRequest(request)
|
|
961
|
+
|
|
962
|
+
# If we have keyword arguments corresponding to fields on the
|
|
963
|
+
# request, apply these.
|
|
964
|
+
if name is not None:
|
|
965
|
+
request.name = name
|
|
966
|
+
|
|
967
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
968
|
+
# and friendly error handling.
|
|
969
|
+
rpc = self._client._transport._wrapped_methods[
|
|
970
|
+
self._client._transport.delete_entitlement
|
|
971
|
+
]
|
|
972
|
+
|
|
973
|
+
# Certain fields should be provided within the metadata header;
|
|
974
|
+
# add these here.
|
|
975
|
+
metadata = tuple(metadata) + (
|
|
976
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
977
|
+
)
|
|
978
|
+
|
|
979
|
+
# Validate the universe domain.
|
|
980
|
+
self._client._validate_universe_domain()
|
|
981
|
+
|
|
982
|
+
# Send the request.
|
|
983
|
+
response = await rpc(
|
|
984
|
+
request,
|
|
985
|
+
retry=retry,
|
|
986
|
+
timeout=timeout,
|
|
987
|
+
metadata=metadata,
|
|
988
|
+
)
|
|
989
|
+
|
|
990
|
+
# Wrap the response in an operation future.
|
|
991
|
+
response = operation_async.from_gapic(
|
|
992
|
+
response,
|
|
993
|
+
self._client._transport.operations_client,
|
|
994
|
+
privilegedaccessmanager.Entitlement,
|
|
995
|
+
metadata_type=privilegedaccessmanager.OperationMetadata,
|
|
996
|
+
)
|
|
997
|
+
|
|
998
|
+
# Done; return the response.
|
|
999
|
+
return response
|
|
1000
|
+
|
|
1001
|
+
async def update_entitlement(
|
|
1002
|
+
self,
|
|
1003
|
+
request: Optional[
|
|
1004
|
+
Union[privilegedaccessmanager.UpdateEntitlementRequest, dict]
|
|
1005
|
+
] = None,
|
|
1006
|
+
*,
|
|
1007
|
+
entitlement: Optional[privilegedaccessmanager.Entitlement] = None,
|
|
1008
|
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
|
1009
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1010
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1011
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
1012
|
+
) -> operation_async.AsyncOperation:
|
|
1013
|
+
r"""Updates the entitlement specified in the request. Updated fields
|
|
1014
|
+
in the entitlement need to be specified in an update mask. The
|
|
1015
|
+
changes made to an entitlement are applicable only on future
|
|
1016
|
+
grants of the entitlement. However, if new approvers are added
|
|
1017
|
+
or existing approvers are removed from the approval workflow,
|
|
1018
|
+
the changes are effective on existing grants.
|
|
1019
|
+
|
|
1020
|
+
The following fields are not supported for updates:
|
|
1021
|
+
|
|
1022
|
+
- All immutable fields
|
|
1023
|
+
- Entitlement name
|
|
1024
|
+
- Resource name
|
|
1025
|
+
- Resource type
|
|
1026
|
+
- Adding an approval workflow in an entitlement which
|
|
1027
|
+
previously had no approval workflow.
|
|
1028
|
+
- Deleting the approval workflow from an entitlement.
|
|
1029
|
+
- Adding or deleting a step in the approval workflow (only one
|
|
1030
|
+
step is supported)
|
|
1031
|
+
|
|
1032
|
+
Note that updates are allowed on the list of approvers in an
|
|
1033
|
+
approval workflow step.
|
|
1034
|
+
|
|
1035
|
+
.. code-block:: python
|
|
1036
|
+
|
|
1037
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1038
|
+
# code template only.
|
|
1039
|
+
# It will require modifications to work:
|
|
1040
|
+
# - It may require correct/in-range values for request initialization.
|
|
1041
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1042
|
+
# client as shown in:
|
|
1043
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1044
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
1045
|
+
|
|
1046
|
+
async def sample_update_entitlement():
|
|
1047
|
+
# Create a client
|
|
1048
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
1049
|
+
|
|
1050
|
+
# Initialize request argument(s)
|
|
1051
|
+
request = privilegedaccessmanager_v1.UpdateEntitlementRequest(
|
|
1052
|
+
)
|
|
1053
|
+
|
|
1054
|
+
# Make the request
|
|
1055
|
+
operation = client.update_entitlement(request=request)
|
|
1056
|
+
|
|
1057
|
+
print("Waiting for operation to complete...")
|
|
1058
|
+
|
|
1059
|
+
response = (await operation).result()
|
|
1060
|
+
|
|
1061
|
+
# Handle the response
|
|
1062
|
+
print(response)
|
|
1063
|
+
|
|
1064
|
+
Args:
|
|
1065
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.UpdateEntitlementRequest, dict]]):
|
|
1066
|
+
The request object. Message for updating an entitlement.
|
|
1067
|
+
entitlement (:class:`google.cloud.privilegedaccessmanager_v1.types.Entitlement`):
|
|
1068
|
+
Required. The entitlement resource
|
|
1069
|
+
that is updated.
|
|
1070
|
+
|
|
1071
|
+
This corresponds to the ``entitlement`` field
|
|
1072
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1073
|
+
should not be set.
|
|
1074
|
+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
|
|
1075
|
+
Required. The list of fields to update. A field is
|
|
1076
|
+
overwritten if, and only if, it is in the mask. Any
|
|
1077
|
+
immutable fields set in the mask are ignored by the
|
|
1078
|
+
server. Repeated fields and map fields are only allowed
|
|
1079
|
+
in the last position of a ``paths`` string and overwrite
|
|
1080
|
+
the existing values. Hence an update to a repeated field
|
|
1081
|
+
or a map should contain the entire list of values. The
|
|
1082
|
+
fields specified in the update_mask are relative to the
|
|
1083
|
+
resource and not to the request. (e.g.
|
|
1084
|
+
``MaxRequestDuration``; *not*
|
|
1085
|
+
``entitlement.MaxRequestDuration``) A value of '*' for
|
|
1086
|
+
this field refers to full replacement of the resource.
|
|
1087
|
+
|
|
1088
|
+
This corresponds to the ``update_mask`` field
|
|
1089
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1090
|
+
should not be set.
|
|
1091
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1092
|
+
should be retried.
|
|
1093
|
+
timeout (float): The timeout for this request.
|
|
1094
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
1095
|
+
sent along with the request as metadata.
|
|
1096
|
+
|
|
1097
|
+
Returns:
|
|
1098
|
+
google.api_core.operation_async.AsyncOperation:
|
|
1099
|
+
An object representing a long-running operation.
|
|
1100
|
+
|
|
1101
|
+
The result type for the operation will be :class:`google.cloud.privilegedaccessmanager_v1.types.Entitlement` An entitlement defines the eligibility of a set of users to obtain
|
|
1102
|
+
predefined access for some time possibly after going
|
|
1103
|
+
through an approval workflow.
|
|
1104
|
+
|
|
1105
|
+
"""
|
|
1106
|
+
# Create or coerce a protobuf request object.
|
|
1107
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1108
|
+
# gotten any keyword arguments that map to the request.
|
|
1109
|
+
has_flattened_params = any([entitlement, update_mask])
|
|
1110
|
+
if request is not None and has_flattened_params:
|
|
1111
|
+
raise ValueError(
|
|
1112
|
+
"If the `request` argument is set, then none of "
|
|
1113
|
+
"the individual field arguments should be set."
|
|
1114
|
+
)
|
|
1115
|
+
|
|
1116
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1117
|
+
# there are no flattened fields), or create one.
|
|
1118
|
+
if not isinstance(request, privilegedaccessmanager.UpdateEntitlementRequest):
|
|
1119
|
+
request = privilegedaccessmanager.UpdateEntitlementRequest(request)
|
|
1120
|
+
|
|
1121
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1122
|
+
# request, apply these.
|
|
1123
|
+
if entitlement is not None:
|
|
1124
|
+
request.entitlement = entitlement
|
|
1125
|
+
if update_mask is not None:
|
|
1126
|
+
request.update_mask = update_mask
|
|
1127
|
+
|
|
1128
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1129
|
+
# and friendly error handling.
|
|
1130
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1131
|
+
self._client._transport.update_entitlement
|
|
1132
|
+
]
|
|
1133
|
+
|
|
1134
|
+
# Certain fields should be provided within the metadata header;
|
|
1135
|
+
# add these here.
|
|
1136
|
+
metadata = tuple(metadata) + (
|
|
1137
|
+
gapic_v1.routing_header.to_grpc_metadata(
|
|
1138
|
+
(("entitlement.name", request.entitlement.name),)
|
|
1139
|
+
),
|
|
1140
|
+
)
|
|
1141
|
+
|
|
1142
|
+
# Validate the universe domain.
|
|
1143
|
+
self._client._validate_universe_domain()
|
|
1144
|
+
|
|
1145
|
+
# Send the request.
|
|
1146
|
+
response = await rpc(
|
|
1147
|
+
request,
|
|
1148
|
+
retry=retry,
|
|
1149
|
+
timeout=timeout,
|
|
1150
|
+
metadata=metadata,
|
|
1151
|
+
)
|
|
1152
|
+
|
|
1153
|
+
# Wrap the response in an operation future.
|
|
1154
|
+
response = operation_async.from_gapic(
|
|
1155
|
+
response,
|
|
1156
|
+
self._client._transport.operations_client,
|
|
1157
|
+
privilegedaccessmanager.Entitlement,
|
|
1158
|
+
metadata_type=privilegedaccessmanager.OperationMetadata,
|
|
1159
|
+
)
|
|
1160
|
+
|
|
1161
|
+
# Done; return the response.
|
|
1162
|
+
return response
|
|
1163
|
+
|
|
1164
|
+
async def list_grants(
|
|
1165
|
+
self,
|
|
1166
|
+
request: Optional[
|
|
1167
|
+
Union[privilegedaccessmanager.ListGrantsRequest, dict]
|
|
1168
|
+
] = None,
|
|
1169
|
+
*,
|
|
1170
|
+
parent: Optional[str] = None,
|
|
1171
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1172
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1173
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
1174
|
+
) -> pagers.ListGrantsAsyncPager:
|
|
1175
|
+
r"""Lists grants for a given entitlement.
|
|
1176
|
+
|
|
1177
|
+
.. code-block:: python
|
|
1178
|
+
|
|
1179
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1180
|
+
# code template only.
|
|
1181
|
+
# It will require modifications to work:
|
|
1182
|
+
# - It may require correct/in-range values for request initialization.
|
|
1183
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1184
|
+
# client as shown in:
|
|
1185
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1186
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
1187
|
+
|
|
1188
|
+
async def sample_list_grants():
|
|
1189
|
+
# Create a client
|
|
1190
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
1191
|
+
|
|
1192
|
+
# Initialize request argument(s)
|
|
1193
|
+
request = privilegedaccessmanager_v1.ListGrantsRequest(
|
|
1194
|
+
parent="parent_value",
|
|
1195
|
+
)
|
|
1196
|
+
|
|
1197
|
+
# Make the request
|
|
1198
|
+
page_result = client.list_grants(request=request)
|
|
1199
|
+
|
|
1200
|
+
# Handle the response
|
|
1201
|
+
async for response in page_result:
|
|
1202
|
+
print(response)
|
|
1203
|
+
|
|
1204
|
+
Args:
|
|
1205
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.ListGrantsRequest, dict]]):
|
|
1206
|
+
The request object. Message for requesting list of
|
|
1207
|
+
grants.
|
|
1208
|
+
parent (:class:`str`):
|
|
1209
|
+
Required. The parent resource which
|
|
1210
|
+
owns the grants.
|
|
1211
|
+
|
|
1212
|
+
This corresponds to the ``parent`` field
|
|
1213
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1214
|
+
should not be set.
|
|
1215
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1216
|
+
should be retried.
|
|
1217
|
+
timeout (float): The timeout for this request.
|
|
1218
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
1219
|
+
sent along with the request as metadata.
|
|
1220
|
+
|
|
1221
|
+
Returns:
|
|
1222
|
+
google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.ListGrantsAsyncPager:
|
|
1223
|
+
Message for response to listing
|
|
1224
|
+
grants.
|
|
1225
|
+
Iterating over this object will yield
|
|
1226
|
+
results and resolve additional pages
|
|
1227
|
+
automatically.
|
|
1228
|
+
|
|
1229
|
+
"""
|
|
1230
|
+
# Create or coerce a protobuf request object.
|
|
1231
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1232
|
+
# gotten any keyword arguments that map to the request.
|
|
1233
|
+
has_flattened_params = any([parent])
|
|
1234
|
+
if request is not None and has_flattened_params:
|
|
1235
|
+
raise ValueError(
|
|
1236
|
+
"If the `request` argument is set, then none of "
|
|
1237
|
+
"the individual field arguments should be set."
|
|
1238
|
+
)
|
|
1239
|
+
|
|
1240
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1241
|
+
# there are no flattened fields), or create one.
|
|
1242
|
+
if not isinstance(request, privilegedaccessmanager.ListGrantsRequest):
|
|
1243
|
+
request = privilegedaccessmanager.ListGrantsRequest(request)
|
|
1244
|
+
|
|
1245
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1246
|
+
# request, apply these.
|
|
1247
|
+
if parent is not None:
|
|
1248
|
+
request.parent = parent
|
|
1249
|
+
|
|
1250
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1251
|
+
# and friendly error handling.
|
|
1252
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1253
|
+
self._client._transport.list_grants
|
|
1254
|
+
]
|
|
1255
|
+
|
|
1256
|
+
# Certain fields should be provided within the metadata header;
|
|
1257
|
+
# add these here.
|
|
1258
|
+
metadata = tuple(metadata) + (
|
|
1259
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
1260
|
+
)
|
|
1261
|
+
|
|
1262
|
+
# Validate the universe domain.
|
|
1263
|
+
self._client._validate_universe_domain()
|
|
1264
|
+
|
|
1265
|
+
# Send the request.
|
|
1266
|
+
response = await rpc(
|
|
1267
|
+
request,
|
|
1268
|
+
retry=retry,
|
|
1269
|
+
timeout=timeout,
|
|
1270
|
+
metadata=metadata,
|
|
1271
|
+
)
|
|
1272
|
+
|
|
1273
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
1274
|
+
# an `__aiter__` convenience method.
|
|
1275
|
+
response = pagers.ListGrantsAsyncPager(
|
|
1276
|
+
method=rpc,
|
|
1277
|
+
request=request,
|
|
1278
|
+
response=response,
|
|
1279
|
+
metadata=metadata,
|
|
1280
|
+
)
|
|
1281
|
+
|
|
1282
|
+
# Done; return the response.
|
|
1283
|
+
return response
|
|
1284
|
+
|
|
1285
|
+
async def search_grants(
|
|
1286
|
+
self,
|
|
1287
|
+
request: Optional[
|
|
1288
|
+
Union[privilegedaccessmanager.SearchGrantsRequest, dict]
|
|
1289
|
+
] = None,
|
|
1290
|
+
*,
|
|
1291
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1292
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1293
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
1294
|
+
) -> pagers.SearchGrantsAsyncPager:
|
|
1295
|
+
r"""``SearchGrants`` returns grants that are related to the calling
|
|
1296
|
+
user in the specified way.
|
|
1297
|
+
|
|
1298
|
+
.. code-block:: python
|
|
1299
|
+
|
|
1300
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1301
|
+
# code template only.
|
|
1302
|
+
# It will require modifications to work:
|
|
1303
|
+
# - It may require correct/in-range values for request initialization.
|
|
1304
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1305
|
+
# client as shown in:
|
|
1306
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1307
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
1308
|
+
|
|
1309
|
+
async def sample_search_grants():
|
|
1310
|
+
# Create a client
|
|
1311
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
1312
|
+
|
|
1313
|
+
# Initialize request argument(s)
|
|
1314
|
+
request = privilegedaccessmanager_v1.SearchGrantsRequest(
|
|
1315
|
+
parent="parent_value",
|
|
1316
|
+
caller_relationship="HAD_APPROVED",
|
|
1317
|
+
)
|
|
1318
|
+
|
|
1319
|
+
# Make the request
|
|
1320
|
+
page_result = client.search_grants(request=request)
|
|
1321
|
+
|
|
1322
|
+
# Handle the response
|
|
1323
|
+
async for response in page_result:
|
|
1324
|
+
print(response)
|
|
1325
|
+
|
|
1326
|
+
Args:
|
|
1327
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.SearchGrantsRequest, dict]]):
|
|
1328
|
+
The request object. Request message for ``SearchGrants`` method.
|
|
1329
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1330
|
+
should be retried.
|
|
1331
|
+
timeout (float): The timeout for this request.
|
|
1332
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
1333
|
+
sent along with the request as metadata.
|
|
1334
|
+
|
|
1335
|
+
Returns:
|
|
1336
|
+
google.cloud.privilegedaccessmanager_v1.services.privileged_access_manager.pagers.SearchGrantsAsyncPager:
|
|
1337
|
+
Response message for SearchGrants method.
|
|
1338
|
+
|
|
1339
|
+
Iterating over this object will yield results and
|
|
1340
|
+
resolve additional pages automatically.
|
|
1341
|
+
|
|
1342
|
+
"""
|
|
1343
|
+
# Create or coerce a protobuf request object.
|
|
1344
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1345
|
+
# there are no flattened fields), or create one.
|
|
1346
|
+
if not isinstance(request, privilegedaccessmanager.SearchGrantsRequest):
|
|
1347
|
+
request = privilegedaccessmanager.SearchGrantsRequest(request)
|
|
1348
|
+
|
|
1349
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1350
|
+
# and friendly error handling.
|
|
1351
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1352
|
+
self._client._transport.search_grants
|
|
1353
|
+
]
|
|
1354
|
+
|
|
1355
|
+
# Certain fields should be provided within the metadata header;
|
|
1356
|
+
# add these here.
|
|
1357
|
+
metadata = tuple(metadata) + (
|
|
1358
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
1359
|
+
)
|
|
1360
|
+
|
|
1361
|
+
# Validate the universe domain.
|
|
1362
|
+
self._client._validate_universe_domain()
|
|
1363
|
+
|
|
1364
|
+
# Send the request.
|
|
1365
|
+
response = await rpc(
|
|
1366
|
+
request,
|
|
1367
|
+
retry=retry,
|
|
1368
|
+
timeout=timeout,
|
|
1369
|
+
metadata=metadata,
|
|
1370
|
+
)
|
|
1371
|
+
|
|
1372
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
1373
|
+
# an `__aiter__` convenience method.
|
|
1374
|
+
response = pagers.SearchGrantsAsyncPager(
|
|
1375
|
+
method=rpc,
|
|
1376
|
+
request=request,
|
|
1377
|
+
response=response,
|
|
1378
|
+
metadata=metadata,
|
|
1379
|
+
)
|
|
1380
|
+
|
|
1381
|
+
# Done; return the response.
|
|
1382
|
+
return response
|
|
1383
|
+
|
|
1384
|
+
async def get_grant(
|
|
1385
|
+
self,
|
|
1386
|
+
request: Optional[Union[privilegedaccessmanager.GetGrantRequest, dict]] = None,
|
|
1387
|
+
*,
|
|
1388
|
+
name: Optional[str] = None,
|
|
1389
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1390
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1391
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
1392
|
+
) -> privilegedaccessmanager.Grant:
|
|
1393
|
+
r"""Get details of a single grant.
|
|
1394
|
+
|
|
1395
|
+
.. code-block:: python
|
|
1396
|
+
|
|
1397
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1398
|
+
# code template only.
|
|
1399
|
+
# It will require modifications to work:
|
|
1400
|
+
# - It may require correct/in-range values for request initialization.
|
|
1401
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1402
|
+
# client as shown in:
|
|
1403
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1404
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
1405
|
+
|
|
1406
|
+
async def sample_get_grant():
|
|
1407
|
+
# Create a client
|
|
1408
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
1409
|
+
|
|
1410
|
+
# Initialize request argument(s)
|
|
1411
|
+
request = privilegedaccessmanager_v1.GetGrantRequest(
|
|
1412
|
+
name="name_value",
|
|
1413
|
+
)
|
|
1414
|
+
|
|
1415
|
+
# Make the request
|
|
1416
|
+
response = await client.get_grant(request=request)
|
|
1417
|
+
|
|
1418
|
+
# Handle the response
|
|
1419
|
+
print(response)
|
|
1420
|
+
|
|
1421
|
+
Args:
|
|
1422
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.GetGrantRequest, dict]]):
|
|
1423
|
+
The request object. Message for getting a grant.
|
|
1424
|
+
name (:class:`str`):
|
|
1425
|
+
Required. Name of the resource.
|
|
1426
|
+
This corresponds to the ``name`` field
|
|
1427
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1428
|
+
should not be set.
|
|
1429
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1430
|
+
should be retried.
|
|
1431
|
+
timeout (float): The timeout for this request.
|
|
1432
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
1433
|
+
sent along with the request as metadata.
|
|
1434
|
+
|
|
1435
|
+
Returns:
|
|
1436
|
+
google.cloud.privilegedaccessmanager_v1.types.Grant:
|
|
1437
|
+
This is to ensure that the Grants and ProducerGrants proto are byte
|
|
1438
|
+
compatible. A grant represents a request from a user
|
|
1439
|
+
for obtaining the access specified in an entitlement
|
|
1440
|
+
they are eligible for.
|
|
1441
|
+
|
|
1442
|
+
"""
|
|
1443
|
+
# Create or coerce a protobuf request object.
|
|
1444
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1445
|
+
# gotten any keyword arguments that map to the request.
|
|
1446
|
+
has_flattened_params = any([name])
|
|
1447
|
+
if request is not None and has_flattened_params:
|
|
1448
|
+
raise ValueError(
|
|
1449
|
+
"If the `request` argument is set, then none of "
|
|
1450
|
+
"the individual field arguments should be set."
|
|
1451
|
+
)
|
|
1452
|
+
|
|
1453
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1454
|
+
# there are no flattened fields), or create one.
|
|
1455
|
+
if not isinstance(request, privilegedaccessmanager.GetGrantRequest):
|
|
1456
|
+
request = privilegedaccessmanager.GetGrantRequest(request)
|
|
1457
|
+
|
|
1458
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1459
|
+
# request, apply these.
|
|
1460
|
+
if name is not None:
|
|
1461
|
+
request.name = name
|
|
1462
|
+
|
|
1463
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1464
|
+
# and friendly error handling.
|
|
1465
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1466
|
+
self._client._transport.get_grant
|
|
1467
|
+
]
|
|
1468
|
+
|
|
1469
|
+
# Certain fields should be provided within the metadata header;
|
|
1470
|
+
# add these here.
|
|
1471
|
+
metadata = tuple(metadata) + (
|
|
1472
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1473
|
+
)
|
|
1474
|
+
|
|
1475
|
+
# Validate the universe domain.
|
|
1476
|
+
self._client._validate_universe_domain()
|
|
1477
|
+
|
|
1478
|
+
# Send the request.
|
|
1479
|
+
response = await rpc(
|
|
1480
|
+
request,
|
|
1481
|
+
retry=retry,
|
|
1482
|
+
timeout=timeout,
|
|
1483
|
+
metadata=metadata,
|
|
1484
|
+
)
|
|
1485
|
+
|
|
1486
|
+
# Done; return the response.
|
|
1487
|
+
return response
|
|
1488
|
+
|
|
1489
|
+
async def create_grant(
|
|
1490
|
+
self,
|
|
1491
|
+
request: Optional[
|
|
1492
|
+
Union[privilegedaccessmanager.CreateGrantRequest, dict]
|
|
1493
|
+
] = None,
|
|
1494
|
+
*,
|
|
1495
|
+
parent: Optional[str] = None,
|
|
1496
|
+
grant: Optional[privilegedaccessmanager.Grant] = None,
|
|
1497
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1498
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1499
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
1500
|
+
) -> privilegedaccessmanager.Grant:
|
|
1501
|
+
r"""Creates a new grant in a given project and location.
|
|
1502
|
+
|
|
1503
|
+
.. code-block:: python
|
|
1504
|
+
|
|
1505
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1506
|
+
# code template only.
|
|
1507
|
+
# It will require modifications to work:
|
|
1508
|
+
# - It may require correct/in-range values for request initialization.
|
|
1509
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1510
|
+
# client as shown in:
|
|
1511
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1512
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
1513
|
+
|
|
1514
|
+
async def sample_create_grant():
|
|
1515
|
+
# Create a client
|
|
1516
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
1517
|
+
|
|
1518
|
+
# Initialize request argument(s)
|
|
1519
|
+
request = privilegedaccessmanager_v1.CreateGrantRequest(
|
|
1520
|
+
parent="parent_value",
|
|
1521
|
+
)
|
|
1522
|
+
|
|
1523
|
+
# Make the request
|
|
1524
|
+
response = await client.create_grant(request=request)
|
|
1525
|
+
|
|
1526
|
+
# Handle the response
|
|
1527
|
+
print(response)
|
|
1528
|
+
|
|
1529
|
+
Args:
|
|
1530
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.CreateGrantRequest, dict]]):
|
|
1531
|
+
The request object. Message for creating a grant
|
|
1532
|
+
parent (:class:`str`):
|
|
1533
|
+
Required. Name of the parent
|
|
1534
|
+
entitlement for which this grant is
|
|
1535
|
+
being requested.
|
|
1536
|
+
|
|
1537
|
+
This corresponds to the ``parent`` field
|
|
1538
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1539
|
+
should not be set.
|
|
1540
|
+
grant (:class:`google.cloud.privilegedaccessmanager_v1.types.Grant`):
|
|
1541
|
+
Required. The resource being created.
|
|
1542
|
+
This corresponds to the ``grant`` field
|
|
1543
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1544
|
+
should not be set.
|
|
1545
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1546
|
+
should be retried.
|
|
1547
|
+
timeout (float): The timeout for this request.
|
|
1548
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
1549
|
+
sent along with the request as metadata.
|
|
1550
|
+
|
|
1551
|
+
Returns:
|
|
1552
|
+
google.cloud.privilegedaccessmanager_v1.types.Grant:
|
|
1553
|
+
This is to ensure that the Grants and ProducerGrants proto are byte
|
|
1554
|
+
compatible. A grant represents a request from a user
|
|
1555
|
+
for obtaining the access specified in an entitlement
|
|
1556
|
+
they are eligible for.
|
|
1557
|
+
|
|
1558
|
+
"""
|
|
1559
|
+
# Create or coerce a protobuf request object.
|
|
1560
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1561
|
+
# gotten any keyword arguments that map to the request.
|
|
1562
|
+
has_flattened_params = any([parent, grant])
|
|
1563
|
+
if request is not None and has_flattened_params:
|
|
1564
|
+
raise ValueError(
|
|
1565
|
+
"If the `request` argument is set, then none of "
|
|
1566
|
+
"the individual field arguments should be set."
|
|
1567
|
+
)
|
|
1568
|
+
|
|
1569
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1570
|
+
# there are no flattened fields), or create one.
|
|
1571
|
+
if not isinstance(request, privilegedaccessmanager.CreateGrantRequest):
|
|
1572
|
+
request = privilegedaccessmanager.CreateGrantRequest(request)
|
|
1573
|
+
|
|
1574
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1575
|
+
# request, apply these.
|
|
1576
|
+
if parent is not None:
|
|
1577
|
+
request.parent = parent
|
|
1578
|
+
if grant is not None:
|
|
1579
|
+
request.grant = grant
|
|
1580
|
+
|
|
1581
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1582
|
+
# and friendly error handling.
|
|
1583
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1584
|
+
self._client._transport.create_grant
|
|
1585
|
+
]
|
|
1586
|
+
|
|
1587
|
+
# Certain fields should be provided within the metadata header;
|
|
1588
|
+
# add these here.
|
|
1589
|
+
metadata = tuple(metadata) + (
|
|
1590
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
1591
|
+
)
|
|
1592
|
+
|
|
1593
|
+
# Validate the universe domain.
|
|
1594
|
+
self._client._validate_universe_domain()
|
|
1595
|
+
|
|
1596
|
+
# Send the request.
|
|
1597
|
+
response = await rpc(
|
|
1598
|
+
request,
|
|
1599
|
+
retry=retry,
|
|
1600
|
+
timeout=timeout,
|
|
1601
|
+
metadata=metadata,
|
|
1602
|
+
)
|
|
1603
|
+
|
|
1604
|
+
# Done; return the response.
|
|
1605
|
+
return response
|
|
1606
|
+
|
|
1607
|
+
async def approve_grant(
|
|
1608
|
+
self,
|
|
1609
|
+
request: Optional[
|
|
1610
|
+
Union[privilegedaccessmanager.ApproveGrantRequest, dict]
|
|
1611
|
+
] = None,
|
|
1612
|
+
*,
|
|
1613
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1614
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1615
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
1616
|
+
) -> privilegedaccessmanager.Grant:
|
|
1617
|
+
r"""``ApproveGrant`` is used to approve a grant. This method can
|
|
1618
|
+
only be called on a grant when it's in the ``APPROVAL_AWAITED``
|
|
1619
|
+
state. This operation can't be undone.
|
|
1620
|
+
|
|
1621
|
+
.. code-block:: python
|
|
1622
|
+
|
|
1623
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1624
|
+
# code template only.
|
|
1625
|
+
# It will require modifications to work:
|
|
1626
|
+
# - It may require correct/in-range values for request initialization.
|
|
1627
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1628
|
+
# client as shown in:
|
|
1629
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1630
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
1631
|
+
|
|
1632
|
+
async def sample_approve_grant():
|
|
1633
|
+
# Create a client
|
|
1634
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
1635
|
+
|
|
1636
|
+
# Initialize request argument(s)
|
|
1637
|
+
request = privilegedaccessmanager_v1.ApproveGrantRequest(
|
|
1638
|
+
name="name_value",
|
|
1639
|
+
)
|
|
1640
|
+
|
|
1641
|
+
# Make the request
|
|
1642
|
+
response = await client.approve_grant(request=request)
|
|
1643
|
+
|
|
1644
|
+
# Handle the response
|
|
1645
|
+
print(response)
|
|
1646
|
+
|
|
1647
|
+
Args:
|
|
1648
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.ApproveGrantRequest, dict]]):
|
|
1649
|
+
The request object. Request message for ``ApproveGrant`` method.
|
|
1650
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1651
|
+
should be retried.
|
|
1652
|
+
timeout (float): The timeout for this request.
|
|
1653
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
1654
|
+
sent along with the request as metadata.
|
|
1655
|
+
|
|
1656
|
+
Returns:
|
|
1657
|
+
google.cloud.privilegedaccessmanager_v1.types.Grant:
|
|
1658
|
+
This is to ensure that the Grants and ProducerGrants proto are byte
|
|
1659
|
+
compatible. A grant represents a request from a user
|
|
1660
|
+
for obtaining the access specified in an entitlement
|
|
1661
|
+
they are eligible for.
|
|
1662
|
+
|
|
1663
|
+
"""
|
|
1664
|
+
# Create or coerce a protobuf request object.
|
|
1665
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1666
|
+
# there are no flattened fields), or create one.
|
|
1667
|
+
if not isinstance(request, privilegedaccessmanager.ApproveGrantRequest):
|
|
1668
|
+
request = privilegedaccessmanager.ApproveGrantRequest(request)
|
|
1669
|
+
|
|
1670
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1671
|
+
# and friendly error handling.
|
|
1672
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1673
|
+
self._client._transport.approve_grant
|
|
1674
|
+
]
|
|
1675
|
+
|
|
1676
|
+
# Certain fields should be provided within the metadata header;
|
|
1677
|
+
# add these here.
|
|
1678
|
+
metadata = tuple(metadata) + (
|
|
1679
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1680
|
+
)
|
|
1681
|
+
|
|
1682
|
+
# Validate the universe domain.
|
|
1683
|
+
self._client._validate_universe_domain()
|
|
1684
|
+
|
|
1685
|
+
# Send the request.
|
|
1686
|
+
response = await rpc(
|
|
1687
|
+
request,
|
|
1688
|
+
retry=retry,
|
|
1689
|
+
timeout=timeout,
|
|
1690
|
+
metadata=metadata,
|
|
1691
|
+
)
|
|
1692
|
+
|
|
1693
|
+
# Done; return the response.
|
|
1694
|
+
return response
|
|
1695
|
+
|
|
1696
|
+
async def deny_grant(
|
|
1697
|
+
self,
|
|
1698
|
+
request: Optional[Union[privilegedaccessmanager.DenyGrantRequest, dict]] = None,
|
|
1699
|
+
*,
|
|
1700
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1701
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1702
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
1703
|
+
) -> privilegedaccessmanager.Grant:
|
|
1704
|
+
r"""``DenyGrant`` is used to deny a grant. This method can only be
|
|
1705
|
+
called on a grant when it's in the ``APPROVAL_AWAITED`` state.
|
|
1706
|
+
This operation can't be undone.
|
|
1707
|
+
|
|
1708
|
+
.. code-block:: python
|
|
1709
|
+
|
|
1710
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1711
|
+
# code template only.
|
|
1712
|
+
# It will require modifications to work:
|
|
1713
|
+
# - It may require correct/in-range values for request initialization.
|
|
1714
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1715
|
+
# client as shown in:
|
|
1716
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1717
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
1718
|
+
|
|
1719
|
+
async def sample_deny_grant():
|
|
1720
|
+
# Create a client
|
|
1721
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
1722
|
+
|
|
1723
|
+
# Initialize request argument(s)
|
|
1724
|
+
request = privilegedaccessmanager_v1.DenyGrantRequest(
|
|
1725
|
+
name="name_value",
|
|
1726
|
+
)
|
|
1727
|
+
|
|
1728
|
+
# Make the request
|
|
1729
|
+
response = await client.deny_grant(request=request)
|
|
1730
|
+
|
|
1731
|
+
# Handle the response
|
|
1732
|
+
print(response)
|
|
1733
|
+
|
|
1734
|
+
Args:
|
|
1735
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.DenyGrantRequest, dict]]):
|
|
1736
|
+
The request object. Request message for ``DenyGrant`` method.
|
|
1737
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1738
|
+
should be retried.
|
|
1739
|
+
timeout (float): The timeout for this request.
|
|
1740
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
1741
|
+
sent along with the request as metadata.
|
|
1742
|
+
|
|
1743
|
+
Returns:
|
|
1744
|
+
google.cloud.privilegedaccessmanager_v1.types.Grant:
|
|
1745
|
+
This is to ensure that the Grants and ProducerGrants proto are byte
|
|
1746
|
+
compatible. A grant represents a request from a user
|
|
1747
|
+
for obtaining the access specified in an entitlement
|
|
1748
|
+
they are eligible for.
|
|
1749
|
+
|
|
1750
|
+
"""
|
|
1751
|
+
# Create or coerce a protobuf request object.
|
|
1752
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1753
|
+
# there are no flattened fields), or create one.
|
|
1754
|
+
if not isinstance(request, privilegedaccessmanager.DenyGrantRequest):
|
|
1755
|
+
request = privilegedaccessmanager.DenyGrantRequest(request)
|
|
1756
|
+
|
|
1757
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1758
|
+
# and friendly error handling.
|
|
1759
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1760
|
+
self._client._transport.deny_grant
|
|
1761
|
+
]
|
|
1762
|
+
|
|
1763
|
+
# Certain fields should be provided within the metadata header;
|
|
1764
|
+
# add these here.
|
|
1765
|
+
metadata = tuple(metadata) + (
|
|
1766
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1767
|
+
)
|
|
1768
|
+
|
|
1769
|
+
# Validate the universe domain.
|
|
1770
|
+
self._client._validate_universe_domain()
|
|
1771
|
+
|
|
1772
|
+
# Send the request.
|
|
1773
|
+
response = await rpc(
|
|
1774
|
+
request,
|
|
1775
|
+
retry=retry,
|
|
1776
|
+
timeout=timeout,
|
|
1777
|
+
metadata=metadata,
|
|
1778
|
+
)
|
|
1779
|
+
|
|
1780
|
+
# Done; return the response.
|
|
1781
|
+
return response
|
|
1782
|
+
|
|
1783
|
+
async def revoke_grant(
|
|
1784
|
+
self,
|
|
1785
|
+
request: Optional[
|
|
1786
|
+
Union[privilegedaccessmanager.RevokeGrantRequest, dict]
|
|
1787
|
+
] = None,
|
|
1788
|
+
*,
|
|
1789
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1790
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1791
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
1792
|
+
) -> operation_async.AsyncOperation:
|
|
1793
|
+
r"""``RevokeGrant`` is used to immediately revoke access for a
|
|
1794
|
+
grant. This method can be called when the grant is in a
|
|
1795
|
+
non-terminal state.
|
|
1796
|
+
|
|
1797
|
+
.. code-block:: python
|
|
1798
|
+
|
|
1799
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1800
|
+
# code template only.
|
|
1801
|
+
# It will require modifications to work:
|
|
1802
|
+
# - It may require correct/in-range values for request initialization.
|
|
1803
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1804
|
+
# client as shown in:
|
|
1805
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1806
|
+
from google.cloud import privilegedaccessmanager_v1
|
|
1807
|
+
|
|
1808
|
+
async def sample_revoke_grant():
|
|
1809
|
+
# Create a client
|
|
1810
|
+
client = privilegedaccessmanager_v1.PrivilegedAccessManagerAsyncClient()
|
|
1811
|
+
|
|
1812
|
+
# Initialize request argument(s)
|
|
1813
|
+
request = privilegedaccessmanager_v1.RevokeGrantRequest(
|
|
1814
|
+
name="name_value",
|
|
1815
|
+
)
|
|
1816
|
+
|
|
1817
|
+
# Make the request
|
|
1818
|
+
operation = client.revoke_grant(request=request)
|
|
1819
|
+
|
|
1820
|
+
print("Waiting for operation to complete...")
|
|
1821
|
+
|
|
1822
|
+
response = (await operation).result()
|
|
1823
|
+
|
|
1824
|
+
# Handle the response
|
|
1825
|
+
print(response)
|
|
1826
|
+
|
|
1827
|
+
Args:
|
|
1828
|
+
request (Optional[Union[google.cloud.privilegedaccessmanager_v1.types.RevokeGrantRequest, dict]]):
|
|
1829
|
+
The request object. Request message for ``RevokeGrant`` method.
|
|
1830
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1831
|
+
should be retried.
|
|
1832
|
+
timeout (float): The timeout for this request.
|
|
1833
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
1834
|
+
sent along with the request as metadata.
|
|
1835
|
+
|
|
1836
|
+
Returns:
|
|
1837
|
+
google.api_core.operation_async.AsyncOperation:
|
|
1838
|
+
An object representing a long-running operation.
|
|
1839
|
+
|
|
1840
|
+
The result type for the operation will be :class:`google.cloud.privilegedaccessmanager_v1.types.Grant` This is to ensure that the Grants and ProducerGrants proto are byte
|
|
1841
|
+
compatible. A grant represents a request from a user
|
|
1842
|
+
for obtaining the access specified in an entitlement
|
|
1843
|
+
they are eligible for.
|
|
1844
|
+
|
|
1845
|
+
"""
|
|
1846
|
+
# Create or coerce a protobuf request object.
|
|
1847
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1848
|
+
# there are no flattened fields), or create one.
|
|
1849
|
+
if not isinstance(request, privilegedaccessmanager.RevokeGrantRequest):
|
|
1850
|
+
request = privilegedaccessmanager.RevokeGrantRequest(request)
|
|
1851
|
+
|
|
1852
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1853
|
+
# and friendly error handling.
|
|
1854
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1855
|
+
self._client._transport.revoke_grant
|
|
1856
|
+
]
|
|
1857
|
+
|
|
1858
|
+
# Certain fields should be provided within the metadata header;
|
|
1859
|
+
# add these here.
|
|
1860
|
+
metadata = tuple(metadata) + (
|
|
1861
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1862
|
+
)
|
|
1863
|
+
|
|
1864
|
+
# Validate the universe domain.
|
|
1865
|
+
self._client._validate_universe_domain()
|
|
1866
|
+
|
|
1867
|
+
# Send the request.
|
|
1868
|
+
response = await rpc(
|
|
1869
|
+
request,
|
|
1870
|
+
retry=retry,
|
|
1871
|
+
timeout=timeout,
|
|
1872
|
+
metadata=metadata,
|
|
1873
|
+
)
|
|
1874
|
+
|
|
1875
|
+
# Wrap the response in an operation future.
|
|
1876
|
+
response = operation_async.from_gapic(
|
|
1877
|
+
response,
|
|
1878
|
+
self._client._transport.operations_client,
|
|
1879
|
+
privilegedaccessmanager.Grant,
|
|
1880
|
+
metadata_type=privilegedaccessmanager.OperationMetadata,
|
|
1881
|
+
)
|
|
1882
|
+
|
|
1883
|
+
# Done; return the response.
|
|
1884
|
+
return response
|
|
1885
|
+
|
|
1886
|
+
async def list_operations(
|
|
1887
|
+
self,
|
|
1888
|
+
request: Optional[operations_pb2.ListOperationsRequest] = None,
|
|
1889
|
+
*,
|
|
1890
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1891
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1892
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
1893
|
+
) -> operations_pb2.ListOperationsResponse:
|
|
1894
|
+
r"""Lists operations that match the specified filter in the request.
|
|
1895
|
+
|
|
1896
|
+
Args:
|
|
1897
|
+
request (:class:`~.operations_pb2.ListOperationsRequest`):
|
|
1898
|
+
The request object. Request message for
|
|
1899
|
+
`ListOperations` method.
|
|
1900
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
1901
|
+
if any, should be retried.
|
|
1902
|
+
timeout (float): The timeout for this request.
|
|
1903
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
1904
|
+
sent along with the request as metadata.
|
|
1905
|
+
Returns:
|
|
1906
|
+
~.operations_pb2.ListOperationsResponse:
|
|
1907
|
+
Response message for ``ListOperations`` method.
|
|
1908
|
+
"""
|
|
1909
|
+
# Create or coerce a protobuf request object.
|
|
1910
|
+
# The request isn't a proto-plus wrapped type,
|
|
1911
|
+
# so it must be constructed via keyword expansion.
|
|
1912
|
+
if isinstance(request, dict):
|
|
1913
|
+
request = operations_pb2.ListOperationsRequest(**request)
|
|
1914
|
+
|
|
1915
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1916
|
+
# and friendly error handling.
|
|
1917
|
+
rpc = gapic_v1.method_async.wrap_method(
|
|
1918
|
+
self._client._transport.list_operations,
|
|
1919
|
+
default_timeout=None,
|
|
1920
|
+
client_info=DEFAULT_CLIENT_INFO,
|
|
1921
|
+
)
|
|
1922
|
+
|
|
1923
|
+
# Certain fields should be provided within the metadata header;
|
|
1924
|
+
# add these here.
|
|
1925
|
+
metadata = tuple(metadata) + (
|
|
1926
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1927
|
+
)
|
|
1928
|
+
|
|
1929
|
+
# Validate the universe domain.
|
|
1930
|
+
self._client._validate_universe_domain()
|
|
1931
|
+
|
|
1932
|
+
# Send the request.
|
|
1933
|
+
response = await rpc(
|
|
1934
|
+
request,
|
|
1935
|
+
retry=retry,
|
|
1936
|
+
timeout=timeout,
|
|
1937
|
+
metadata=metadata,
|
|
1938
|
+
)
|
|
1939
|
+
|
|
1940
|
+
# Done; return the response.
|
|
1941
|
+
return response
|
|
1942
|
+
|
|
1943
|
+
async def get_operation(
|
|
1944
|
+
self,
|
|
1945
|
+
request: Optional[operations_pb2.GetOperationRequest] = None,
|
|
1946
|
+
*,
|
|
1947
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1948
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1949
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
1950
|
+
) -> operations_pb2.Operation:
|
|
1951
|
+
r"""Gets the latest state of a long-running operation.
|
|
1952
|
+
|
|
1953
|
+
Args:
|
|
1954
|
+
request (:class:`~.operations_pb2.GetOperationRequest`):
|
|
1955
|
+
The request object. Request message for
|
|
1956
|
+
`GetOperation` method.
|
|
1957
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
1958
|
+
if any, should be retried.
|
|
1959
|
+
timeout (float): The timeout for this request.
|
|
1960
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
1961
|
+
sent along with the request as metadata.
|
|
1962
|
+
Returns:
|
|
1963
|
+
~.operations_pb2.Operation:
|
|
1964
|
+
An ``Operation`` object.
|
|
1965
|
+
"""
|
|
1966
|
+
# Create or coerce a protobuf request object.
|
|
1967
|
+
# The request isn't a proto-plus wrapped type,
|
|
1968
|
+
# so it must be constructed via keyword expansion.
|
|
1969
|
+
if isinstance(request, dict):
|
|
1970
|
+
request = operations_pb2.GetOperationRequest(**request)
|
|
1971
|
+
|
|
1972
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1973
|
+
# and friendly error handling.
|
|
1974
|
+
rpc = gapic_v1.method_async.wrap_method(
|
|
1975
|
+
self._client._transport.get_operation,
|
|
1976
|
+
default_timeout=None,
|
|
1977
|
+
client_info=DEFAULT_CLIENT_INFO,
|
|
1978
|
+
)
|
|
1979
|
+
|
|
1980
|
+
# Certain fields should be provided within the metadata header;
|
|
1981
|
+
# add these here.
|
|
1982
|
+
metadata = tuple(metadata) + (
|
|
1983
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1984
|
+
)
|
|
1985
|
+
|
|
1986
|
+
# Validate the universe domain.
|
|
1987
|
+
self._client._validate_universe_domain()
|
|
1988
|
+
|
|
1989
|
+
# Send the request.
|
|
1990
|
+
response = await rpc(
|
|
1991
|
+
request,
|
|
1992
|
+
retry=retry,
|
|
1993
|
+
timeout=timeout,
|
|
1994
|
+
metadata=metadata,
|
|
1995
|
+
)
|
|
1996
|
+
|
|
1997
|
+
# Done; return the response.
|
|
1998
|
+
return response
|
|
1999
|
+
|
|
2000
|
+
async def delete_operation(
|
|
2001
|
+
self,
|
|
2002
|
+
request: Optional[operations_pb2.DeleteOperationRequest] = None,
|
|
2003
|
+
*,
|
|
2004
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2005
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2006
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
2007
|
+
) -> None:
|
|
2008
|
+
r"""Deletes a long-running operation.
|
|
2009
|
+
|
|
2010
|
+
This method indicates that the client is no longer interested
|
|
2011
|
+
in the operation result. It does not cancel the operation.
|
|
2012
|
+
If the server doesn't support this method, it returns
|
|
2013
|
+
`google.rpc.Code.UNIMPLEMENTED`.
|
|
2014
|
+
|
|
2015
|
+
Args:
|
|
2016
|
+
request (:class:`~.operations_pb2.DeleteOperationRequest`):
|
|
2017
|
+
The request object. Request message for
|
|
2018
|
+
`DeleteOperation` method.
|
|
2019
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
2020
|
+
if any, should be retried.
|
|
2021
|
+
timeout (float): The timeout for this request.
|
|
2022
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
2023
|
+
sent along with the request as metadata.
|
|
2024
|
+
Returns:
|
|
2025
|
+
None
|
|
2026
|
+
"""
|
|
2027
|
+
# Create or coerce a protobuf request object.
|
|
2028
|
+
# The request isn't a proto-plus wrapped type,
|
|
2029
|
+
# so it must be constructed via keyword expansion.
|
|
2030
|
+
if isinstance(request, dict):
|
|
2031
|
+
request = operations_pb2.DeleteOperationRequest(**request)
|
|
2032
|
+
|
|
2033
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2034
|
+
# and friendly error handling.
|
|
2035
|
+
rpc = gapic_v1.method_async.wrap_method(
|
|
2036
|
+
self._client._transport.delete_operation,
|
|
2037
|
+
default_timeout=None,
|
|
2038
|
+
client_info=DEFAULT_CLIENT_INFO,
|
|
2039
|
+
)
|
|
2040
|
+
|
|
2041
|
+
# Certain fields should be provided within the metadata header;
|
|
2042
|
+
# add these here.
|
|
2043
|
+
metadata = tuple(metadata) + (
|
|
2044
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
2045
|
+
)
|
|
2046
|
+
|
|
2047
|
+
# Validate the universe domain.
|
|
2048
|
+
self._client._validate_universe_domain()
|
|
2049
|
+
|
|
2050
|
+
# Send the request.
|
|
2051
|
+
await rpc(
|
|
2052
|
+
request,
|
|
2053
|
+
retry=retry,
|
|
2054
|
+
timeout=timeout,
|
|
2055
|
+
metadata=metadata,
|
|
2056
|
+
)
|
|
2057
|
+
|
|
2058
|
+
async def get_location(
|
|
2059
|
+
self,
|
|
2060
|
+
request: Optional[locations_pb2.GetLocationRequest] = None,
|
|
2061
|
+
*,
|
|
2062
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2063
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2064
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
2065
|
+
) -> locations_pb2.Location:
|
|
2066
|
+
r"""Gets information about a location.
|
|
2067
|
+
|
|
2068
|
+
Args:
|
|
2069
|
+
request (:class:`~.location_pb2.GetLocationRequest`):
|
|
2070
|
+
The request object. Request message for
|
|
2071
|
+
`GetLocation` method.
|
|
2072
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
2073
|
+
if any, should be retried.
|
|
2074
|
+
timeout (float): The timeout for this request.
|
|
2075
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
2076
|
+
sent along with the request as metadata.
|
|
2077
|
+
Returns:
|
|
2078
|
+
~.location_pb2.Location:
|
|
2079
|
+
Location object.
|
|
2080
|
+
"""
|
|
2081
|
+
# Create or coerce a protobuf request object.
|
|
2082
|
+
# The request isn't a proto-plus wrapped type,
|
|
2083
|
+
# so it must be constructed via keyword expansion.
|
|
2084
|
+
if isinstance(request, dict):
|
|
2085
|
+
request = locations_pb2.GetLocationRequest(**request)
|
|
2086
|
+
|
|
2087
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2088
|
+
# and friendly error handling.
|
|
2089
|
+
rpc = gapic_v1.method_async.wrap_method(
|
|
2090
|
+
self._client._transport.get_location,
|
|
2091
|
+
default_timeout=None,
|
|
2092
|
+
client_info=DEFAULT_CLIENT_INFO,
|
|
2093
|
+
)
|
|
2094
|
+
|
|
2095
|
+
# Certain fields should be provided within the metadata header;
|
|
2096
|
+
# add these here.
|
|
2097
|
+
metadata = tuple(metadata) + (
|
|
2098
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
2099
|
+
)
|
|
2100
|
+
|
|
2101
|
+
# Validate the universe domain.
|
|
2102
|
+
self._client._validate_universe_domain()
|
|
2103
|
+
|
|
2104
|
+
# Send the request.
|
|
2105
|
+
response = await rpc(
|
|
2106
|
+
request,
|
|
2107
|
+
retry=retry,
|
|
2108
|
+
timeout=timeout,
|
|
2109
|
+
metadata=metadata,
|
|
2110
|
+
)
|
|
2111
|
+
|
|
2112
|
+
# Done; return the response.
|
|
2113
|
+
return response
|
|
2114
|
+
|
|
2115
|
+
async def list_locations(
|
|
2116
|
+
self,
|
|
2117
|
+
request: Optional[locations_pb2.ListLocationsRequest] = None,
|
|
2118
|
+
*,
|
|
2119
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
2120
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
2121
|
+
metadata: Sequence[Tuple[str, str]] = (),
|
|
2122
|
+
) -> locations_pb2.ListLocationsResponse:
|
|
2123
|
+
r"""Lists information about the supported locations for this service.
|
|
2124
|
+
|
|
2125
|
+
Args:
|
|
2126
|
+
request (:class:`~.location_pb2.ListLocationsRequest`):
|
|
2127
|
+
The request object. Request message for
|
|
2128
|
+
`ListLocations` method.
|
|
2129
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
2130
|
+
if any, should be retried.
|
|
2131
|
+
timeout (float): The timeout for this request.
|
|
2132
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
2133
|
+
sent along with the request as metadata.
|
|
2134
|
+
Returns:
|
|
2135
|
+
~.location_pb2.ListLocationsResponse:
|
|
2136
|
+
Response message for ``ListLocations`` method.
|
|
2137
|
+
"""
|
|
2138
|
+
# Create or coerce a protobuf request object.
|
|
2139
|
+
# The request isn't a proto-plus wrapped type,
|
|
2140
|
+
# so it must be constructed via keyword expansion.
|
|
2141
|
+
if isinstance(request, dict):
|
|
2142
|
+
request = locations_pb2.ListLocationsRequest(**request)
|
|
2143
|
+
|
|
2144
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
2145
|
+
# and friendly error handling.
|
|
2146
|
+
rpc = gapic_v1.method_async.wrap_method(
|
|
2147
|
+
self._client._transport.list_locations,
|
|
2148
|
+
default_timeout=None,
|
|
2149
|
+
client_info=DEFAULT_CLIENT_INFO,
|
|
2150
|
+
)
|
|
2151
|
+
|
|
2152
|
+
# Certain fields should be provided within the metadata header;
|
|
2153
|
+
# add these here.
|
|
2154
|
+
metadata = tuple(metadata) + (
|
|
2155
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
2156
|
+
)
|
|
2157
|
+
|
|
2158
|
+
# Validate the universe domain.
|
|
2159
|
+
self._client._validate_universe_domain()
|
|
2160
|
+
|
|
2161
|
+
# Send the request.
|
|
2162
|
+
response = await rpc(
|
|
2163
|
+
request,
|
|
2164
|
+
retry=retry,
|
|
2165
|
+
timeout=timeout,
|
|
2166
|
+
metadata=metadata,
|
|
2167
|
+
)
|
|
2168
|
+
|
|
2169
|
+
# Done; return the response.
|
|
2170
|
+
return response
|
|
2171
|
+
|
|
2172
|
+
async def __aenter__(self) -> "PrivilegedAccessManagerAsyncClient":
|
|
2173
|
+
return self
|
|
2174
|
+
|
|
2175
|
+
async def __aexit__(self, exc_type, exc, tb):
|
|
2176
|
+
await self.transport.close()
|
|
2177
|
+
|
|
2178
|
+
|
|
2179
|
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
2180
|
+
gapic_version=package_version.__version__
|
|
2181
|
+
)
|
|
2182
|
+
|
|
2183
|
+
|
|
2184
|
+
__all__ = ("PrivilegedAccessManagerAsyncClient",)
|