google-cloud-dataproc 5.18.1__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 (103) hide show
  1. google/cloud/dataproc/__init__.py +409 -0
  2. google/cloud/dataproc/gapic_version.py +16 -0
  3. google/cloud/dataproc/py.typed +2 -0
  4. google/cloud/dataproc_v1/__init__.py +389 -0
  5. google/cloud/dataproc_v1/gapic_metadata.json +821 -0
  6. google/cloud/dataproc_v1/gapic_version.py +16 -0
  7. google/cloud/dataproc_v1/py.typed +2 -0
  8. google/cloud/dataproc_v1/services/__init__.py +15 -0
  9. google/cloud/dataproc_v1/services/autoscaling_policy_service/__init__.py +22 -0
  10. google/cloud/dataproc_v1/services/autoscaling_policy_service/async_client.py +1488 -0
  11. google/cloud/dataproc_v1/services/autoscaling_policy_service/client.py +1924 -0
  12. google/cloud/dataproc_v1/services/autoscaling_policy_service/pagers.py +201 -0
  13. google/cloud/dataproc_v1/services/autoscaling_policy_service/transports/__init__.py +41 -0
  14. google/cloud/dataproc_v1/services/autoscaling_policy_service/transports/base.py +361 -0
  15. google/cloud/dataproc_v1/services/autoscaling_policy_service/transports/grpc.py +635 -0
  16. google/cloud/dataproc_v1/services/autoscaling_policy_service/transports/grpc_asyncio.py +743 -0
  17. google/cloud/dataproc_v1/services/autoscaling_policy_service/transports/rest.py +2358 -0
  18. google/cloud/dataproc_v1/services/autoscaling_policy_service/transports/rest_base.py +671 -0
  19. google/cloud/dataproc_v1/services/batch_controller/__init__.py +22 -0
  20. google/cloud/dataproc_v1/services/batch_controller/async_client.py +1330 -0
  21. google/cloud/dataproc_v1/services/batch_controller/client.py +1786 -0
  22. google/cloud/dataproc_v1/services/batch_controller/pagers.py +197 -0
  23. google/cloud/dataproc_v1/services/batch_controller/transports/__init__.py +36 -0
  24. google/cloud/dataproc_v1/services/batch_controller/transports/base.py +308 -0
  25. google/cloud/dataproc_v1/services/batch_controller/transports/grpc.py +606 -0
  26. google/cloud/dataproc_v1/services/batch_controller/transports/grpc_asyncio.py +682 -0
  27. google/cloud/dataproc_v1/services/batch_controller/transports/rest.py +2118 -0
  28. google/cloud/dataproc_v1/services/batch_controller/transports/rest_base.py +592 -0
  29. google/cloud/dataproc_v1/services/cluster_controller/__init__.py +22 -0
  30. google/cloud/dataproc_v1/services/cluster_controller/async_client.py +2096 -0
  31. google/cloud/dataproc_v1/services/cluster_controller/client.py +2587 -0
  32. google/cloud/dataproc_v1/services/cluster_controller/pagers.py +197 -0
  33. google/cloud/dataproc_v1/services/cluster_controller/transports/__init__.py +36 -0
  34. google/cloud/dataproc_v1/services/cluster_controller/transports/base.py +423 -0
  35. google/cloud/dataproc_v1/services/cluster_controller/transports/grpc.py +729 -0
  36. google/cloud/dataproc_v1/services/cluster_controller/transports/grpc_asyncio.py +885 -0
  37. google/cloud/dataproc_v1/services/cluster_controller/transports/rest.py +3062 -0
  38. google/cloud/dataproc_v1/services/cluster_controller/transports/rest_base.py +821 -0
  39. google/cloud/dataproc_v1/services/job_controller/__init__.py +22 -0
  40. google/cloud/dataproc_v1/services/job_controller/async_client.py +1787 -0
  41. google/cloud/dataproc_v1/services/job_controller/client.py +2195 -0
  42. google/cloud/dataproc_v1/services/job_controller/pagers.py +197 -0
  43. google/cloud/dataproc_v1/services/job_controller/transports/__init__.py +36 -0
  44. google/cloud/dataproc_v1/services/job_controller/transports/base.py +408 -0
  45. google/cloud/dataproc_v1/services/job_controller/transports/grpc.py +678 -0
  46. google/cloud/dataproc_v1/services/job_controller/transports/grpc_asyncio.py +838 -0
  47. google/cloud/dataproc_v1/services/job_controller/transports/rest.py +2753 -0
  48. google/cloud/dataproc_v1/services/job_controller/transports/rest_base.py +765 -0
  49. google/cloud/dataproc_v1/services/node_group_controller/__init__.py +22 -0
  50. google/cloud/dataproc_v1/services/node_group_controller/async_client.py +1255 -0
  51. google/cloud/dataproc_v1/services/node_group_controller/client.py +1695 -0
  52. google/cloud/dataproc_v1/services/node_group_controller/transports/__init__.py +38 -0
  53. google/cloud/dataproc_v1/services/node_group_controller/transports/base.py +295 -0
  54. google/cloud/dataproc_v1/services/node_group_controller/transports/grpc.py +585 -0
  55. google/cloud/dataproc_v1/services/node_group_controller/transports/grpc_asyncio.py +656 -0
  56. google/cloud/dataproc_v1/services/node_group_controller/transports/rest.py +2017 -0
  57. google/cloud/dataproc_v1/services/node_group_controller/transports/rest_base.py +554 -0
  58. google/cloud/dataproc_v1/services/session_controller/__init__.py +22 -0
  59. google/cloud/dataproc_v1/services/session_controller/async_client.py +1488 -0
  60. google/cloud/dataproc_v1/services/session_controller/client.py +1960 -0
  61. google/cloud/dataproc_v1/services/session_controller/pagers.py +197 -0
  62. google/cloud/dataproc_v1/services/session_controller/transports/__init__.py +36 -0
  63. google/cloud/dataproc_v1/services/session_controller/transports/base.py +323 -0
  64. google/cloud/dataproc_v1/services/session_controller/transports/grpc.py +633 -0
  65. google/cloud/dataproc_v1/services/session_controller/transports/grpc_asyncio.py +716 -0
  66. google/cloud/dataproc_v1/services/session_controller/transports/rest.py +2416 -0
  67. google/cloud/dataproc_v1/services/session_controller/transports/rest_base.py +650 -0
  68. google/cloud/dataproc_v1/services/session_template_controller/__init__.py +22 -0
  69. google/cloud/dataproc_v1/services/session_template_controller/async_client.py +1442 -0
  70. google/cloud/dataproc_v1/services/session_template_controller/client.py +1886 -0
  71. google/cloud/dataproc_v1/services/session_template_controller/pagers.py +201 -0
  72. google/cloud/dataproc_v1/services/session_template_controller/transports/__init__.py +41 -0
  73. google/cloud/dataproc_v1/services/session_template_controller/transports/base.py +331 -0
  74. google/cloud/dataproc_v1/services/session_template_controller/transports/grpc.py +628 -0
  75. google/cloud/dataproc_v1/services/session_template_controller/transports/grpc_asyncio.py +708 -0
  76. google/cloud/dataproc_v1/services/session_template_controller/transports/rest.py +2349 -0
  77. google/cloud/dataproc_v1/services/session_template_controller/transports/rest_base.py +649 -0
  78. google/cloud/dataproc_v1/services/workflow_template_service/__init__.py +22 -0
  79. google/cloud/dataproc_v1/services/workflow_template_service/async_client.py +1885 -0
  80. google/cloud/dataproc_v1/services/workflow_template_service/client.py +2370 -0
  81. google/cloud/dataproc_v1/services/workflow_template_service/pagers.py +201 -0
  82. google/cloud/dataproc_v1/services/workflow_template_service/transports/__init__.py +41 -0
  83. google/cloud/dataproc_v1/services/workflow_template_service/transports/base.py +431 -0
  84. google/cloud/dataproc_v1/services/workflow_template_service/transports/grpc.py +760 -0
  85. google/cloud/dataproc_v1/services/workflow_template_service/transports/grpc_asyncio.py +916 -0
  86. google/cloud/dataproc_v1/services/workflow_template_service/transports/rest.py +2882 -0
  87. google/cloud/dataproc_v1/services/workflow_template_service/transports/rest_base.py +799 -0
  88. google/cloud/dataproc_v1/types/__init__.py +342 -0
  89. google/cloud/dataproc_v1/types/autoscaling_policies.py +448 -0
  90. google/cloud/dataproc_v1/types/batches.py +642 -0
  91. google/cloud/dataproc_v1/types/clusters.py +2671 -0
  92. google/cloud/dataproc_v1/types/jobs.py +1822 -0
  93. google/cloud/dataproc_v1/types/node_groups.py +166 -0
  94. google/cloud/dataproc_v1/types/operations.py +395 -0
  95. google/cloud/dataproc_v1/types/session_templates.py +284 -0
  96. google/cloud/dataproc_v1/types/sessions.py +504 -0
  97. google/cloud/dataproc_v1/types/shared.py +1010 -0
  98. google/cloud/dataproc_v1/types/workflow_templates.py +1229 -0
  99. google_cloud_dataproc-5.18.1.dist-info/LICENSE +202 -0
  100. google_cloud_dataproc-5.18.1.dist-info/METADATA +229 -0
  101. google_cloud_dataproc-5.18.1.dist-info/RECORD +103 -0
  102. google_cloud_dataproc-5.18.1.dist-info/WHEEL +5 -0
  103. google_cloud_dataproc-5.18.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1488 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2024 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from collections import OrderedDict
