google-cloud-cloudcontrolspartner 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.
Files changed (76) hide show
  1. google/cloud/cloudcontrolspartner/__init__.py +115 -0
  2. google/cloud/cloudcontrolspartner/gapic_version.py +16 -0
  3. google/cloud/cloudcontrolspartner/py.typed +2 -0
  4. google/cloud/cloudcontrolspartner_v1/__init__.py +103 -0
  5. google/cloud/cloudcontrolspartner_v1/gapic_metadata.json +197 -0
  6. google/cloud/cloudcontrolspartner_v1/gapic_version.py +16 -0
  7. google/cloud/cloudcontrolspartner_v1/py.typed +2 -0
  8. google/cloud/cloudcontrolspartner_v1/services/__init__.py +15 -0
  9. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/__init__.py +22 -0
  10. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/async_client.py +1253 -0
  11. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/client.py +1705 -0
  12. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/pagers.py +429 -0
  13. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/transports/__init__.py +41 -0
  14. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/transports/base.py +340 -0
  15. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/transports/grpc.py +466 -0
  16. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/transports/grpc_asyncio.py +472 -0
  17. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/transports/rest.py +1212 -0
  18. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/__init__.py +22 -0
  19. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/async_client.py +528 -0
  20. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/client.py +935 -0
  21. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/pagers.py +155 -0
  22. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/transports/__init__.py +41 -0
  23. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/transports/base.py +194 -0
  24. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/transports/grpc.py +300 -0
  25. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/transports/grpc_asyncio.py +299 -0
  26. google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/transports/rest.py +434 -0
  27. google/cloud/cloudcontrolspartner_v1/types/__init__.py +82 -0
  28. google/cloud/cloudcontrolspartner_v1/types/access_approval_requests.py +228 -0
  29. google/cloud/cloudcontrolspartner_v1/types/completion_state.py +53 -0
  30. google/cloud/cloudcontrolspartner_v1/types/core.py +93 -0
  31. google/cloud/cloudcontrolspartner_v1/types/customer_workloads.py +300 -0
  32. google/cloud/cloudcontrolspartner_v1/types/customers.py +233 -0
  33. google/cloud/cloudcontrolspartner_v1/types/ekm_connections.py +141 -0
  34. google/cloud/cloudcontrolspartner_v1/types/monitoring.py +24 -0
  35. google/cloud/cloudcontrolspartner_v1/types/partner_permissions.py +94 -0
  36. google/cloud/cloudcontrolspartner_v1/types/partners.py +188 -0
  37. google/cloud/cloudcontrolspartner_v1/types/violations.py +388 -0
  38. google/cloud/cloudcontrolspartner_v1beta/__init__.py +103 -0
  39. google/cloud/cloudcontrolspartner_v1beta/gapic_metadata.json +197 -0
  40. google/cloud/cloudcontrolspartner_v1beta/gapic_version.py +16 -0
  41. google/cloud/cloudcontrolspartner_v1beta/py.typed +2 -0
  42. google/cloud/cloudcontrolspartner_v1beta/services/__init__.py +15 -0
  43. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/__init__.py +22 -0
  44. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/async_client.py +1262 -0
  45. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/client.py +1714 -0
  46. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/pagers.py +429 -0
  47. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/transports/__init__.py +41 -0
  48. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/transports/base.py +340 -0
  49. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/transports/grpc.py +466 -0
  50. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/transports/grpc_asyncio.py +472 -0
  51. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/transports/rest.py +1212 -0
  52. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/__init__.py +22 -0
  53. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/async_client.py +530 -0
  54. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/client.py +937 -0
  55. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/pagers.py +155 -0
  56. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/transports/__init__.py +41 -0
  57. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/transports/base.py +194 -0
  58. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/transports/grpc.py +300 -0
  59. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/transports/grpc_asyncio.py +299 -0
  60. google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/transports/rest.py +434 -0
  61. google/cloud/cloudcontrolspartner_v1beta/types/__init__.py +82 -0
  62. google/cloud/cloudcontrolspartner_v1beta/types/access_approval_requests.py +230 -0
  63. google/cloud/cloudcontrolspartner_v1beta/types/completion_state.py +53 -0
  64. google/cloud/cloudcontrolspartner_v1beta/types/core.py +93 -0
  65. google/cloud/cloudcontrolspartner_v1beta/types/customer_workloads.py +304 -0
  66. google/cloud/cloudcontrolspartner_v1beta/types/customers.py +236 -0
  67. google/cloud/cloudcontrolspartner_v1beta/types/ekm_connections.py +143 -0
  68. google/cloud/cloudcontrolspartner_v1beta/types/monitoring.py +24 -0
  69. google/cloud/cloudcontrolspartner_v1beta/types/partner_permissions.py +96 -0
  70. google/cloud/cloudcontrolspartner_v1beta/types/partners.py +189 -0
  71. google/cloud/cloudcontrolspartner_v1beta/types/violations.py +391 -0
  72. google_cloud_cloudcontrolspartner-0.1.0.dist-info/LICENSE +202 -0
  73. google_cloud_cloudcontrolspartner-0.1.0.dist-info/METADATA +137 -0
  74. google_cloud_cloudcontrolspartner-0.1.0.dist-info/RECORD +76 -0
  75. google_cloud_cloudcontrolspartner-0.1.0.dist-info/WHEEL +5 -0
  76. google_cloud_cloudcontrolspartner-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1714 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2023 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 os