17
+ import logging as std_logging
18
+ import re
19
+ from typing import (
20
+ Callable,
21
+ Dict,
22
+ Mapping,
23
+ MutableMapping,
24
+ MutableSequence,
25
+ Optional,
26
+ Sequence,
27
+ Tuple,
28
+ Type,
29
+ Union,
30
+ )
31
+
32
+ from google.api_core import exceptions as core_exceptions
33
+ from google.api_core import gapic_v1
34
+ from google.api_core import retry_async as retries
35
+ from google.api_core.client_options import ClientOptions
36
+ from google.auth import credentials as ga_credentials # type: ignore
37
+ from google.oauth2 import service_account # type: ignore
38
+
39
+ from google.cloud.dataproc_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.iam.v1 import iam_policy_pb2 # type: ignore
47
+ from google.iam.v1 import policy_pb2 # type: ignore
48
+ from google.longrunning import operations_pb2 # type: ignore
49
+
50
+ from google.cloud.dataproc_v1.services.autoscaling_policy_service import pagers
51
+ from google.cloud.dataproc_v1.types import autoscaling_policies
52
+
53
+ from .client import AutoscalingPolicyServiceClient
54
+ from .transports.base import DEFAULT_CLIENT_INFO, AutoscalingPolicyServiceTransport
55
+ from .transports.grpc_asyncio import AutoscalingPolicyServiceGrpcAsyncIOTransport
56
+
57
+ try:
58
+ from google.api_core import client_logging # type: ignore
59
+
60
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
61
+ except ImportError: # pragma: NO COVER
62
+ CLIENT_LOGGING_SUPPORTED = False
63
+
64
+ _LOGGER = std_logging.getLogger(__name__)
65
+
66
+
67
+ class AutoscalingPolicyServiceAsyncClient:
68
+ """The API interface for managing autoscaling policies in the
69
+ Dataproc API.
70
+ """
71
+
72
+ _client: AutoscalingPolicyServiceClient
73
+
74
+ # Copy defaults from the synchronous client for use here.
75
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
76
+ DEFAULT_ENDPOINT = AutoscalingPolicyServiceClient.DEFAULT_ENDPOINT
77
+ DEFAULT_MTLS_ENDPOINT = AutoscalingPolicyServiceClient.DEFAULT_MTLS_ENDPOINT
78
+ _DEFAULT_ENDPOINT_TEMPLATE = (
79
+ AutoscalingPolicyServiceClient._DEFAULT_ENDPOINT_TEMPLATE
80
+ )
81
+ _DEFAULT_UNIVERSE = AutoscalingPolicyServiceClient._DEFAULT_UNIVERSE
82
+
83
+ autoscaling_policy_path = staticmethod(
84
+ AutoscalingPolicyServiceClient.autoscaling_policy_path
85
+ )
86
+ parse_autoscaling_policy_path = staticmethod(
87
+ AutoscalingPolicyServiceClient.parse_autoscaling_policy_path
88
+ )
89
+ common_billing_account_path = staticmethod(
90
+ AutoscalingPolicyServiceClient.common_billing_account_path
91
+ )
92
+ parse_common_billing_account_path = staticmethod(
93
+ AutoscalingPolicyServiceClient.parse_common_billing_account_path
94
+ )
95
+ common_folder_path = staticmethod(AutoscalingPolicyServiceClient.common_folder_path)
96
+ parse_common_folder_path = staticmethod(
97
+ AutoscalingPolicyServiceClient.parse_common_folder_path
98
+ )
99
+ common_organization_path = staticmethod(
100
+ AutoscalingPolicyServiceClient.common_organization_path
101
+ )
102
+ parse_common_organization_path = staticmethod(
103
+ AutoscalingPolicyServiceClient.parse_common_organization_path
104
+ )
105
+ common_project_path = staticmethod(
106
+ AutoscalingPolicyServiceClient.common_project_path
107
+ )
108
+ parse_common_project_path = staticmethod(
109
+ AutoscalingPolicyServiceClient.parse_common_project_path
110
+ )
111
+ common_location_path = staticmethod(
112
+ AutoscalingPolicyServiceClient.common_location_path
113
+ )
114
+ parse_common_location_path = staticmethod(
115
+ AutoscalingPolicyServiceClient.parse_common_location_path
116
+ )
117
+
118
+ @classmethod
119
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
120
+ """Creates an instance of this client using the provided credentials
121
+ info.
122
+
123
+ Args:
124
+ info (dict): The service account private key info.
125
+ args: Additional arguments to pass to the constructor.
126
+ kwargs: Additional arguments to pass to the constructor.
127
+
128
+ Returns:
129
+ AutoscalingPolicyServiceAsyncClient: The constructed client.
130
+ """
131
+ return AutoscalingPolicyServiceClient.from_service_account_info.__func__(AutoscalingPolicyServiceAsyncClient, info, *args, **kwargs) # type: ignore
132
+
133
+ @classmethod
134
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
135
+ """Creates an instance of this client using the provided credentials
136
+ file.
137
+
138
+ Args:
139
+ filename (str): The path to the service account private key json
140
+ file.
141
+ args: Additional arguments to pass to the constructor.
142
+ kwargs: Additional arguments to pass to the constructor.
143
+
144
+ Returns:
145
+ AutoscalingPolicyServiceAsyncClient: The constructed client.
146
+ """
147
+ return AutoscalingPolicyServiceClient.from_service_account_file.__func__(AutoscalingPolicyServiceAsyncClient, filename, *args, **kwargs) # type: ignore
148
+
149
+ from_service_account_json = from_service_account_file
150
+
151
+ @classmethod
152
+ def get_mtls_endpoint_and_cert_source(
153
+ cls, client_options: Optional[ClientOptions] = None
154
+ ):
155
+ """Return the API endpoint and client cert source for mutual TLS.
156
+
157
+ The client cert source is determined in the following order:
158
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
159
+ client cert source is None.
160
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
161
+ default client cert source exists, use the default one; otherwise the client cert
162
+ source is None.
163
+
164
+ The API endpoint is determined in the following order:
165
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
166
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
167
+ default mTLS endpoint; if the environment variable is "never", use the default API
168
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
169
+ use the default API endpoint.
170
+
171
+ More details can be found at https://google.aip.dev/auth/4114.
172
+
173
+ Args:
174
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
175
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
176
+ in this method.
177
+
178
+ Returns:
179
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
180
+ client cert source to use.
181
+
182
+ Raises:
183
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
184
+ """
185
+ return AutoscalingPolicyServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
186
+
187
+ @property
188
+ def transport(self) -> AutoscalingPolicyServiceTransport:
189
+ """Returns the transport used by the client instance.
190
+
191
+ Returns:
192
+ AutoscalingPolicyServiceTransport: The transport used by the client instance.
193
+ """
194
+ return self._client.transport
195
+
196
+ @property
197
+ def api_endpoint(self):
198
+ """Return the API endpoint used by the client instance.
199
+
200
+ Returns:
201
+ str: The API endpoint used by the client instance.
202
+ """
203
+ return self._client._api_endpoint
204
+
205
+ @property
206
+ def universe_domain(self) -> str:
207
+ """Return the universe domain used by the client instance.
208
+
209
+ Returns:
210
+ str: The universe domain used
211
+ by the client instance.
212
+ """
213
+ return self._client._universe_domain
214
+
215
+ get_transport_class = AutoscalingPolicyServiceClient.get_transport_class
216
+
217
+ def __init__(
218
+ self,
219
+ *,
220
+ credentials: Optional[ga_credentials.Credentials] = None,
221
+ transport: Optional[
222
+ Union[
223
+ str,
224
+ AutoscalingPolicyServiceTransport,
225
+ Callable[..., AutoscalingPolicyServiceTransport],
226
+ ]
227
+ ] = "grpc_asyncio",
228
+ client_options: Optional[ClientOptions] = None,
229
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
230
+ ) -> None:
231
+ """Instantiates the autoscaling policy service async client.
232
+
233
+ Args:
234
+ credentials (Optional[google.auth.credentials.Credentials]): The
235
+ authorization credentials to attach to requests. These
236
+ credentials identify the application to the service; if none
237
+ are specified, the client will attempt to ascertain the
238
+ credentials from the environment.
239
+ transport (Optional[Union[str,AutoscalingPolicyServiceTransport,Callable[..., AutoscalingPolicyServiceTransport]]]):
240
+ The transport to use, or a Callable that constructs and returns a new transport to use.
241
+ If a Callable is given, it will be called with the same set of initialization
242
+ arguments as used in the AutoscalingPolicyServiceTransport constructor.
243
+ If set to None, a transport is chosen automatically.
244
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
245
+ Custom options for the client.
246
+
247
+ 1. The ``api_endpoint`` property can be used to override the
248
+ default endpoint provided by the client when ``transport`` is
249
+ not explicitly provided. Only if this property is not set and
250
+ ``transport`` was not explicitly provided, the endpoint is
251
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
252
+ variable, which have one of the following values:
253
+ "always" (always use the default mTLS endpoint), "never" (always
254
+ use the default regular endpoint) and "auto" (auto-switch to the
255
+ default mTLS endpoint if client certificate is present; this is
256
+ the default value).
257
+
258
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
259
+ is "true", then the ``client_cert_source`` property can be used
260
+ to provide a client certificate for mTLS transport. If
261
+ not provided, the default SSL client certificate will be used if
262
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
263
+ set, no client certificate will be used.
264
+
265
+ 3. The ``universe_domain`` property can be used to override the
266
+ default "googleapis.com" universe. Note that ``api_endpoint``
267
+ property still takes precedence; and ``universe_domain`` is
268
+ currently not supported for mTLS.
269
+
270
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
271
+ The client info used to send a user-agent string along with
272
+ API requests. If ``None``, then default info will be used.
273
+ Generally, you only need to set this if you're developing
274
+ your own client library.
275
+
276
+ Raises:
277
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
278
+ creation failed for any reason.
279
+ """
280
+ self._client = AutoscalingPolicyServiceClient(
281
+ credentials=credentials,
282
+ transport=transport,
283
+ client_options=client_options,
284
+ client_info=client_info,
285
+ )
286
+
287
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
288
+ std_logging.DEBUG
289
+ ): # pragma: NO COVER
290
+ _LOGGER.debug(
291
+ "Created client `google.cloud.dataproc_v1.AutoscalingPolicyServiceAsyncClient`.",
292
+ extra={
293
+ "serviceName": "google.cloud.dataproc.v1.AutoscalingPolicyService",
294
+ "universeDomain": getattr(
295
+ self._client._transport._credentials, "universe_domain", ""
296
+ ),
297
+ "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
298
+ "credentialsInfo": getattr(
299
+ self.transport._credentials, "get_cred_info", lambda: None
300
+ )(),
301
+ }
302
+ if hasattr(self._client._transport, "_credentials")
303
+ else {
304
+ "serviceName": "google.cloud.dataproc.v1.AutoscalingPolicyService",
305
+ "credentialsType": None,
306
+ },
307
+ )
308
+
309
+ async def create_autoscaling_policy(
310
+ self,
311
+ request: Optional[
312
+ Union[autoscaling_policies.CreateAutoscalingPolicyRequest, dict]
313
+ ] = None,
314
+ *,
315
+ parent: Optional[str] = None,
316
+ policy: Optional[autoscaling_policies.AutoscalingPolicy] = None,
317
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
318
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
319
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
320
+ ) -> autoscaling_policies.AutoscalingPolicy:
321
+ r"""Creates new autoscaling policy.
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 dataproc_v1
333
+
334
+ async def sample_create_autoscaling_policy():
335
+ # Create a client
336
+ client = dataproc_v1.AutoscalingPolicyServiceAsyncClient()
337
+
338
+ # Initialize request argument(s)
339
+ policy = dataproc_v1.AutoscalingPolicy()
340
+ policy.basic_algorithm.yarn_config.scale_up_factor = 0.1578
341
+ policy.basic_algorithm.yarn_config.scale_down_factor = 0.1789
342
+ policy.worker_config.max_instances = 1389
343
+
344
+ request = dataproc_v1.CreateAutoscalingPolicyRequest(
345
+ parent="parent_value",
346
+ policy=policy,
347
+ )
348
+
349
+ # Make the request
350
+ response = await client.create_autoscaling_policy(request=request)
351
+
352
+ # Handle the response
353
+ print(response)
354
+
355
+ Args:
356
+ request (Optional[Union[google.cloud.dataproc_v1.types.CreateAutoscalingPolicyRequest, dict]]):
357
+ The request object. A request to create an autoscaling
358
+ policy.
359
+ parent (:class:`str`):
360
+ Required. The "resource name" of the region or location,
361
+ as described in
362
+ https://cloud.google.com/apis/design/resource_names.
363
+
364
+ - For ``projects.regions.autoscalingPolicies.create``,
365
+ the resource name of the region has the following
366
+ format: ``projects/{project_id}/regions/{region}``
367
+
368
+ - For
369
+ ``projects.locations.autoscalingPolicies.create``,
370
+ the resource name of the location has the following
371
+ format:
372
+ ``projects/{project_id}/locations/{location}``
373
+
374
+ This corresponds to the ``parent`` field
375
+ on the ``request`` instance; if ``request`` is provided, this
376
+ should not be set.
377
+ policy (:class:`google.cloud.dataproc_v1.types.AutoscalingPolicy`):
378
+ Required. The autoscaling policy to
379
+ create.
380
+
381
+ This corresponds to the ``policy`` field
382
+ on the ``request`` instance; if ``request`` is provided, this
383
+ should not be set.
384
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
385
+ should be retried.
386
+ timeout (float): The timeout for this request.
387
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
388
+ sent along with the request as metadata. Normally, each value must be of type `str`,
389
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
390
+ be of type `bytes`.
391
+
392
+ Returns:
393
+ google.cloud.dataproc_v1.types.AutoscalingPolicy:
394
+ Describes an autoscaling policy for
395
+ Dataproc cluster autoscaler.
396
+
397
+ """
398
+ # Create or coerce a protobuf request object.
399
+ # - Quick check: If we got a request object, we should *not* have
400
+ # gotten any keyword arguments that map to the request.
401
+ flattened_params = [parent, policy]
402
+ has_flattened_params = (
403
+ len([param for param in flattened_params if param is not None]) > 0
404
+ )
405
+ if request is not None and has_flattened_params:
406
+ raise ValueError(
407
+ "If the `request` argument is set, then none of "
408
+ "the individual field arguments should be set."
409
+ )
410
+
411
+ # - Use the request object if provided (there's no risk of modifying the input as
412
+ # there are no flattened fields), or create one.
413
+ if not isinstance(request, autoscaling_policies.CreateAutoscalingPolicyRequest):
414
+ request = autoscaling_policies.CreateAutoscalingPolicyRequest(request)
415
+
416
+ # If we have keyword arguments corresponding to fields on the
417
+ # request, apply these.
418
+ if parent is not None:
419
+ request.parent = parent
420
+ if policy is not None:
421
+ request.policy = policy
422
+
423
+ # Wrap the RPC method; this adds retry and timeout information,
424
+ # and friendly error handling.
425
+ rpc = self._client._transport._wrapped_methods[
426
+ self._client._transport.create_autoscaling_policy
427
+ ]
428
+
429
+ # Certain fields should be provided within the metadata header;
430
+ # add these here.
431
+ metadata = tuple(metadata) + (
432
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
433
+ )
434
+
435
+ # Validate the universe domain.
436
+ self._client._validate_universe_domain()
437
+
438
+ # Send the request.
439
+ response = await rpc(
440
+ request,
441
+ retry=retry,
442
+ timeout=timeout,
443
+ metadata=metadata,
444
+ )
445
+
446
+ # Done; return the response.
447
+ return response
448
+
449
+ async def update_autoscaling_policy(
450
+ self,
451
+ request: Optional[
452
+ Union[autoscaling_policies.UpdateAutoscalingPolicyRequest, dict]
453
+ ] = None,
454
+ *,
455
+ policy: Optional[autoscaling_policies.AutoscalingPolicy] = None,
456
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
457
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
458
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
459
+ ) -> autoscaling_policies.AutoscalingPolicy:
460
+ r"""Updates (replaces) autoscaling policy.
461
+
462
+ Disabled check for update_mask, because all updates will be full
463
+ replacements.
464
+
465
+ .. code-block:: python
466
+
467
+ # This snippet has been automatically generated and should be regarded as a
468
+ # code template only.
469
+ # It will require modifications to work:
470
+ # - It may require correct/in-range values for request initialization.
471
+ # - It may require specifying regional endpoints when creating the service
472
+ # client as shown in:
473
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
474
+ from google.cloud import dataproc_v1
475
+
476
+ async def sample_update_autoscaling_policy():
477
+ # Create a client
478
+ client = dataproc_v1.AutoscalingPolicyServiceAsyncClient()
479
+
480
+ # Initialize request argument(s)
481
+ policy = dataproc_v1.AutoscalingPolicy()
482
+ policy.basic_algorithm.yarn_config.scale_up_factor = 0.1578
483
+ policy.basic_algorithm.yarn_config.scale_down_factor = 0.1789
484
+ policy.worker_config.max_instances = 1389
485
+
486
+ request = dataproc_v1.UpdateAutoscalingPolicyRequest(
487
+ policy=policy,
488
+ )
489
+
490
+ # Make the request
491
+ response = await client.update_autoscaling_policy(request=request)
492
+
493
+ # Handle the response
494
+ print(response)
495
+
496
+ Args:
497
+ request (Optional[Union[google.cloud.dataproc_v1.types.UpdateAutoscalingPolicyRequest, dict]]):
498
+ The request object. A request to update an autoscaling
499
+ policy.
500
+ policy (:class:`google.cloud.dataproc_v1.types.AutoscalingPolicy`):
501
+ Required. The updated autoscaling
502
+ policy.
503
+
504
+ This corresponds to the ``policy`` field
505
+ on the ``request`` instance; if ``request`` is provided, this
506
+ should not be set.
507
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
508
+ should be retried.
509
+ timeout (float): The timeout for this request.
510
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
511
+ sent along with the request as metadata. Normally, each value must be of type `str`,
512
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
513
+ be of type `bytes`.
514
+
515
+ Returns:
516
+ google.cloud.dataproc_v1.types.AutoscalingPolicy:
517
+ Describes an autoscaling policy for
518
+ Dataproc cluster autoscaler.
519
+
520
+ """
521
+ # Create or coerce a protobuf request object.
522
+ # - Quick check: If we got a request object, we should *not* have
523
+ # gotten any keyword arguments that map to the request.
524
+ flattened_params = [policy]
525
+ has_flattened_params = (
526
+ len([param for param in flattened_params if param is not None]) > 0
527
+ )
528
+ if request is not None and has_flattened_params:
529
+ raise ValueError(
530
+ "If the `request` argument is set, then none of "
531
+ "the individual field arguments should be set."
532
+ )
533
+
534
+ # - Use the request object if provided (there's no risk of modifying the input as
535
+ # there are no flattened fields), or create one.
536
+ if not isinstance(request, autoscaling_policies.UpdateAutoscalingPolicyRequest):
537
+ request = autoscaling_policies.UpdateAutoscalingPolicyRequest(request)
538
+
539
+ # If we have keyword arguments corresponding to fields on the
540
+ # request, apply these.
541
+ if policy is not None:
542
+ request.policy = policy
543
+
544
+ # Wrap the RPC method; this adds retry and timeout information,
545
+ # and friendly error handling.
546
+ rpc = self._client._transport._wrapped_methods[
547
+ self._client._transport.update_autoscaling_policy
548
+ ]
549
+
550
+ # Certain fields should be provided within the metadata header;
551
+ # add these here.
552
+ metadata = tuple(metadata) + (
553
+ gapic_v1.routing_header.to_grpc_metadata(
554
+ (("policy.name", request.policy.name),)
555
+ ),
556
+ )
557
+
558
+ # Validate the universe domain.
559
+ self._client._validate_universe_domain()
560
+
561
+ # Send the request.
562
+ response = await rpc(
563
+ request,
564
+ retry=retry,
565
+ timeout=timeout,
566
+ metadata=metadata,
567
+ )
568
+
569
+ # Done; return the response.
570
+ return response
571
+
572
+ async def get_autoscaling_policy(
573
+ self,
574
+ request: Optional[
575
+ Union[autoscaling_policies.GetAutoscalingPolicyRequest, dict]
576
+ ] = None,
577
+ *,
578
+ name: Optional[str] = None,
579
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
580
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
581
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
582
+ ) -> autoscaling_policies.AutoscalingPolicy:
583
+ r"""Retrieves autoscaling policy.
584
+
585
+ .. code-block:: python
586
+
587
+ # This snippet has been automatically generated and should be regarded as a
588
+ # code template only.
589
+ # It will require modifications to work:
590
+ # - It may require correct/in-range values for request initialization.
591
+ # - It may require specifying regional endpoints when creating the service
592
+ # client as shown in:
593
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
594
+ from google.cloud import dataproc_v1
595
+
596
+ async def sample_get_autoscaling_policy():
597
+ # Create a client
598
+ client = dataproc_v1.AutoscalingPolicyServiceAsyncClient()
599
+
600
+ # Initialize request argument(s)
601
+ request = dataproc_v1.GetAutoscalingPolicyRequest(
602
+ name="name_value",
603
+ )
604
+
605
+ # Make the request
606
+ response = await client.get_autoscaling_policy(request=request)
607
+
608
+ # Handle the response
609
+ print(response)
610
+
611
+ Args:
612
+ request (Optional[Union[google.cloud.dataproc_v1.types.GetAutoscalingPolicyRequest, dict]]):
613
+ The request object. A request to fetch an autoscaling
614
+ policy.
615
+ name (:class:`str`):
616
+ Required. The "resource name" of the autoscaling policy,
617
+ as described in
618
+ https://cloud.google.com/apis/design/resource_names.
619
+
620
+ - For ``projects.regions.autoscalingPolicies.get``, the
621
+ resource name of the policy has the following format:
622
+ ``projects/{project_id}/regions/{region}/autoscalingPolicies/{policy_id}``
623
+
624
+ - For ``projects.locations.autoscalingPolicies.get``,
625
+ the resource name of the policy has the following
626
+ format:
627
+ ``projects/{project_id}/locations/{location}/autoscalingPolicies/{policy_id}``
628
+
629
+ This corresponds to the ``name`` field
630
+ on the ``request`` instance; if ``request`` is provided, this
631
+ should not be set.
632
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
633
+ should be retried.
634
+ timeout (float): The timeout for this request.
635
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
636
+ sent along with the request as metadata. Normally, each value must be of type `str`,
637
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
638
+ be of type `bytes`.
639
+
640
+ Returns:
641
+ google.cloud.dataproc_v1.types.AutoscalingPolicy:
642
+ Describes an autoscaling policy for
643
+ Dataproc cluster autoscaler.
644
+
645
+ """
646
+ # Create or coerce a protobuf request object.
647
+ # - Quick check: If we got a request object, we should *not* have
648
+ # gotten any keyword arguments that map to the request.
649
+ flattened_params = [name]
650
+ has_flattened_params = (
651
+ len([param for param in flattened_params if param is not None]) > 0
652
+ )
653
+ if request is not None and has_flattened_params:
654
+ raise ValueError(
655
+ "If the `request` argument is set, then none of "
656
+ "the individual field arguments should be set."
657
+ )
658
+
659
+ # - Use the request object if provided (there's no risk of modifying the input as
660
+ # there are no flattened fields), or create one.
661
+ if not isinstance(request, autoscaling_policies.GetAutoscalingPolicyRequest):
662
+ request = autoscaling_policies.GetAutoscalingPolicyRequest(request)
663
+
664
+ # If we have keyword arguments corresponding to fields on the
665
+ # request, apply these.
666
+ if name is not None:
667
+ request.name = name
668
+
669
+ # Wrap the RPC method; this adds retry and timeout information,
670
+ # and friendly error handling.
671
+ rpc = self._client._transport._wrapped_methods[
672
+ self._client._transport.get_autoscaling_policy
673
+ ]
674
+
675
+ # Certain fields should be provided within the metadata header;
676
+ # add these here.
677
+ metadata = tuple(metadata) + (
678
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
679
+ )
680
+
681
+ # Validate the universe domain.
682
+ self._client._validate_universe_domain()
683
+
684
+ # Send the request.
685
+ response = await rpc(
686
+ request,
687
+ retry=retry,
688
+ timeout=timeout,
689
+ metadata=metadata,
690
+ )
691
+
692
+ # Done; return the response.
693
+ return response
694
+
695
+ async def list_autoscaling_policies(
696
+ self,
697
+ request: Optional[
698
+ Union[autoscaling_policies.ListAutoscalingPoliciesRequest, dict]
699
+ ] = None,
700
+ *,
701
+ parent: Optional[str] = None,
702
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
703
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
704
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
705
+ ) -> pagers.ListAutoscalingPoliciesAsyncPager:
706
+ r"""Lists autoscaling policies in the project.
707
+
708
+ .. code-block:: python
709
+
710
+ # This snippet has been automatically generated and should be regarded as a
711
+ # code template only.
712
+ # It will require modifications to work:
713
+ # - It may require correct/in-range values for request initialization.
714
+ # - It may require specifying regional endpoints when creating the service
715
+ # client as shown in:
716
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
717
+ from google.cloud import dataproc_v1
718
+
719
+ async def sample_list_autoscaling_policies():
720
+ # Create a client
721
+ client = dataproc_v1.AutoscalingPolicyServiceAsyncClient()
722
+
723
+ # Initialize request argument(s)
724
+ request = dataproc_v1.ListAutoscalingPoliciesRequest(
725
+ parent="parent_value",
726
+ )
727
+
728
+ # Make the request
729
+ page_result = client.list_autoscaling_policies(request=request)
730
+
731
+ # Handle the response
732
+ async for response in page_result:
733
+ print(response)
734
+
735
+ Args:
736
+ request (Optional[Union[google.cloud.dataproc_v1.types.ListAutoscalingPoliciesRequest, dict]]):
737
+ The request object. A request to list autoscaling
738
+ policies in a project.
739
+ parent (:class:`str`):
740
+ Required. The "resource name" of the region or location,
741
+ as described in
742
+ https://cloud.google.com/apis/design/resource_names.
743
+
744
+ - For ``projects.regions.autoscalingPolicies.list``,
745
+ the resource name of the region has the following
746
+ format: ``projects/{project_id}/regions/{region}``
747
+
748
+ - For ``projects.locations.autoscalingPolicies.list``,
749
+ the resource name of the location has the following
750
+ format:
751
+ ``projects/{project_id}/locations/{location}``
752
+
753
+ This corresponds to the ``parent`` field
754
+ on the ``request`` instance; if ``request`` is provided, this
755
+ should not be set.
756
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
757
+ should be retried.
758
+ timeout (float): The timeout for this request.
759
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
760
+ sent along with the request as metadata. Normally, each value must be of type `str`,
761
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
762
+ be of type `bytes`.
763
+
764
+ Returns:
765
+ google.cloud.dataproc_v1.services.autoscaling_policy_service.pagers.ListAutoscalingPoliciesAsyncPager:
766
+ A response to a request to list
767
+ autoscaling policies in a project.
768
+ Iterating over this object will yield
769
+ results and resolve additional pages
770
+ automatically.
771
+
772
+ """
773
+ # Create or coerce a protobuf request object.
774
+ # - Quick check: If we got a request object, we should *not* have
775
+ # gotten any keyword arguments that map to the request.
776
+ flattened_params = [parent]
777
+ has_flattened_params = (
778
+ len([param for param in flattened_params if param is not None]) > 0
779
+ )
780
+ if request is not None and has_flattened_params:
781
+ raise ValueError(
782
+ "If the `request` argument is set, then none of "
783
+ "the individual field arguments should be set."
784
+ )
785
+
786
+ # - Use the request object if provided (there's no risk of modifying the input as
787
+ # there are no flattened fields), or create one.
788
+ if not isinstance(request, autoscaling_policies.ListAutoscalingPoliciesRequest):
789
+ request = autoscaling_policies.ListAutoscalingPoliciesRequest(request)
790
+
791
+ # If we have keyword arguments corresponding to fields on the
792
+ # request, apply these.
793
+ if parent is not None:
794
+ request.parent = parent
795
+
796
+ # Wrap the RPC method; this adds retry and timeout information,
797
+ # and friendly error handling.
798
+ rpc = self._client._transport._wrapped_methods[
799
+ self._client._transport.list_autoscaling_policies
800
+ ]
801
+
802
+ # Certain fields should be provided within the metadata header;
803
+ # add these here.
804
+ metadata = tuple(metadata) + (
805
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
806
+ )
807
+
808
+ # Validate the universe domain.
809
+ self._client._validate_universe_domain()
810
+
811
+ # Send the request.
812
+ response = await rpc(
813
+ request,
814
+ retry=retry,
815
+ timeout=timeout,
816
+ metadata=metadata,
817
+ )
818
+
819
+ # This method is paged; wrap the response in a pager, which provides
820
+ # an `__aiter__` convenience method.
821
+ response = pagers.ListAutoscalingPoliciesAsyncPager(
822
+ method=rpc,
823
+ request=request,
824
+ response=response,
825
+ retry=retry,
826
+ timeout=timeout,
827
+ metadata=metadata,
828
+ )
829
+
830
+ # Done; return the response.
831
+ return response
832
+
833
+ async def delete_autoscaling_policy(
834
+ self,
835
+ request: Optional[
836
+ Union[autoscaling_policies.DeleteAutoscalingPolicyRequest, dict]
837
+ ] = None,
838
+ *,
839
+ name: Optional[str] = None,
840
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
841
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
842
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
843
+ ) -> None:
844
+ r"""Deletes an autoscaling policy. It is an error to
845
+ delete an autoscaling policy that is in use by one or
846
+ more clusters.
847
+
848
+ .. code-block:: python
849
+
850
+ # This snippet has been automatically generated and should be regarded as a
851
+ # code template only.
852
+ # It will require modifications to work:
853
+ # - It may require correct/in-range values for request initialization.
854
+ # - It may require specifying regional endpoints when creating the service
855
+ # client as shown in:
856
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
857
+ from google.cloud import dataproc_v1
858
+
859
+ async def sample_delete_autoscaling_policy():
860
+ # Create a client
861
+ client = dataproc_v1.AutoscalingPolicyServiceAsyncClient()
862
+
863
+ # Initialize request argument(s)
864
+ request = dataproc_v1.DeleteAutoscalingPolicyRequest(
865
+ name="name_value",
866
+ )
867
+
868
+ # Make the request
869
+ await client.delete_autoscaling_policy(request=request)
870
+
871
+ Args:
872
+ request (Optional[Union[google.cloud.dataproc_v1.types.DeleteAutoscalingPolicyRequest, dict]]):
873
+ The request object. A request to delete an autoscaling
874
+ policy.
875
+ Autoscaling policies in use by one or
876
+ more clusters will not be deleted.
877
+ name (:class:`str`):
878
+ Required. The "resource name" of the autoscaling policy,
879
+ as described in
880
+ https://cloud.google.com/apis/design/resource_names.
881
+
882
+ - For ``projects.regions.autoscalingPolicies.delete``,
883
+ the resource name of the policy has the following
884
+ format:
885
+ ``projects/{project_id}/regions/{region}/autoscalingPolicies/{policy_id}``
886
+
887
+ - For
888
+ ``projects.locations.autoscalingPolicies.delete``,
889
+ the resource name of the policy has the following
890
+ format:
891
+ ``projects/{project_id}/locations/{location}/autoscalingPolicies/{policy_id}``
892
+
893
+ This corresponds to the ``name`` field
894
+ on the ``request`` instance; if ``request`` is provided, this
895
+ should not be set.
896
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
897
+ should be retried.
898
+ timeout (float): The timeout for this request.
899
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
900
+ sent along with the request as metadata. Normally, each value must be of type `str`,
901
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
902
+ be of type `bytes`.
903
+ """
904
+ # Create or coerce a protobuf request object.
905
+ # - Quick check: If we got a request object, we should *not* have
906
+ # gotten any keyword arguments that map to the request.
907
+ flattened_params = [name]
908
+ has_flattened_params = (
909
+ len([param for param in flattened_params if param is not None]) > 0
910
+ )
911
+ if request is not None and has_flattened_params:
912
+ raise ValueError(
913
+ "If the `request` argument is set, then none of "
914
+ "the individual field arguments should be set."
915
+ )
916
+
917
+ # - Use the request object if provided (there's no risk of modifying the input as
918
+ # there are no flattened fields), or create one.
919
+ if not isinstance(request, autoscaling_policies.DeleteAutoscalingPolicyRequest):
920
+ request = autoscaling_policies.DeleteAutoscalingPolicyRequest(request)
921
+
922
+ # If we have keyword arguments corresponding to fields on the
923
+ # request, apply these.
924
+ if name is not None:
925
+ request.name = name
926
+
927
+ # Wrap the RPC method; this adds retry and timeout information,
928
+ # and friendly error handling.
929
+ rpc = self._client._transport._wrapped_methods[
930
+ self._client._transport.delete_autoscaling_policy
931
+ ]
932
+
933
+ # Certain fields should be provided within the metadata header;
934
+ # add these here.
935
+ metadata = tuple(metadata) + (
936
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
937
+ )
938
+
939
+ # Validate the universe domain.
940
+ self._client._validate_universe_domain()
941
+
942
+ # Send the request.
943
+ await rpc(
944
+ request,
945
+ retry=retry,
946
+ timeout=timeout,
947
+ metadata=metadata,
948
+ )
949
+
950
+ async def list_operations(
951
+ self,
952
+ request: Optional[operations_pb2.ListOperationsRequest] = None,
953
+ *,
954
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
955
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
956
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
957
+ ) -> operations_pb2.ListOperationsResponse:
958
+ r"""Lists operations that match the specified filter in the request.
959
+
960
+ Args:
961
+ request (:class:`~.operations_pb2.ListOperationsRequest`):
962
+ The request object. Request message for
963
+ `ListOperations` method.
964
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
965
+ if any, should be retried.
966
+ timeout (float): The timeout for this request.
967
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
968
+ sent along with the request as metadata. Normally, each value must be of type `str`,
969
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
970
+ be of type `bytes`.
971
+ Returns:
972
+ ~.operations_pb2.ListOperationsResponse:
973
+ Response message for ``ListOperations`` method.
974
+ """
975
+ # Create or coerce a protobuf request object.
976
+ # The request isn't a proto-plus wrapped type,
977
+ # so it must be constructed via keyword expansion.
978
+ if isinstance(request, dict):
979
+ request = operations_pb2.ListOperationsRequest(**request)
980
+
981
+ # Wrap the RPC method; this adds retry and timeout information,
982
+ # and friendly error handling.
983
+ rpc = self.transport._wrapped_methods[self._client._transport.list_operations]
984
+
985
+ # Certain fields should be provided within the metadata header;
986
+ # add these here.
987
+ metadata = tuple(metadata) + (
988
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
989
+ )
990
+
991
+ # Validate the universe domain.
992
+ self._client._validate_universe_domain()
993
+
994
+ # Send the request.
995
+ response = await rpc(
996
+ request,
997
+ retry=retry,
998
+ timeout=timeout,
999
+ metadata=metadata,
1000
+ )
1001
+
1002
+ # Done; return the response.
1003
+ return response
1004
+
1005
+ async def get_operation(
1006
+ self,
1007
+ request: Optional[operations_pb2.GetOperationRequest] = None,
1008
+ *,
1009
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1010
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1011
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1012
+ ) -> operations_pb2.Operation:
1013
+ r"""Gets the latest state of a long-running operation.
1014
+
1015
+ Args:
1016
+ request (:class:`~.operations_pb2.GetOperationRequest`):
1017
+ The request object. Request message for
1018
+ `GetOperation` method.
1019
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1020
+ if any, should be retried.
1021
+ timeout (float): The timeout for this request.
1022
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1023
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1024
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1025
+ be of type `bytes`.
1026
+ Returns:
1027
+ ~.operations_pb2.Operation:
1028
+ An ``Operation`` object.
1029
+ """
1030
+ # Create or coerce a protobuf request object.
1031
+ # The request isn't a proto-plus wrapped type,
1032
+ # so it must be constructed via keyword expansion.
1033
+ if isinstance(request, dict):
1034
+ request = operations_pb2.GetOperationRequest(**request)
1035
+
1036
+ # Wrap the RPC method; this adds retry and timeout information,
1037
+ # and friendly error handling.
1038
+ rpc = self.transport._wrapped_methods[self._client._transport.get_operation]
1039
+
1040
+ # Certain fields should be provided within the metadata header;
1041
+ # add these here.
1042
+ metadata = tuple(metadata) + (
1043
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1044
+ )
1045
+
1046
+ # Validate the universe domain.
1047
+ self._client._validate_universe_domain()
1048
+
1049
+ # Send the request.
1050
+ response = await rpc(
1051
+ request,
1052
+ retry=retry,
1053
+ timeout=timeout,
1054
+ metadata=metadata,
1055
+ )
1056
+
1057
+ # Done; return the response.
1058
+ return response
1059
+
1060
+ async def delete_operation(
1061
+ self,
1062
+ request: Optional[operations_pb2.DeleteOperationRequest] = None,
1063
+ *,
1064
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1065
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1066
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1067
+ ) -> None:
1068
+ r"""Deletes a long-running operation.
1069
+
1070
+ This method indicates that the client is no longer interested
1071
+ in the operation result. It does not cancel the operation.
1072
+ If the server doesn't support this method, it returns
1073
+ `google.rpc.Code.UNIMPLEMENTED`.
1074
+
1075
+ Args:
1076
+ request (:class:`~.operations_pb2.DeleteOperationRequest`):
1077
+ The request object. Request message for
1078
+ `DeleteOperation` method.
1079
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1080
+ if any, should be retried.
1081
+ timeout (float): The timeout for this request.
1082
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1083
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1084
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1085
+ be of type `bytes`.
1086
+ Returns:
1087
+ None
1088
+ """
1089
+ # Create or coerce a protobuf request object.
1090
+ # The request isn't a proto-plus wrapped type,
1091
+ # so it must be constructed via keyword expansion.
1092
+ if isinstance(request, dict):
1093
+ request = operations_pb2.DeleteOperationRequest(**request)
1094
+
1095
+ # Wrap the RPC method; this adds retry and timeout information,
1096
+ # and friendly error handling.
1097
+ rpc = self.transport._wrapped_methods[self._client._transport.delete_operation]
1098
+
1099
+ # Certain fields should be provided within the metadata header;
1100
+ # add these here.
1101
+ metadata = tuple(metadata) + (
1102
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1103
+ )
1104
+
1105
+ # Validate the universe domain.
1106
+ self._client._validate_universe_domain()
1107
+
1108
+ # Send the request.
1109
+ await rpc(
1110
+ request,
1111
+ retry=retry,
1112
+ timeout=timeout,
1113
+ metadata=metadata,
1114
+ )
1115
+
1116
+ async def cancel_operation(
1117
+ self,
1118
+ request: Optional[operations_pb2.CancelOperationRequest] = None,
1119
+ *,
1120
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1121
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1122
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1123
+ ) -> None:
1124
+ r"""Starts asynchronous cancellation on a long-running operation.
1125
+
1126
+ The server makes a best effort to cancel the operation, but success
1127
+ is not guaranteed. If the server doesn't support this method, it returns
1128
+ `google.rpc.Code.UNIMPLEMENTED`.
1129
+
1130
+ Args:
1131
+ request (:class:`~.operations_pb2.CancelOperationRequest`):
1132
+ The request object. Request message for
1133
+ `CancelOperation` method.
1134
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1135
+ if any, should be retried.
1136
+ timeout (float): The timeout for this request.
1137
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1138
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1139
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1140
+ be of type `bytes`.
1141
+ Returns:
1142
+ None
1143
+ """
1144
+ # Create or coerce a protobuf request object.
1145
+ # The request isn't a proto-plus wrapped type,
1146
+ # so it must be constructed via keyword expansion.
1147
+ if isinstance(request, dict):
1148
+ request = operations_pb2.CancelOperationRequest(**request)
1149
+
1150
+ # Wrap the RPC method; this adds retry and timeout information,
1151
+ # and friendly error handling.
1152
+ rpc = self.transport._wrapped_methods[self._client._transport.cancel_operation]
1153
+
1154
+ # Certain fields should be provided within the metadata header;
1155
+ # add these here.
1156
+ metadata = tuple(metadata) + (
1157
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1158
+ )
1159
+
1160
+ # Validate the universe domain.
1161
+ self._client._validate_universe_domain()
1162
+
1163
+ # Send the request.
1164
+ await rpc(
1165
+ request,
1166
+ retry=retry,
1167
+ timeout=timeout,
1168
+ metadata=metadata,
1169
+ )
1170
+
1171
+ async def set_iam_policy(
1172
+ self,
1173
+ request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
1174
+ *,
1175
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1176
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1177
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1178
+ ) -> policy_pb2.Policy:
1179
+ r"""Sets the IAM access control policy on the specified function.
1180
+
1181
+ Replaces any existing policy.
1182
+
1183
+ Args:
1184
+ request (:class:`~.iam_policy_pb2.SetIamPolicyRequest`):
1185
+ The request object. Request message for `SetIamPolicy`
1186
+ method.
1187
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1188
+ should be retried.
1189
+ timeout (float): The timeout for this request.
1190
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1191
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1192
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1193
+ be of type `bytes`.
1194
+ Returns:
1195
+ ~.policy_pb2.Policy:
1196
+ Defines an Identity and Access Management (IAM) policy.
1197
+ It is used to specify access control policies for Cloud
1198
+ Platform resources.
1199
+ A ``Policy`` is a collection of ``bindings``. A
1200
+ ``binding`` binds one or more ``members`` to a single
1201
+ ``role``. Members can be user accounts, service
1202
+ accounts, Google groups, and domains (such as G Suite).
1203
+ A ``role`` is a named list of permissions (defined by
1204
+ IAM or configured by users). A ``binding`` can
1205
+ optionally specify a ``condition``, which is a logic
1206
+ expression that further constrains the role binding
1207
+ based on attributes about the request and/or target
1208
+ resource.
1209
+
1210
+ **JSON Example**
1211
+
1212
+ ::
1213
+
1214
+ {
1215
+ "bindings": [
1216
+ {
1217
+ "role": "roles/resourcemanager.organizationAdmin",
1218
+ "members": [
1219
+ "user:mike@example.com",
1220
+ "group:admins@example.com",
1221
+ "domain:google.com",
1222
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
1223
+ ]
1224
+ },
1225
+ {
1226
+ "role": "roles/resourcemanager.organizationViewer",
1227
+ "members": ["user:eve@example.com"],
1228
+ "condition": {
1229
+ "title": "expirable access",
1230
+ "description": "Does not grant access after Sep 2020",
1231
+ "expression": "request.time <
1232
+ timestamp('2020-10-01T00:00:00.000Z')",
1233
+ }
1234
+ }
1235
+ ]
1236
+ }
1237
+
1238
+ **YAML Example**
1239
+
1240
+ ::
1241
+
1242
+ bindings:
1243
+ - members:
1244
+ - user:mike@example.com
1245
+ - group:admins@example.com
1246
+ - domain:google.com
1247
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
1248
+ role: roles/resourcemanager.organizationAdmin
1249
+ - members:
1250
+ - user:eve@example.com
1251
+ role: roles/resourcemanager.organizationViewer
1252
+ condition:
1253
+ title: expirable access
1254
+ description: Does not grant access after Sep 2020
1255
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
1256
+
1257
+ For a description of IAM and its features, see the `IAM
1258
+ developer's
1259
+ guide <https://cloud.google.com/iam/docs>`__.
1260
+ """
1261
+ # Create or coerce a protobuf request object.
1262
+
1263
+ # The request isn't a proto-plus wrapped type,
1264
+ # so it must be constructed via keyword expansion.
1265
+ if isinstance(request, dict):
1266
+ request = iam_policy_pb2.SetIamPolicyRequest(**request)
1267
+
1268
+ # Wrap the RPC method; this adds retry and timeout information,
1269
+ # and friendly error handling.
1270
+ rpc = self.transport._wrapped_methods[self._client._transport.set_iam_policy]
1271
+
1272
+ # Certain fields should be provided within the metadata header;
1273
+ # add these here.
1274
+ metadata = tuple(metadata) + (
1275
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1276
+ )
1277
+
1278
+ # Validate the universe domain.
1279
+ self._client._validate_universe_domain()
1280
+
1281
+ # Send the request.
1282
+ response = await rpc(
1283
+ request,
1284
+ retry=retry,
1285
+ timeout=timeout,
1286
+ metadata=metadata,
1287
+ )
1288
+
1289
+ # Done; return the response.
1290
+ return response
1291
+
1292
+ async def get_iam_policy(
1293
+ self,
1294
+ request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
1295
+ *,
1296
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1297
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1298
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1299
+ ) -> policy_pb2.Policy:
1300
+ r"""Gets the IAM access control policy for a function.
1301
+
1302
+ Returns an empty policy if the function exists and does not have a
1303
+ policy set.
1304
+
1305
+ Args:
1306
+ request (:class:`~.iam_policy_pb2.GetIamPolicyRequest`):
1307
+ The request object. Request message for `GetIamPolicy`
1308
+ method.
1309
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if
1310
+ any, should be retried.
1311
+ timeout (float): The timeout for this request.
1312
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1313
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1314
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1315
+ be of type `bytes`.
1316
+ Returns:
1317
+ ~.policy_pb2.Policy:
1318
+ Defines an Identity and Access Management (IAM) policy.
1319
+ It is used to specify access control policies for Cloud
1320
+ Platform resources.
1321
+ A ``Policy`` is a collection of ``bindings``. A
1322
+ ``binding`` binds one or more ``members`` to a single
1323
+ ``role``. Members can be user accounts, service
1324
+ accounts, Google groups, and domains (such as G Suite).
1325
+ A ``role`` is a named list of permissions (defined by
1326
+ IAM or configured by users). A ``binding`` can
1327
+ optionally specify a ``condition``, which is a logic
1328
+ expression that further constrains the role binding
1329
+ based on attributes about the request and/or target
1330
+ resource.
1331
+
1332
+ **JSON Example**
1333
+
1334
+ ::
1335
+
1336
+ {
1337
+ "bindings": [
1338
+ {
1339
+ "role": "roles/resourcemanager.organizationAdmin",
1340
+ "members": [
1341
+ "user:mike@example.com",
1342
+ "group:admins@example.com",
1343
+ "domain:google.com",
1344
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
1345
+ ]
1346
+ },
1347
+ {
1348
+ "role": "roles/resourcemanager.organizationViewer",
1349
+ "members": ["user:eve@example.com"],
1350
+ "condition": {
1351
+ "title": "expirable access",
1352
+ "description": "Does not grant access after Sep 2020",
1353
+ "expression": "request.time <
1354
+ timestamp('2020-10-01T00:00:00.000Z')",
1355
+ }
1356
+ }
1357
+ ]
1358
+ }
1359
+
1360
+ **YAML Example**
1361
+
1362
+ ::
1363
+
1364
+ bindings:
1365
+ - members:
1366
+ - user:mike@example.com
1367
+ - group:admins@example.com
1368
+ - domain:google.com
1369
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
1370
+ role: roles/resourcemanager.organizationAdmin
1371
+ - members:
1372
+ - user:eve@example.com
1373
+ role: roles/resourcemanager.organizationViewer
1374
+ condition:
1375
+ title: expirable access
1376
+ description: Does not grant access after Sep 2020
1377
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
1378
+
1379
+ For a description of IAM and its features, see the `IAM
1380
+ developer's
1381
+ guide <https://cloud.google.com/iam/docs>`__.
1382
+ """
1383
+ # Create or coerce a protobuf request object.
1384
+
1385
+ # The request isn't a proto-plus wrapped type,
1386
+ # so it must be constructed via keyword expansion.
1387
+ if isinstance(request, dict):
1388
+ request = iam_policy_pb2.GetIamPolicyRequest(**request)
1389
+
1390
+ # Wrap the RPC method; this adds retry and timeout information,
1391
+ # and friendly error handling.
1392
+ rpc = self.transport._wrapped_methods[self._client._transport.get_iam_policy]
1393
+
1394
+ # Certain fields should be provided within the metadata header;
1395
+ # add these here.
1396
+ metadata = tuple(metadata) + (
1397
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1398
+ )
1399
+
1400
+ # Validate the universe domain.
1401
+ self._client._validate_universe_domain()
1402
+
1403
+ # Send the request.
1404
+ response = await rpc(
1405
+ request,
1406
+ retry=retry,
1407
+ timeout=timeout,
1408
+ metadata=metadata,
1409
+ )
1410
+
1411
+ # Done; return the response.
1412
+ return response
1413
+
1414
+ async def test_iam_permissions(
1415
+ self,
1416
+ request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
1417
+ *,
1418
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1419
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1420
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1421
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
1422
+ r"""Tests the specified IAM permissions against the IAM access control
1423
+ policy for a function.
1424
+
1425
+ If the function does not exist, this will return an empty set
1426
+ of permissions, not a NOT_FOUND error.
1427
+
1428
+ Args:
1429
+ request (:class:`~.iam_policy_pb2.TestIamPermissionsRequest`):
1430
+ The request object. Request message for
1431
+ `TestIamPermissions` method.
1432
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1433
+ if any, should be retried.
1434
+ timeout (float): The timeout for this request.
1435
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1436
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1437
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1438
+ be of type `bytes`.
1439
+ Returns:
1440
+ ~.iam_policy_pb2.TestIamPermissionsResponse:
1441
+ Response message for ``TestIamPermissions`` method.
1442
+ """
1443
+ # Create or coerce a protobuf request object.
1444
+
1445
+ # The request isn't a proto-plus wrapped type,
1446
+ # so it must be constructed via keyword expansion.
1447
+ if isinstance(request, dict):
1448
+ request = iam_policy_pb2.TestIamPermissionsRequest(**request)
1449
+
1450
+ # Wrap the RPC method; this adds retry and timeout information,
1451
+ # and friendly error handling.
1452
+ rpc = self.transport._wrapped_methods[
1453
+ self._client._transport.test_iam_permissions
1454
+ ]
1455
+
1456
+ # Certain fields should be provided within the metadata header;
1457
+ # add these here.
1458
+ metadata = tuple(metadata) + (
1459
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1460
+ )
1461
+
1462
+ # Validate the universe domain.
1463
+ self._client._validate_universe_domain()
1464
+
1465
+ # Send the request.
1466
+ response = await rpc(
1467
+ request,
1468
+ retry=retry,
1469
+ timeout=timeout,
1470
+ metadata=metadata,
1471
+ )
1472
+
1473
+ # Done; return the response.
1474
+ return response
1475
+
1476
+ async def __aenter__(self) -> "AutoscalingPolicyServiceAsyncClient":
1477
+ return self
1478
+
1479
+ async def __aexit__(self, exc_type, exc, tb):
1480
+ await self.transport.close()
1481
+
1482
+
1483
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1484
+ gapic_version=package_version.__version__
1485
+ )
1486
+
1487
+
1488
+ __all__ = ("AutoscalingPolicyServiceAsyncClient",)