18
+ import re
19
+ from typing import (
20
+ Dict,
21
+ Mapping,
22
+ MutableMapping,
23
+ MutableSequence,
24
+ Optional,
25
+ Sequence,
26
+ Tuple,
27
+ Type,
28
+ Union,
29
+ cast,
30
+ )
31
+ import warnings
32
+
33
+ from google.api_core import client_options as client_options_lib
34
+ from google.api_core import exceptions as core_exceptions
35
+ from google.api_core import gapic_v1
36
+ from google.api_core import retry as retries
37
+ from google.auth import credentials as ga_credentials # type: ignore
38
+ from google.auth.exceptions import MutualTLSChannelError # type: ignore
39
+ from google.auth.transport import mtls # type: ignore
40
+ from google.auth.transport.grpc import SslCredentials # type: ignore
41
+ from google.oauth2 import service_account # type: ignore
42
+
43
+ from google.cloud.cloudcontrolspartner_v1beta import gapic_version as package_version
44
+
45
+ try:
46
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
47
+ except AttributeError: # pragma: NO COVER
48
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
49
+
50
+ from google.protobuf import timestamp_pb2 # type: ignore
51
+
52
+ from google.cloud.cloudcontrolspartner_v1beta.services.cloud_controls_partner_core import (
53
+ pagers,
54
+ )
55
+ from google.cloud.cloudcontrolspartner_v1beta.types import (
56
+ access_approval_requests,
57
+ customer_workloads,
58
+ customers,
59
+ ekm_connections,
60
+ partner_permissions,
61
+ partners,
62
+ )
63
+
64
+ from .transports.base import DEFAULT_CLIENT_INFO, CloudControlsPartnerCoreTransport
65
+ from .transports.grpc import CloudControlsPartnerCoreGrpcTransport
66
+ from .transports.grpc_asyncio import CloudControlsPartnerCoreGrpcAsyncIOTransport
67
+ from .transports.rest import CloudControlsPartnerCoreRestTransport
68
+
69
+
70
+ class CloudControlsPartnerCoreClientMeta(type):
71
+ """Metaclass for the CloudControlsPartnerCore client.
72
+
73
+ This provides class-level methods for building and retrieving
74
+ support objects (e.g. transport) without polluting the client instance
75
+ objects.
76
+ """
77
+
78
+ _transport_registry = (
79
+ OrderedDict()
80
+ ) # type: Dict[str, Type[CloudControlsPartnerCoreTransport]]
81
+ _transport_registry["grpc"] = CloudControlsPartnerCoreGrpcTransport
82
+ _transport_registry["grpc_asyncio"] = CloudControlsPartnerCoreGrpcAsyncIOTransport
83
+ _transport_registry["rest"] = CloudControlsPartnerCoreRestTransport
84
+
85
+ def get_transport_class(
86
+ cls,
87
+ label: Optional[str] = None,
88
+ ) -> Type[CloudControlsPartnerCoreTransport]:
89
+ """Returns an appropriate transport class.
90
+
91
+ Args:
92
+ label: The name of the desired transport. If none is
93
+ provided, then the first transport in the registry is used.
94
+
95
+ Returns:
96
+ The transport class to use.
97
+ """
98
+ # If a specific transport is requested, return that one.
99
+ if label:
100
+ return cls._transport_registry[label]
101
+
102
+ # No transport is requested; return the default (that is, the first one
103
+ # in the dictionary).
104
+ return next(iter(cls._transport_registry.values()))
105
+
106
+
107
+ class CloudControlsPartnerCoreClient(metaclass=CloudControlsPartnerCoreClientMeta):
108
+ """Service describing handlers for resources"""
109
+
110
+ @staticmethod
111
+ def _get_default_mtls_endpoint(api_endpoint):
112
+ """Converts api endpoint to mTLS endpoint.
113
+
114
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
115
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
116
+ Args:
117
+ api_endpoint (Optional[str]): the api endpoint to convert.
118
+ Returns:
119
+ str: converted mTLS api endpoint.
120
+ """
121
+ if not api_endpoint:
122
+ return api_endpoint
123
+
124
+ mtls_endpoint_re = re.compile(
125
+ r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
126
+ )
127
+
128
+ m = mtls_endpoint_re.match(api_endpoint)
129
+ name, mtls, sandbox, googledomain = m.groups()
130
+ if mtls or not googledomain:
131
+ return api_endpoint
132
+
133
+ if sandbox:
134
+ return api_endpoint.replace(
135
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
136
+ )
137
+
138
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
139
+
140
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
141
+ DEFAULT_ENDPOINT = "cloudcontrolspartner.googleapis.com"
142
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
143
+ DEFAULT_ENDPOINT
144
+ )
145
+
146
+ _DEFAULT_ENDPOINT_TEMPLATE = "cloudcontrolspartner.{UNIVERSE_DOMAIN}"
147
+ _DEFAULT_UNIVERSE = "googleapis.com"
148
+
149
+ @classmethod
150
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
151
+ """Creates an instance of this client using the provided credentials
152
+ info.
153
+
154
+ Args:
155
+ info (dict): The service account private key info.
156
+ args: Additional arguments to pass to the constructor.
157
+ kwargs: Additional arguments to pass to the constructor.
158
+
159
+ Returns:
160
+ CloudControlsPartnerCoreClient: The constructed client.
161
+ """
162
+ credentials = service_account.Credentials.from_service_account_info(info)
163
+ kwargs["credentials"] = credentials
164
+ return cls(*args, **kwargs)
165
+
166
+ @classmethod
167
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
168
+ """Creates an instance of this client using the provided credentials
169
+ file.
170
+
171
+ Args:
172
+ filename (str): The path to the service account private key json
173
+ file.
174
+ args: Additional arguments to pass to the constructor.
175
+ kwargs: Additional arguments to pass to the constructor.
176
+
177
+ Returns:
178
+ CloudControlsPartnerCoreClient: The constructed client.
179
+ """
180
+ credentials = service_account.Credentials.from_service_account_file(filename)
181
+ kwargs["credentials"] = credentials
182
+ return cls(*args, **kwargs)
183
+
184
+ from_service_account_json = from_service_account_file
185
+
186
+ @property
187
+ def transport(self) -> CloudControlsPartnerCoreTransport:
188
+ """Returns the transport used by the client instance.
189
+
190
+ Returns:
191
+ CloudControlsPartnerCoreTransport: The transport used by the client
192
+ instance.
193
+ """
194
+ return self._transport
195
+
196
+ @staticmethod
197
+ def access_approval_request_path(
198
+ organization: str,
199
+ location: str,
200
+ customer: str,
201
+ workload: str,
202
+ access_approval_request: str,
203
+ ) -> str:
204
+ """Returns a fully-qualified access_approval_request string."""
205
+ return "organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}/accessApprovalRequests/{access_approval_request}".format(
206
+ organization=organization,
207
+ location=location,
208
+ customer=customer,
209
+ workload=workload,
210
+ access_approval_request=access_approval_request,
211
+ )
212
+
213
+ @staticmethod
214
+ def parse_access_approval_request_path(path: str) -> Dict[str, str]:
215
+ """Parses a access_approval_request path into its component segments."""
216
+ m = re.match(
217
+ r"^organizations/(?P<organization>.+?)/locations/(?P<location>.+?)/customers/(?P<customer>.+?)/workloads/(?P<workload>.+?)/accessApprovalRequests/(?P<access_approval_request>.+?)$",
218
+ path,
219
+ )
220
+ return m.groupdict() if m else {}
221
+
222
+ @staticmethod
223
+ def customer_path(
224
+ organization: str,
225
+ location: str,
226
+ customer: str,
227
+ ) -> str:
228
+ """Returns a fully-qualified customer string."""
229
+ return "organizations/{organization}/locations/{location}/customers/{customer}".format(
230
+ organization=organization,
231
+ location=location,
232
+ customer=customer,
233
+ )
234
+
235
+ @staticmethod
236
+ def parse_customer_path(path: str) -> Dict[str, str]:
237
+ """Parses a customer path into its component segments."""
238
+ m = re.match(
239
+ r"^organizations/(?P<organization>.+?)/locations/(?P<location>.+?)/customers/(?P<customer>.+?)$",
240
+ path,
241
+ )
242
+ return m.groupdict() if m else {}
243
+
244
+ @staticmethod
245
+ def ekm_connections_path(
246
+ organization: str,
247
+ location: str,
248
+ customer: str,
249
+ workload: str,
250
+ ) -> str:
251
+ """Returns a fully-qualified ekm_connections string."""
252
+ return "organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}/ekmConnections".format(
253
+ organization=organization,
254
+ location=location,
255
+ customer=customer,
256
+ workload=workload,
257
+ )
258
+
259
+ @staticmethod
260
+ def parse_ekm_connections_path(path: str) -> Dict[str, str]:
261
+ """Parses a ekm_connections path into its component segments."""
262
+ m = re.match(
263
+ r"^organizations/(?P<organization>.+?)/locations/(?P<location>.+?)/customers/(?P<customer>.+?)/workloads/(?P<workload>.+?)/ekmConnections$",
264
+ path,
265
+ )
266
+ return m.groupdict() if m else {}
267
+
268
+ @staticmethod
269
+ def partner_path(
270
+ organization: str,
271
+ location: str,
272
+ ) -> str:
273
+ """Returns a fully-qualified partner string."""
274
+ return "organizations/{organization}/locations/{location}/partner".format(
275
+ organization=organization,
276
+ location=location,
277
+ )
278
+
279
+ @staticmethod
280
+ def parse_partner_path(path: str) -> Dict[str, str]:
281
+ """Parses a partner path into its component segments."""
282
+ m = re.match(
283
+ r"^organizations/(?P<organization>.+?)/locations/(?P<location>.+?)/partner$",
284
+ path,
285
+ )
286
+ return m.groupdict() if m else {}
287
+
288
+ @staticmethod
289
+ def partner_permissions_path(
290
+ organization: str,
291
+ location: str,
292
+ customer: str,
293
+ workload: str,
294
+ ) -> str:
295
+ """Returns a fully-qualified partner_permissions string."""
296
+ return "organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}/partnerPermissions".format(
297
+ organization=organization,
298
+ location=location,
299
+ customer=customer,
300
+ workload=workload,
301
+ )
302
+
303
+ @staticmethod
304
+ def parse_partner_permissions_path(path: str) -> Dict[str, str]:
305
+ """Parses a partner_permissions path into its component segments."""
306
+ m = re.match(
307
+ r"^organizations/(?P<organization>.+?)/locations/(?P<location>.+?)/customers/(?P<customer>.+?)/workloads/(?P<workload>.+?)/partnerPermissions$",
308
+ path,
309
+ )
310
+ return m.groupdict() if m else {}
311
+
312
+ @staticmethod
313
+ def workload_path(
314
+ organization: str,
315
+ location: str,
316
+ customer: str,
317
+ workload: str,
318
+ ) -> str:
319
+ """Returns a fully-qualified workload string."""
320
+ return "organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}".format(
321
+ organization=organization,
322
+ location=location,
323
+ customer=customer,
324
+ workload=workload,
325
+ )
326
+
327
+ @staticmethod
328
+ def parse_workload_path(path: str) -> Dict[str, str]:
329
+ """Parses a workload path into its component segments."""
330
+ m = re.match(
331
+ r"^organizations/(?P<organization>.+?)/locations/(?P<location>.+?)/customers/(?P<customer>.+?)/workloads/(?P<workload>.+?)$",
332
+ path,
333
+ )
334
+ return m.groupdict() if m else {}
335
+
336
+ @staticmethod
337
+ def common_billing_account_path(
338
+ billing_account: str,
339
+ ) -> str:
340
+ """Returns a fully-qualified billing_account string."""
341
+ return "billingAccounts/{billing_account}".format(
342
+ billing_account=billing_account,
343
+ )
344
+
345
+ @staticmethod
346
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
347
+ """Parse a billing_account path into its component segments."""
348
+ m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
349
+ return m.groupdict() if m else {}
350
+
351
+ @staticmethod
352
+ def common_folder_path(
353
+ folder: str,
354
+ ) -> str:
355
+ """Returns a fully-qualified folder string."""
356
+ return "folders/{folder}".format(
357
+ folder=folder,
358
+ )
359
+
360
+ @staticmethod
361
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
362
+ """Parse a folder path into its component segments."""
363
+ m = re.match(r"^folders/(?P<folder>.+?)$", path)
364
+ return m.groupdict() if m else {}
365
+
366
+ @staticmethod
367
+ def common_organization_path(
368
+ organization: str,
369
+ ) -> str:
370
+ """Returns a fully-qualified organization string."""
371
+ return "organizations/{organization}".format(
372
+ organization=organization,
373
+ )
374
+
375
+ @staticmethod
376
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
377
+ """Parse a organization path into its component segments."""
378
+ m = re.match(r"^organizations/(?P<organization>.+?)$", path)
379
+ return m.groupdict() if m else {}
380
+
381
+ @staticmethod
382
+ def common_project_path(
383
+ project: str,
384
+ ) -> str:
385
+ """Returns a fully-qualified project string."""
386
+ return "projects/{project}".format(
387
+ project=project,
388
+ )
389
+
390
+ @staticmethod
391
+ def parse_common_project_path(path: str) -> Dict[str, str]:
392
+ """Parse a project path into its component segments."""
393
+ m = re.match(r"^projects/(?P<project>.+?)$", path)
394
+ return m.groupdict() if m else {}
395
+
396
+ @staticmethod
397
+ def common_location_path(
398
+ project: str,
399
+ location: str,
400
+ ) -> str:
401
+ """Returns a fully-qualified location string."""
402
+ return "projects/{project}/locations/{location}".format(
403
+ project=project,
404
+ location=location,
405
+ )
406
+
407
+ @staticmethod
408
+ def parse_common_location_path(path: str) -> Dict[str, str]:
409
+ """Parse a location path into its component segments."""
410
+ m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
411
+ return m.groupdict() if m else {}
412
+
413
+ @classmethod
414
+ def get_mtls_endpoint_and_cert_source(
415
+ cls, client_options: Optional[client_options_lib.ClientOptions] = None
416
+ ):
417
+ """Deprecated. Return the API endpoint and client cert source for mutual TLS.
418
+
419
+ The client cert source is determined in the following order:
420
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
421
+ client cert source is None.
422
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
423
+ default client cert source exists, use the default one; otherwise the client cert
424
+ source is None.
425
+
426
+ The API endpoint is determined in the following order:
427
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
428
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
429
+ default mTLS endpoint; if the environment variable is "never", use the default API
430
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
431
+ use the default API endpoint.
432
+
433
+ More details can be found at https://google.aip.dev/auth/4114.
434
+
435
+ Args:
436
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
437
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
438
+ in this method.
439
+
440
+ Returns:
441
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
442
+ client cert source to use.
443
+
444
+ Raises:
445
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
446
+ """
447
+
448
+ warnings.warn(
449
+ "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
450
+ DeprecationWarning,
451
+ )
452
+ if client_options is None:
453
+ client_options = client_options_lib.ClientOptions()
454
+ use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
455
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
456
+ if use_client_cert not in ("true", "false"):
457
+ raise ValueError(
458
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
459
+ )
460
+ if use_mtls_endpoint not in ("auto", "never", "always"):
461
+ raise MutualTLSChannelError(
462
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
463
+ )
464
+
465
+ # Figure out the client cert source to use.
466
+ client_cert_source = None
467
+ if use_client_cert == "true":
468
+ if client_options.client_cert_source:
469
+ client_cert_source = client_options.client_cert_source
470
+ elif mtls.has_default_client_cert_source():
471
+ client_cert_source = mtls.default_client_cert_source()
472
+
473
+ # Figure out which api endpoint to use.
474
+ if client_options.api_endpoint is not None:
475
+ api_endpoint = client_options.api_endpoint
476
+ elif use_mtls_endpoint == "always" or (
477
+ use_mtls_endpoint == "auto" and client_cert_source
478
+ ):
479
+ api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
480
+ else:
481
+ api_endpoint = cls.DEFAULT_ENDPOINT
482
+
483
+ return api_endpoint, client_cert_source
484
+
485
+ @staticmethod
486
+ def _read_environment_variables():
487
+ """Returns the environment variables used by the client.
488
+
489
+ Returns:
490
+ Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
491
+ GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
492
+
493
+ Raises:
494
+ ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
495
+ any of ["true", "false"].
496
+ google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
497
+ is not any of ["auto", "never", "always"].
498
+ """
499
+ use_client_cert = os.getenv(
500
+ "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
501
+ ).lower()
502
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
503
+ universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
504
+ if use_client_cert not in ("true", "false"):
505
+ raise ValueError(
506
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
507
+ )
508
+ if use_mtls_endpoint not in ("auto", "never", "always"):
509
+ raise MutualTLSChannelError(
510
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
511
+ )
512
+ return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
513
+
514
+ @staticmethod
515
+ def _get_client_cert_source(provided_cert_source, use_cert_flag):
516
+ """Return the client cert source to be used by the client.
517
+
518
+ Args:
519
+ provided_cert_source (bytes): The client certificate source provided.
520
+ use_cert_flag (bool): A flag indicating whether to use the client certificate.
521
+
522
+ Returns:
523
+ bytes or None: The client cert source to be used by the client.
524
+ """
525
+ client_cert_source = None
526
+ if use_cert_flag:
527
+ if provided_cert_source:
528
+ client_cert_source = provided_cert_source
529
+ elif mtls.has_default_client_cert_source():
530
+ client_cert_source = mtls.default_client_cert_source()
531
+ return client_cert_source
532
+
533
+ @staticmethod
534
+ def _get_api_endpoint(
535
+ api_override, client_cert_source, universe_domain, use_mtls_endpoint
536
+ ):
537
+ """Return the API endpoint used by the client.
538
+
539
+ Args:
540
+ api_override (str): The API endpoint override. If specified, this is always
541
+ the return value of this function and the other arguments are not used.
542
+ client_cert_source (bytes): The client certificate source used by the client.
543
+ universe_domain (str): The universe domain used by the client.
544
+ use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
545
+ Possible values are "always", "auto", or "never".
546
+
547
+ Returns:
548
+ str: The API endpoint to be used by the client.
549
+ """
550
+ if api_override is not None:
551
+ api_endpoint = api_override
552
+ elif use_mtls_endpoint == "always" or (
553
+ use_mtls_endpoint == "auto" and client_cert_source
554
+ ):
555
+ _default_universe = CloudControlsPartnerCoreClient._DEFAULT_UNIVERSE
556
+ if universe_domain != _default_universe:
557
+ raise MutualTLSChannelError(
558
+ f"mTLS is not supported in any universe other than {_default_universe}."
559
+ )
560
+ api_endpoint = CloudControlsPartnerCoreClient.DEFAULT_MTLS_ENDPOINT
561
+ else:
562
+ api_endpoint = (
563
+ CloudControlsPartnerCoreClient._DEFAULT_ENDPOINT_TEMPLATE.format(
564
+ UNIVERSE_DOMAIN=universe_domain
565
+ )
566
+ )
567
+ return api_endpoint
568
+
569
+ @staticmethod
570
+ def _get_universe_domain(
571
+ client_universe_domain: Optional[str], universe_domain_env: Optional[str]
572
+ ) -> str:
573
+ """Return the universe domain used by the client.
574
+
575
+ Args:
576
+ client_universe_domain (Optional[str]): The universe domain configured via the client options.
577
+ universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
578
+
579
+ Returns:
580
+ str: The universe domain to be used by the client.
581
+
582
+ Raises:
583
+ ValueError: If the universe domain is an empty string.
584
+ """
585
+ universe_domain = CloudControlsPartnerCoreClient._DEFAULT_UNIVERSE
586
+ if client_universe_domain is not None:
587
+ universe_domain = client_universe_domain
588
+ elif universe_domain_env is not None:
589
+ universe_domain = universe_domain_env
590
+ if len(universe_domain.strip()) == 0:
591
+ raise ValueError("Universe Domain cannot be an empty string.")
592
+ return universe_domain
593
+
594
+ @staticmethod
595
+ def _compare_universes(
596
+ client_universe: str, credentials: ga_credentials.Credentials
597
+ ) -> bool:
598
+ """Returns True iff the universe domains used by the client and credentials match.
599
+
600
+ Args:
601
+ client_universe (str): The universe domain configured via the client options.
602
+ credentials (ga_credentials.Credentials): The credentials being used in the client.
603
+
604
+ Returns:
605
+ bool: True iff client_universe matches the universe in credentials.
606
+
607
+ Raises:
608
+ ValueError: when client_universe does not match the universe in credentials.
609
+ """
610
+
611
+ default_universe = CloudControlsPartnerCoreClient._DEFAULT_UNIVERSE
612
+ credentials_universe = getattr(credentials, "universe_domain", default_universe)
613
+
614
+ if client_universe != credentials_universe:
615
+ raise ValueError(
616
+ "The configured universe domain "
617
+ f"({client_universe}) does not match the universe domain "
618
+ f"found in the credentials ({credentials_universe}). "
619
+ "If you haven't configured the universe domain explicitly, "
620
+ f"`{default_universe}` is the default."
621
+ )
622
+ return True
623
+
624
+ def _validate_universe_domain(self):
625
+ """Validates client's and credentials' universe domains are consistent.
626
+
627
+ Returns:
628
+ bool: True iff the configured universe domain is valid.
629
+
630
+ Raises:
631
+ ValueError: If the configured universe domain is not valid.
632
+ """
633
+ self._is_universe_domain_valid = (
634
+ self._is_universe_domain_valid
635
+ or CloudControlsPartnerCoreClient._compare_universes(
636
+ self.universe_domain, self.transport._credentials
637
+ )
638
+ )
639
+ return self._is_universe_domain_valid
640
+
641
+ @property
642
+ def api_endpoint(self):
643
+ """Return the API endpoint used by the client instance.
644
+
645
+ Returns:
646
+ str: The API endpoint used by the client instance.
647
+ """
648
+ return self._api_endpoint
649
+
650
+ @property
651
+ def universe_domain(self) -> str:
652
+ """Return the universe domain used by the client instance.
653
+
654
+ Returns:
655
+ str: The universe domain used by the client instance.
656
+ """
657
+ return self._universe_domain
658
+
659
+ def __init__(
660
+ self,
661
+ *,
662
+ credentials: Optional[ga_credentials.Credentials] = None,
663
+ transport: Optional[Union[str, CloudControlsPartnerCoreTransport]] = None,
664
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
665
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
666
+ ) -> None:
667
+ """Instantiates the cloud controls partner core client.
668
+
669
+ Args:
670
+ credentials (Optional[google.auth.credentials.Credentials]): The
671
+ authorization credentials to attach to requests. These
672
+ credentials identify the application to the service; if none
673
+ are specified, the client will attempt to ascertain the
674
+ credentials from the environment.
675
+ transport (Union[str, CloudControlsPartnerCoreTransport]): The
676
+ transport to use. If set to None, a transport is chosen
677
+ automatically.
678
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
679
+ Custom options for the client.
680
+
681
+ 1. The ``api_endpoint`` property can be used to override the
682
+ default endpoint provided by the client when ``transport`` is
683
+ not explicitly provided. Only if this property is not set and
684
+ ``transport`` was not explicitly provided, the endpoint is
685
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
686
+ variable, which have one of the following values:
687
+ "always" (always use the default mTLS endpoint), "never" (always
688
+ use the default regular endpoint) and "auto" (auto-switch to the
689
+ default mTLS endpoint if client certificate is present; this is
690
+ the default value).
691
+
692
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
693
+ is "true", then the ``client_cert_source`` property can be used
694
+ to provide a client certificate for mTLS transport. If
695
+ not provided, the default SSL client certificate will be used if
696
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
697
+ set, no client certificate will be used.
698
+
699
+ 3. The ``universe_domain`` property can be used to override the
700
+ default "googleapis.com" universe. Note that the ``api_endpoint``
701
+ property still takes precedence; and ``universe_domain`` is
702
+ currently not supported for mTLS.
703
+
704
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
705
+ The client info used to send a user-agent string along with
706
+ API requests. If ``None``, then default info will be used.
707
+ Generally, you only need to set this if you're developing
708
+ your own client library.
709
+
710
+ Raises:
711
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
712
+ creation failed for any reason.
713
+ """
714
+ self._client_options = client_options
715
+ if isinstance(self._client_options, dict):
716
+ self._client_options = client_options_lib.from_dict(self._client_options)
717
+ if self._client_options is None:
718
+ self._client_options = client_options_lib.ClientOptions()
719
+ self._client_options = cast(
720
+ client_options_lib.ClientOptions, self._client_options
721
+ )
722
+
723
+ universe_domain_opt = getattr(self._client_options, "universe_domain", None)
724
+
725
+ (
726
+ self._use_client_cert,
727
+ self._use_mtls_endpoint,
728
+ self._universe_domain_env,
729
+ ) = CloudControlsPartnerCoreClient._read_environment_variables()
730
+ self._client_cert_source = (
731
+ CloudControlsPartnerCoreClient._get_client_cert_source(
732
+ self._client_options.client_cert_source, self._use_client_cert
733
+ )
734
+ )
735
+ self._universe_domain = CloudControlsPartnerCoreClient._get_universe_domain(
736
+ universe_domain_opt, self._universe_domain_env
737
+ )
738
+ self._api_endpoint = None # updated below, depending on `transport`
739
+
740
+ # Initialize the universe domain validation.
741
+ self._is_universe_domain_valid = False
742
+
743
+ api_key_value = getattr(self._client_options, "api_key", None)
744
+ if api_key_value and credentials:
745
+ raise ValueError(
746
+ "client_options.api_key and credentials are mutually exclusive"
747
+ )
748
+
749
+ # Save or instantiate the transport.
750
+ # Ordinarily, we provide the transport, but allowing a custom transport
751
+ # instance provides an extensibility point for unusual situations.
752
+ transport_provided = isinstance(transport, CloudControlsPartnerCoreTransport)
753
+ if transport_provided:
754
+ # transport is a CloudControlsPartnerCoreTransport instance.
755
+ if credentials or self._client_options.credentials_file or api_key_value:
756
+ raise ValueError(
757
+ "When providing a transport instance, "
758
+ "provide its credentials directly."
759
+ )
760
+ if self._client_options.scopes:
761
+ raise ValueError(
762
+ "When providing a transport instance, provide its scopes "
763
+ "directly."
764
+ )
765
+ self._transport = cast(CloudControlsPartnerCoreTransport, transport)
766
+ self._api_endpoint = self._transport.host
767
+
768
+ self._api_endpoint = (
769
+ self._api_endpoint
770
+ or CloudControlsPartnerCoreClient._get_api_endpoint(
771
+ self._client_options.api_endpoint,
772
+ self._client_cert_source,
773
+ self._universe_domain,
774
+ self._use_mtls_endpoint,
775
+ )
776
+ )
777
+
778
+ if not transport_provided:
779
+ import google.auth._default # type: ignore
780
+
781
+ if api_key_value and hasattr(
782
+ google.auth._default, "get_api_key_credentials"
783
+ ):
784
+ credentials = google.auth._default.get_api_key_credentials(
785
+ api_key_value
786
+ )
787
+
788
+ Transport = type(self).get_transport_class(cast(str, transport))
789
+ self._transport = Transport(
790
+ credentials=credentials,
791
+ credentials_file=self._client_options.credentials_file,
792
+ host=self._api_endpoint,
793
+ scopes=self._client_options.scopes,
794
+ client_cert_source_for_mtls=self._client_cert_source,
795
+ quota_project_id=self._client_options.quota_project_id,
796
+ client_info=client_info,
797
+ always_use_jwt_access=True,
798
+ api_audience=self._client_options.api_audience,
799
+ )
800
+
801
+ def get_workload(
802
+ self,
803
+ request: Optional[Union[customer_workloads.GetWorkloadRequest, dict]] = None,
804
+ *,
805
+ name: Optional[str] = None,
806
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
807
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
808
+ metadata: Sequence[Tuple[str, str]] = (),
809
+ ) -> customer_workloads.Workload:
810
+ r"""Gets details of a single workload
811
+
812
+ .. code-block:: python
813
+
814
+ # This snippet has been automatically generated and should be regarded as a
815
+ # code template only.
816
+ # It will require modifications to work:
817
+ # - It may require correct/in-range values for request initialization.
818
+ # - It may require specifying regional endpoints when creating the service
819
+ # client as shown in:
820
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
821
+ from google.cloud import cloudcontrolspartner_v1beta
822
+
823
+ def sample_get_workload():
824
+ # Create a client
825
+ client = cloudcontrolspartner_v1beta.CloudControlsPartnerCoreClient()
826
+
827
+ # Initialize request argument(s)
828
+ request = cloudcontrolspartner_v1beta.GetWorkloadRequest(
829
+ name="name_value",
830
+ )
831
+
832
+ # Make the request
833
+ response = client.get_workload(request=request)
834
+
835
+ # Handle the response
836
+ print(response)
837
+
838
+ Args:
839
+ request (Union[google.cloud.cloudcontrolspartner_v1beta.types.GetWorkloadRequest, dict]):
840
+ The request object. Message for getting a customer
841
+ workload.
842
+ name (str):
843
+ Required. Format:
844
+
845
+ organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}
846
+
847
+ This corresponds to the ``name`` field
848
+ on the ``request`` instance; if ``request`` is provided, this
849
+ should not be set.
850
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
851
+ should be retried.
852
+ timeout (float): The timeout for this request.
853
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
854
+ sent along with the request as metadata.
855
+
856
+ Returns:
857
+ google.cloud.cloudcontrolspartner_v1beta.types.Workload:
858
+ Contains metadata around the [Workload
859
+ resource](\ https://cloud.google.com/assured-workloads/docs/reference/rest/Shared.Types/Workload)
860
+ in the Assured Workloads API.
861
+
862
+ """
863
+ # Create or coerce a protobuf request object.
864
+ # Quick check: If we got a request object, we should *not* have
865
+ # gotten any keyword arguments that map to the request.
866
+ has_flattened_params = any([name])
867
+ if request is not None and has_flattened_params:
868
+ raise ValueError(
869
+ "If the `request` argument is set, then none of "
870
+ "the individual field arguments should be set."
871
+ )
872
+
873
+ # Minor optimization to avoid making a copy if the user passes
874
+ # in a customer_workloads.GetWorkloadRequest.
875
+ # There's no risk of modifying the input as we've already verified
876
+ # there are no flattened fields.
877
+ if not isinstance(request, customer_workloads.GetWorkloadRequest):
878
+ request = customer_workloads.GetWorkloadRequest(request)
879
+ # If we have keyword arguments corresponding to fields on the
880
+ # request, apply these.
881
+ if name is not None:
882
+ request.name = name
883
+
884
+ # Wrap the RPC method; this adds retry and timeout information,
885
+ # and friendly error handling.
886
+ rpc = self._transport._wrapped_methods[self._transport.get_workload]
887
+
888
+ # Certain fields should be provided within the metadata header;
889
+ # add these here.
890
+ metadata = tuple(metadata) + (
891
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
892
+ )
893
+
894
+ # Validate the universe domain.
895
+ self._validate_universe_domain()
896
+
897
+ # Send the request.
898
+ response = rpc(
899
+ request,
900
+ retry=retry,
901
+ timeout=timeout,
902
+ metadata=metadata,
903
+ )
904
+
905
+ # Done; return the response.
906
+ return response
907
+
908
+ def list_workloads(
909
+ self,
910
+ request: Optional[Union[customer_workloads.ListWorkloadsRequest, dict]] = None,
911
+ *,
912
+ parent: Optional[str] = None,
913
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
914
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
915
+ metadata: Sequence[Tuple[str, str]] = (),
916
+ ) -> pagers.ListWorkloadsPager:
917
+ r"""Lists customer workloads for a given customer org id
918
+
919
+ .. code-block:: python
920
+
921
+ # This snippet has been automatically generated and should be regarded as a
922
+ # code template only.
923
+ # It will require modifications to work:
924
+ # - It may require correct/in-range values for request initialization.
925
+ # - It may require specifying regional endpoints when creating the service
926
+ # client as shown in:
927
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
928
+ from google.cloud import cloudcontrolspartner_v1beta
929
+
930
+ def sample_list_workloads():
931
+ # Create a client
932
+ client = cloudcontrolspartner_v1beta.CloudControlsPartnerCoreClient()
933
+
934
+ # Initialize request argument(s)
935
+ request = cloudcontrolspartner_v1beta.ListWorkloadsRequest(
936
+ parent="parent_value",
937
+ )
938
+
939
+ # Make the request
940
+ page_result = client.list_workloads(request=request)
941
+
942
+ # Handle the response
943
+ for response in page_result:
944
+ print(response)
945
+
946
+ Args:
947
+ request (Union[google.cloud.cloudcontrolspartner_v1beta.types.ListWorkloadsRequest, dict]):
948
+ The request object. Request to list customer workloads.
949
+ parent (str):
950
+ Required. Parent resource
951
+ Format:
952
+
953
+ organizations/{organization}/locations/{location}/customers/{customer}
954
+
955
+ This corresponds to the ``parent`` field
956
+ on the ``request`` instance; if ``request`` is provided, this
957
+ should not be set.
958
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
959
+ should be retried.
960
+ timeout (float): The timeout for this request.
961
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
962
+ sent along with the request as metadata.
963
+
964
+ Returns:
965
+ google.cloud.cloudcontrolspartner_v1beta.services.cloud_controls_partner_core.pagers.ListWorkloadsPager:
966
+ Response message for list customer
967
+ workloads requests.
968
+ Iterating over this object will yield
969
+ results and resolve additional pages
970
+ automatically.
971
+
972
+ """
973
+ # Create or coerce a protobuf request object.
974
+ # Quick check: If we got a request object, we should *not* have
975
+ # gotten any keyword arguments that map to the request.
976
+ has_flattened_params = any([parent])
977
+ if request is not None and has_flattened_params:
978
+ raise ValueError(
979
+ "If the `request` argument is set, then none of "
980
+ "the individual field arguments should be set."
981
+ )
982
+
983
+ # Minor optimization to avoid making a copy if the user passes
984
+ # in a customer_workloads.ListWorkloadsRequest.
985
+ # There's no risk of modifying the input as we've already verified
986
+ # there are no flattened fields.
987
+ if not isinstance(request, customer_workloads.ListWorkloadsRequest):
988
+ request = customer_workloads.ListWorkloadsRequest(request)
989
+ # If we have keyword arguments corresponding to fields on the
990
+ # request, apply these.
991
+ if parent is not None:
992
+ request.parent = parent
993
+
994
+ # Wrap the RPC method; this adds retry and timeout information,
995
+ # and friendly error handling.
996
+ rpc = self._transport._wrapped_methods[self._transport.list_workloads]
997
+
998
+ # Certain fields should be provided within the metadata header;
999
+ # add these here.
1000
+ metadata = tuple(metadata) + (
1001
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1002
+ )
1003
+
1004
+ # Validate the universe domain.
1005
+ self._validate_universe_domain()
1006
+
1007
+ # Send the request.
1008
+ response = rpc(
1009
+ request,
1010
+ retry=retry,
1011
+ timeout=timeout,
1012
+ metadata=metadata,
1013
+ )
1014
+
1015
+ # This method is paged; wrap the response in a pager, which provides
1016
+ # an `__iter__` convenience method.
1017
+ response = pagers.ListWorkloadsPager(
1018
+ method=rpc,
1019
+ request=request,
1020
+ response=response,
1021
+ metadata=metadata,
1022
+ )
1023
+
1024
+ # Done; return the response.
1025
+ return response
1026
+
1027
+ def get_customer(
1028
+ self,
1029
+ request: Optional[Union[customers.GetCustomerRequest, dict]] = None,
1030
+ *,
1031
+ name: Optional[str] = None,
1032
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1033
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1034
+ metadata: Sequence[Tuple[str, str]] = (),
1035
+ ) -> customers.Customer:
1036
+ r"""Gets details of a single customer
1037
+
1038
+ .. code-block:: python
1039
+
1040
+ # This snippet has been automatically generated and should be regarded as a
1041
+ # code template only.
1042
+ # It will require modifications to work:
1043
+ # - It may require correct/in-range values for request initialization.
1044
+ # - It may require specifying regional endpoints when creating the service
1045
+ # client as shown in:
1046
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1047
+ from google.cloud import cloudcontrolspartner_v1beta
1048
+
1049
+ def sample_get_customer():
1050
+ # Create a client
1051
+ client = cloudcontrolspartner_v1beta.CloudControlsPartnerCoreClient()
1052
+
1053
+ # Initialize request argument(s)
1054
+ request = cloudcontrolspartner_v1beta.GetCustomerRequest(
1055
+ name="name_value",
1056
+ )
1057
+
1058
+ # Make the request
1059
+ response = client.get_customer(request=request)
1060
+
1061
+ # Handle the response
1062
+ print(response)
1063
+
1064
+ Args:
1065
+ request (Union[google.cloud.cloudcontrolspartner_v1beta.types.GetCustomerRequest, dict]):
1066
+ The request object. Message for getting a customer
1067
+ name (str):
1068
+ Required. Format:
1069
+
1070
+ organizations/{organization}/locations/{location}/customers/{customer}
1071
+
1072
+ This corresponds to the ``name`` field
1073
+ on the ``request`` instance; if ``request`` is provided, this
1074
+ should not be set.
1075
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1076
+ should be retried.
1077
+ timeout (float): The timeout for this request.
1078
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
1079
+ sent along with the request as metadata.
1080
+
1081
+ Returns:
1082
+ google.cloud.cloudcontrolspartner_v1beta.types.Customer:
1083
+ Contains metadata around a Cloud
1084
+ Controls Partner Customer
1085
+
1086
+ """
1087
+ # Create or coerce a protobuf request object.
1088
+ # Quick check: If we got a request object, we should *not* have
1089
+ # gotten any keyword arguments that map to the request.
1090
+ has_flattened_params = any([name])
1091
+ if request is not None and has_flattened_params:
1092
+ raise ValueError(
1093
+ "If the `request` argument is set, then none of "
1094
+ "the individual field arguments should be set."
1095
+ )
1096
+
1097
+ # Minor optimization to avoid making a copy if the user passes
1098
+ # in a customers.GetCustomerRequest.
1099
+ # There's no risk of modifying the input as we've already verified
1100
+ # there are no flattened fields.
1101
+ if not isinstance(request, customers.GetCustomerRequest):
1102
+ request = customers.GetCustomerRequest(request)
1103
+ # If we have keyword arguments corresponding to fields on the
1104
+ # request, apply these.
1105
+ if name is not None:
1106
+ request.name = name
1107
+
1108
+ # Wrap the RPC method; this adds retry and timeout information,
1109
+ # and friendly error handling.
1110
+ rpc = self._transport._wrapped_methods[self._transport.get_customer]
1111
+
1112
+ # Certain fields should be provided within the metadata header;
1113
+ # add these here.
1114
+ metadata = tuple(metadata) + (
1115
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1116
+ )
1117
+
1118
+ # Validate the universe domain.
1119
+ self._validate_universe_domain()
1120
+
1121
+ # Send the request.
1122
+ response = rpc(
1123
+ request,
1124
+ retry=retry,
1125
+ timeout=timeout,
1126
+ metadata=metadata,
1127
+ )
1128
+
1129
+ # Done; return the response.
1130
+ return response
1131
+
1132
+ def list_customers(
1133
+ self,
1134
+ request: Optional[Union[customers.ListCustomersRequest, dict]] = None,
1135
+ *,
1136
+ parent: Optional[str] = None,
1137
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1138
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1139
+ metadata: Sequence[Tuple[str, str]] = (),
1140
+ ) -> pagers.ListCustomersPager:
1141
+ r"""Lists customers of a partner identified by its Google
1142
+ Cloud organization ID
1143
+
1144
+ .. code-block:: python
1145
+
1146
+ # This snippet has been automatically generated and should be regarded as a
1147
+ # code template only.
1148
+ # It will require modifications to work:
1149
+ # - It may require correct/in-range values for request initialization.
1150
+ # - It may require specifying regional endpoints when creating the service
1151
+ # client as shown in:
1152
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1153
+ from google.cloud import cloudcontrolspartner_v1beta
1154
+
1155
+ def sample_list_customers():
1156
+ # Create a client
1157
+ client = cloudcontrolspartner_v1beta.CloudControlsPartnerCoreClient()
1158
+
1159
+ # Initialize request argument(s)
1160
+ request = cloudcontrolspartner_v1beta.ListCustomersRequest(
1161
+ parent="parent_value",
1162
+ )
1163
+
1164
+ # Make the request
1165
+ page_result = client.list_customers(request=request)
1166
+
1167
+ # Handle the response
1168
+ for response in page_result:
1169
+ print(response)
1170
+
1171
+ Args:
1172
+ request (Union[google.cloud.cloudcontrolspartner_v1beta.types.ListCustomersRequest, dict]):
1173
+ The request object. Request to list customers
1174
+ parent (str):
1175
+ Required. Parent resource
1176
+ Format:
1177
+ organizations/{organization}/locations/{location}
1178
+
1179
+ This corresponds to the ``parent`` field
1180
+ on the ``request`` instance; if ``request`` is provided, this
1181
+ should not be set.
1182
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1183
+ should be retried.
1184
+ timeout (float): The timeout for this request.
1185
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
1186
+ sent along with the request as metadata.
1187
+
1188
+ Returns:
1189
+ google.cloud.cloudcontrolspartner_v1beta.services.cloud_controls_partner_core.pagers.ListCustomersPager:
1190
+ Response message for list customer
1191
+ Customers requests
1192
+ Iterating over this object will yield
1193
+ results and resolve additional pages
1194
+ automatically.
1195
+
1196
+ """
1197
+ # Create or coerce a protobuf request object.
1198
+ # Quick check: If we got a request object, we should *not* have
1199
+ # gotten any keyword arguments that map to the request.
1200
+ has_flattened_params = any([parent])
1201
+ if request is not None and has_flattened_params:
1202
+ raise ValueError(
1203
+ "If the `request` argument is set, then none of "
1204
+ "the individual field arguments should be set."
1205
+ )
1206
+
1207
+ # Minor optimization to avoid making a copy if the user passes
1208
+ # in a customers.ListCustomersRequest.
1209
+ # There's no risk of modifying the input as we've already verified
1210
+ # there are no flattened fields.
1211
+ if not isinstance(request, customers.ListCustomersRequest):
1212
+ request = customers.ListCustomersRequest(request)
1213
+ # If we have keyword arguments corresponding to fields on the
1214
+ # request, apply these.
1215
+ if parent is not None:
1216
+ request.parent = parent
1217
+
1218
+ # Wrap the RPC method; this adds retry and timeout information,
1219
+ # and friendly error handling.
1220
+ rpc = self._transport._wrapped_methods[self._transport.list_customers]
1221
+
1222
+ # Certain fields should be provided within the metadata header;
1223
+ # add these here.
1224
+ metadata = tuple(metadata) + (
1225
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1226
+ )
1227
+
1228
+ # Validate the universe domain.
1229
+ self._validate_universe_domain()
1230
+
1231
+ # Send the request.
1232
+ response = rpc(
1233
+ request,
1234
+ retry=retry,
1235
+ timeout=timeout,
1236
+ metadata=metadata,
1237
+ )
1238
+
1239
+ # This method is paged; wrap the response in a pager, which provides
1240
+ # an `__iter__` convenience method.
1241
+ response = pagers.ListCustomersPager(
1242
+ method=rpc,
1243
+ request=request,
1244
+ response=response,
1245
+ metadata=metadata,
1246
+ )
1247
+
1248
+ # Done; return the response.
1249
+ return response
1250
+
1251
+ def get_ekm_connections(
1252
+ self,
1253
+ request: Optional[Union[ekm_connections.GetEkmConnectionsRequest, dict]] = None,
1254
+ *,
1255
+ name: Optional[str] = None,
1256
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1257
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1258
+ metadata: Sequence[Tuple[str, str]] = (),
1259
+ ) -> ekm_connections.EkmConnections:
1260
+ r"""Gets the EKM connections associated with a workload
1261
+
1262
+ .. code-block:: python
1263
+
1264
+ # This snippet has been automatically generated and should be regarded as a
1265
+ # code template only.
1266
+ # It will require modifications to work:
1267
+ # - It may require correct/in-range values for request initialization.
1268
+ # - It may require specifying regional endpoints when creating the service
1269
+ # client as shown in:
1270
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1271
+ from google.cloud import cloudcontrolspartner_v1beta
1272
+
1273
+ def sample_get_ekm_connections():
1274
+ # Create a client
1275
+ client = cloudcontrolspartner_v1beta.CloudControlsPartnerCoreClient()
1276
+
1277
+ # Initialize request argument(s)
1278
+ request = cloudcontrolspartner_v1beta.GetEkmConnectionsRequest(
1279
+ name="name_value",
1280
+ )
1281
+
1282
+ # Make the request
1283
+ response = client.get_ekm_connections(request=request)
1284
+
1285
+ # Handle the response
1286
+ print(response)
1287
+
1288
+ Args:
1289
+ request (Union[google.cloud.cloudcontrolspartner_v1beta.types.GetEkmConnectionsRequest, dict]):
1290
+ The request object. Request for getting the EKM
1291
+ connections associated with a workload
1292
+ name (str):
1293
+ Required. Format:
1294
+
1295
+ organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}/ekmConnections
1296
+
1297
+ This corresponds to the ``name`` field
1298
+ on the ``request`` instance; if ``request`` is provided, this
1299
+ should not be set.
1300
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1301
+ should be retried.
1302
+ timeout (float): The timeout for this request.
1303
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
1304
+ sent along with the request as metadata.
1305
+
1306
+ Returns:
1307
+ google.cloud.cloudcontrolspartner_v1beta.types.EkmConnections:
1308
+ The EKM connections associated with a
1309
+ workload
1310
+
1311
+ """
1312
+ # Create or coerce a protobuf request object.
1313
+ # Quick check: If we got a request object, we should *not* have
1314
+ # gotten any keyword arguments that map to the request.
1315
+ has_flattened_params = any([name])
1316
+ if request is not None and has_flattened_params:
1317
+ raise ValueError(
1318
+ "If the `request` argument is set, then none of "
1319
+ "the individual field arguments should be set."
1320
+ )
1321
+
1322
+ # Minor optimization to avoid making a copy if the user passes
1323
+ # in a ekm_connections.GetEkmConnectionsRequest.
1324
+ # There's no risk of modifying the input as we've already verified
1325
+ # there are no flattened fields.
1326
+ if not isinstance(request, ekm_connections.GetEkmConnectionsRequest):
1327
+ request = ekm_connections.GetEkmConnectionsRequest(request)
1328
+ # If we have keyword arguments corresponding to fields on the
1329
+ # request, apply these.
1330
+ if name is not None:
1331
+ request.name = name
1332
+
1333
+ # Wrap the RPC method; this adds retry and timeout information,
1334
+ # and friendly error handling.
1335
+ rpc = self._transport._wrapped_methods[self._transport.get_ekm_connections]
1336
+
1337
+ # Certain fields should be provided within the metadata header;
1338
+ # add these here.
1339
+ metadata = tuple(metadata) + (
1340
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1341
+ )
1342
+
1343
+ # Validate the universe domain.
1344
+ self._validate_universe_domain()
1345
+
1346
+ # Send the request.
1347
+ response = rpc(
1348
+ request,
1349
+ retry=retry,
1350
+ timeout=timeout,
1351
+ metadata=metadata,
1352
+ )
1353
+
1354
+ # Done; return the response.
1355
+ return response
1356
+
1357
+ def get_partner_permissions(
1358
+ self,
1359
+ request: Optional[
1360
+ Union[partner_permissions.GetPartnerPermissionsRequest, dict]
1361
+ ] = None,
1362
+ *,
1363
+ name: Optional[str] = None,
1364
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1365
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1366
+ metadata: Sequence[Tuple[str, str]] = (),
1367
+ ) -> partner_permissions.PartnerPermissions:
1368
+ r"""Gets the partner permissions granted for a workload
1369
+
1370
+ .. code-block:: python
1371
+
1372
+ # This snippet has been automatically generated and should be regarded as a
1373
+ # code template only.
1374
+ # It will require modifications to work:
1375
+ # - It may require correct/in-range values for request initialization.
1376
+ # - It may require specifying regional endpoints when creating the service
1377
+ # client as shown in:
1378
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1379
+ from google.cloud import cloudcontrolspartner_v1beta
1380
+
1381
+ def sample_get_partner_permissions():
1382
+ # Create a client
1383
+ client = cloudcontrolspartner_v1beta.CloudControlsPartnerCoreClient()
1384
+
1385
+ # Initialize request argument(s)
1386
+ request = cloudcontrolspartner_v1beta.GetPartnerPermissionsRequest(
1387
+ name="name_value",
1388
+ )
1389
+
1390
+ # Make the request
1391
+ response = client.get_partner_permissions(request=request)
1392
+
1393
+ # Handle the response
1394
+ print(response)
1395
+
1396
+ Args:
1397
+ request (Union[google.cloud.cloudcontrolspartner_v1beta.types.GetPartnerPermissionsRequest, dict]):
1398
+ The request object. Request for getting the partner
1399
+ permissions granted for a workload
1400
+ name (str):
1401
+ Required. Name of the resource to get
1402
+ in the format:
1403
+ organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}/partnerPermissions
1404
+
1405
+ This corresponds to the ``name`` field
1406
+ on the ``request`` instance; if ``request`` is provided, this
1407
+ should not be set.
1408
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1409
+ should be retried.
1410
+ timeout (float): The timeout for this request.
1411
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
1412
+ sent along with the request as metadata.
1413
+
1414
+ Returns:
1415
+ google.cloud.cloudcontrolspartner_v1beta.types.PartnerPermissions:
1416
+ The permissions granted to the
1417
+ partner for a workload
1418
+
1419
+ """
1420
+ # Create or coerce a protobuf request object.
1421
+ # Quick check: If we got a request object, we should *not* have
1422
+ # gotten any keyword arguments that map to the request.
1423
+ has_flattened_params = any([name])
1424
+ if request is not None and has_flattened_params:
1425
+ raise ValueError(
1426
+ "If the `request` argument is set, then none of "
1427
+ "the individual field arguments should be set."
1428
+ )
1429
+
1430
+ # Minor optimization to avoid making a copy if the user passes
1431
+ # in a partner_permissions.GetPartnerPermissionsRequest.
1432
+ # There's no risk of modifying the input as we've already verified
1433
+ # there are no flattened fields.
1434
+ if not isinstance(request, partner_permissions.GetPartnerPermissionsRequest):
1435
+ request = partner_permissions.GetPartnerPermissionsRequest(request)
1436
+ # If we have keyword arguments corresponding to fields on the
1437
+ # request, apply these.
1438
+ if name is not None:
1439
+ request.name = name
1440
+
1441
+ # Wrap the RPC method; this adds retry and timeout information,
1442
+ # and friendly error handling.
1443
+ rpc = self._transport._wrapped_methods[self._transport.get_partner_permissions]
1444
+
1445
+ # Certain fields should be provided within the metadata header;
1446
+ # add these here.
1447
+ metadata = tuple(metadata) + (
1448
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1449
+ )
1450
+
1451
+ # Validate the universe domain.
1452
+ self._validate_universe_domain()
1453
+
1454
+ # Send the request.
1455
+ response = rpc(
1456
+ request,
1457
+ retry=retry,
1458
+ timeout=timeout,
1459
+ metadata=metadata,
1460
+ )
1461
+
1462
+ # Done; return the response.
1463
+ return response
1464
+
1465
+ def list_access_approval_requests(
1466
+ self,
1467
+ request: Optional[
1468
+ Union[access_approval_requests.ListAccessApprovalRequestsRequest, dict]
1469
+ ] = None,
1470
+ *,
1471
+ parent: Optional[str] = None,
1472
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1473
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1474
+ metadata: Sequence[Tuple[str, str]] = (),
1475
+ ) -> pagers.ListAccessApprovalRequestsPager:
1476
+ r"""Lists access requests associated with a workload
1477
+
1478
+ .. code-block:: python
1479
+
1480
+ # This snippet has been automatically generated and should be regarded as a
1481
+ # code template only.
1482
+ # It will require modifications to work:
1483
+ # - It may require correct/in-range values for request initialization.
1484
+ # - It may require specifying regional endpoints when creating the service
1485
+ # client as shown in:
1486
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1487
+ from google.cloud import cloudcontrolspartner_v1beta
1488
+
1489
+ def sample_list_access_approval_requests():
1490
+ # Create a client
1491
+ client = cloudcontrolspartner_v1beta.CloudControlsPartnerCoreClient()
1492
+
1493
+ # Initialize request argument(s)
1494
+ request = cloudcontrolspartner_v1beta.ListAccessApprovalRequestsRequest(
1495
+ parent="parent_value",
1496
+ )
1497
+
1498
+ # Make the request
1499
+ page_result = client.list_access_approval_requests(request=request)
1500
+
1501
+ # Handle the response
1502
+ for response in page_result:
1503
+ print(response)
1504
+
1505
+ Args:
1506
+ request (Union[google.cloud.cloudcontrolspartner_v1beta.types.ListAccessApprovalRequestsRequest, dict]):
1507
+ The request object. Request for getting the access
1508
+ requests associated with a workload.
1509
+ parent (str):
1510
+ Required. Parent resource
1511
+ Format:
1512
+
1513
+ organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}
1514
+
1515
+ This corresponds to the ``parent`` field
1516
+ on the ``request`` instance; if ``request`` is provided, this
1517
+ should not be set.
1518
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1519
+ should be retried.
1520
+ timeout (float): The timeout for this request.
1521
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
1522
+ sent along with the request as metadata.
1523
+
1524
+ Returns:
1525
+ google.cloud.cloudcontrolspartner_v1beta.services.cloud_controls_partner_core.pagers.ListAccessApprovalRequestsPager:
1526
+ Response message for list access
1527
+ requests.
1528
+ Iterating over this object will yield
1529
+ results and resolve additional pages
1530
+ automatically.
1531
+
1532
+ """
1533
+ # Create or coerce a protobuf request object.
1534
+ # Quick check: If we got a request object, we should *not* have
1535
+ # gotten any keyword arguments that map to the request.
1536
+ has_flattened_params = any([parent])
1537
+ if request is not None and has_flattened_params:
1538
+ raise ValueError(
1539
+ "If the `request` argument is set, then none of "
1540
+ "the individual field arguments should be set."
1541
+ )
1542
+
1543
+ # Minor optimization to avoid making a copy if the user passes
1544
+ # in a access_approval_requests.ListAccessApprovalRequestsRequest.
1545
+ # There's no risk of modifying the input as we've already verified
1546
+ # there are no flattened fields.
1547
+ if not isinstance(
1548
+ request, access_approval_requests.ListAccessApprovalRequestsRequest
1549
+ ):
1550
+ request = access_approval_requests.ListAccessApprovalRequestsRequest(
1551
+ request
1552
+ )
1553
+ # If we have keyword arguments corresponding to fields on the
1554
+ # request, apply these.
1555
+ if parent is not None:
1556
+ request.parent = parent
1557
+
1558
+ # Wrap the RPC method; this adds retry and timeout information,
1559
+ # and friendly error handling.
1560
+ rpc = self._transport._wrapped_methods[
1561
+ self._transport.list_access_approval_requests
1562
+ ]
1563
+
1564
+ # Certain fields should be provided within the metadata header;
1565
+ # add these here.
1566
+ metadata = tuple(metadata) + (
1567
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1568
+ )
1569
+
1570
+ # Validate the universe domain.
1571
+ self._validate_universe_domain()
1572
+
1573
+ # Send the request.
1574
+ response = rpc(
1575
+ request,
1576
+ retry=retry,
1577
+ timeout=timeout,
1578
+ metadata=metadata,
1579
+ )
1580
+
1581
+ # This method is paged; wrap the response in a pager, which provides
1582
+ # an `__iter__` convenience method.
1583
+ response = pagers.ListAccessApprovalRequestsPager(
1584
+ method=rpc,
1585
+ request=request,
1586
+ response=response,
1587
+ metadata=metadata,
1588
+ )
1589
+
1590
+ # Done; return the response.
1591
+ return response
1592
+
1593
+ def get_partner(
1594
+ self,
1595
+ request: Optional[Union[partners.GetPartnerRequest, dict]] = None,
1596
+ *,
1597
+ name: Optional[str] = None,
1598
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1599
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1600
+ metadata: Sequence[Tuple[str, str]] = (),
1601
+ ) -> partners.Partner:
1602
+ r"""Get details of a Partner.
1603
+
1604
+ .. code-block:: python
1605
+
1606
+ # This snippet has been automatically generated and should be regarded as a
1607
+ # code template only.
1608
+ # It will require modifications to work:
1609
+ # - It may require correct/in-range values for request initialization.
1610
+ # - It may require specifying regional endpoints when creating the service
1611
+ # client as shown in:
1612
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1613
+ from google.cloud import cloudcontrolspartner_v1beta
1614
+
1615
+ def sample_get_partner():
1616
+ # Create a client
1617
+ client = cloudcontrolspartner_v1beta.CloudControlsPartnerCoreClient()
1618
+
1619
+ # Initialize request argument(s)
1620
+ request = cloudcontrolspartner_v1beta.GetPartnerRequest(
1621
+ name="name_value",
1622
+ )
1623
+
1624
+ # Make the request
1625
+ response = client.get_partner(request=request)
1626
+
1627
+ # Handle the response
1628
+ print(response)
1629
+
1630
+ Args:
1631
+ request (Union[google.cloud.cloudcontrolspartner_v1beta.types.GetPartnerRequest, dict]):
1632
+ The request object. Message for getting a Partner
1633
+ name (str):
1634
+ Required. Format:
1635
+ organizations/{organization}/locations/{location}/partner
1636
+
1637
+ This corresponds to the ``name`` field
1638
+ on the ``request`` instance; if ``request`` is provided, this
1639
+ should not be set.
1640
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1641
+ should be retried.
1642
+ timeout (float): The timeout for this request.
1643
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
1644
+ sent along with the request as metadata.
1645
+
1646
+ Returns:
1647
+ google.cloud.cloudcontrolspartner_v1beta.types.Partner:
1648
+ Message describing Partner resource
1649
+ """
1650
+ # Create or coerce a protobuf request object.
1651
+ # Quick check: If we got a request object, we should *not* have
1652
+ # gotten any keyword arguments that map to the request.
1653
+ has_flattened_params = any([name])
1654
+ if request is not None and has_flattened_params:
1655
+ raise ValueError(
1656
+ "If the `request` argument is set, then none of "
1657
+ "the individual field arguments should be set."
1658
+ )
1659
+
1660
+ # Minor optimization to avoid making a copy if the user passes
1661
+ # in a partners.GetPartnerRequest.
1662
+ # There's no risk of modifying the input as we've already verified
1663
+ # there are no flattened fields.
1664
+ if not isinstance(request, partners.GetPartnerRequest):
1665
+ request = partners.GetPartnerRequest(request)
1666
+ # If we have keyword arguments corresponding to fields on the
1667
+ # request, apply these.
1668
+ if name is not None:
1669
+ request.name = name
1670
+
1671
+ # Wrap the RPC method; this adds retry and timeout information,
1672
+ # and friendly error handling.
1673
+ rpc = self._transport._wrapped_methods[self._transport.get_partner]
1674
+
1675
+ # Certain fields should be provided within the metadata header;
1676
+ # add these here.
1677
+ metadata = tuple(metadata) + (
1678
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1679
+ )
1680
+
1681
+ # Validate the universe domain.
1682
+ self._validate_universe_domain()
1683
+
1684
+ # Send the request.
1685
+ response = rpc(
1686
+ request,
1687
+ retry=retry,
1688
+ timeout=timeout,
1689
+ metadata=metadata,
1690
+ )
1691
+
1692
+ # Done; return the response.
1693
+ return response
1694
+
1695
+ def __enter__(self) -> "CloudControlsPartnerCoreClient":
1696
+ return self
1697
+
1698
+ def __exit__(self, type, value, traceback):
1699
+ """Releases underlying transport's resources.
1700
+
1701
+ .. warning::
1702
+ ONLY use as a context manager if the transport is NOT shared
1703
+ with other clients! Exiting the with block will CLOSE the transport
1704
+ and may cause errors in other clients!
1705
+ """
1706
+ self.transport.close()
1707
+
1708
+
1709
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1710
+ gapic_version=package_version.__version__
1711
+ )
1712
+
1713
+
1714
+ __all__ = ("CloudControlsPartnerCoreClient",)