google-cloud-maintenance-api 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/cloud/maintenance_api/__init__.py +51 -0
- google/cloud/maintenance_api/gapic_version.py +16 -0
- google/cloud/maintenance_api/py.typed +2 -0
- google/cloud/maintenance_api_v1beta/__init__.py +46 -0
- google/cloud/maintenance_api_v1beta/gapic_metadata.json +73 -0
- google/cloud/maintenance_api_v1beta/gapic_version.py +16 -0
- google/cloud/maintenance_api_v1beta/py.typed +2 -0
- google/cloud/maintenance_api_v1beta/services/__init__.py +15 -0
- google/cloud/maintenance_api_v1beta/services/maintenance/__init__.py +22 -0
- google/cloud/maintenance_api_v1beta/services/maintenance/async_client.py +786 -0
- google/cloud/maintenance_api_v1beta/services/maintenance/client.py +1211 -0
- google/cloud/maintenance_api_v1beta/services/maintenance/pagers.py +361 -0
- google/cloud/maintenance_api_v1beta/services/maintenance/transports/__init__.py +36 -0
- google/cloud/maintenance_api_v1beta/services/maintenance/transports/base.py +234 -0
- google/cloud/maintenance_api_v1beta/services/maintenance/transports/grpc.py +456 -0
- google/cloud/maintenance_api_v1beta/services/maintenance/transports/grpc_asyncio.py +499 -0
- google/cloud/maintenance_api_v1beta/services/maintenance/transports/rest.py +1182 -0
- google/cloud/maintenance_api_v1beta/services/maintenance/transports/rest_base.py +283 -0
- google/cloud/maintenance_api_v1beta/types/__init__.py +38 -0
- google/cloud/maintenance_api_v1beta/types/maintenance_service.py +713 -0
- google_cloud_maintenance_api-0.1.0.dist-info/METADATA +239 -0
- google_cloud_maintenance_api-0.1.0.dist-info/RECORD +25 -0
- google_cloud_maintenance_api-0.1.0.dist-info/WHEEL +5 -0
- google_cloud_maintenance_api-0.1.0.dist-info/licenses/LICENSE +202 -0
- google_cloud_maintenance_api-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2025 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
|
+
import google.protobuf
|
|
39
|
+
|
|
40
|
+
from google.cloud.maintenance_api_v1beta import gapic_version as package_version
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
|
|
44
|
+
except AttributeError: # pragma: NO COVER
|
|
45
|
+
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
|
|
46
|
+
|
|
47
|
+
from google.cloud.location import locations_pb2 # type: ignore
|
|
48
|
+
from google.protobuf import timestamp_pb2 # type: ignore
|
|
49
|
+
|
|
50
|
+
from google.cloud.maintenance_api_v1beta.services.maintenance import pagers
|
|
51
|
+
from google.cloud.maintenance_api_v1beta.types import maintenance_service
|
|
52
|
+
|
|
53
|
+
from .client import MaintenanceClient
|
|
54
|
+
from .transports.base import DEFAULT_CLIENT_INFO, MaintenanceTransport
|
|
55
|
+
from .transports.grpc_asyncio import MaintenanceGrpcAsyncIOTransport
|
|
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 MaintenanceAsyncClient:
|
|
68
|
+
"""Unified Maintenance service"""
|
|
69
|
+
|
|
70
|
+
_client: MaintenanceClient
|
|
71
|
+
|
|
72
|
+
# Copy defaults from the synchronous client for use here.
|
|
73
|
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
|
74
|
+
DEFAULT_ENDPOINT = MaintenanceClient.DEFAULT_ENDPOINT
|
|
75
|
+
DEFAULT_MTLS_ENDPOINT = MaintenanceClient.DEFAULT_MTLS_ENDPOINT
|
|
76
|
+
_DEFAULT_ENDPOINT_TEMPLATE = MaintenanceClient._DEFAULT_ENDPOINT_TEMPLATE
|
|
77
|
+
_DEFAULT_UNIVERSE = MaintenanceClient._DEFAULT_UNIVERSE
|
|
78
|
+
|
|
79
|
+
resource_maintenance_path = staticmethod(
|
|
80
|
+
MaintenanceClient.resource_maintenance_path
|
|
81
|
+
)
|
|
82
|
+
parse_resource_maintenance_path = staticmethod(
|
|
83
|
+
MaintenanceClient.parse_resource_maintenance_path
|
|
84
|
+
)
|
|
85
|
+
common_billing_account_path = staticmethod(
|
|
86
|
+
MaintenanceClient.common_billing_account_path
|
|
87
|
+
)
|
|
88
|
+
parse_common_billing_account_path = staticmethod(
|
|
89
|
+
MaintenanceClient.parse_common_billing_account_path
|
|
90
|
+
)
|
|
91
|
+
common_folder_path = staticmethod(MaintenanceClient.common_folder_path)
|
|
92
|
+
parse_common_folder_path = staticmethod(MaintenanceClient.parse_common_folder_path)
|
|
93
|
+
common_organization_path = staticmethod(MaintenanceClient.common_organization_path)
|
|
94
|
+
parse_common_organization_path = staticmethod(
|
|
95
|
+
MaintenanceClient.parse_common_organization_path
|
|
96
|
+
)
|
|
97
|
+
common_project_path = staticmethod(MaintenanceClient.common_project_path)
|
|
98
|
+
parse_common_project_path = staticmethod(
|
|
99
|
+
MaintenanceClient.parse_common_project_path
|
|
100
|
+
)
|
|
101
|
+
common_location_path = staticmethod(MaintenanceClient.common_location_path)
|
|
102
|
+
parse_common_location_path = staticmethod(
|
|
103
|
+
MaintenanceClient.parse_common_location_path
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
@classmethod
|
|
107
|
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
|
108
|
+
"""Creates an instance of this client using the provided credentials
|
|
109
|
+
info.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
info (dict): The service account private key info.
|
|
113
|
+
args: Additional arguments to pass to the constructor.
|
|
114
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
115
|
+
|
|
116
|
+
Returns:
|
|
117
|
+
MaintenanceAsyncClient: The constructed client.
|
|
118
|
+
"""
|
|
119
|
+
return MaintenanceClient.from_service_account_info.__func__(MaintenanceAsyncClient, info, *args, **kwargs) # type: ignore
|
|
120
|
+
|
|
121
|
+
@classmethod
|
|
122
|
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
|
123
|
+
"""Creates an instance of this client using the provided credentials
|
|
124
|
+
file.
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
filename (str): The path to the service account private key json
|
|
128
|
+
file.
|
|
129
|
+
args: Additional arguments to pass to the constructor.
|
|
130
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
MaintenanceAsyncClient: The constructed client.
|
|
134
|
+
"""
|
|
135
|
+
return MaintenanceClient.from_service_account_file.__func__(MaintenanceAsyncClient, filename, *args, **kwargs) # type: ignore
|
|
136
|
+
|
|
137
|
+
from_service_account_json = from_service_account_file
|
|
138
|
+
|
|
139
|
+
@classmethod
|
|
140
|
+
def get_mtls_endpoint_and_cert_source(
|
|
141
|
+
cls, client_options: Optional[ClientOptions] = None
|
|
142
|
+
):
|
|
143
|
+
"""Return the API endpoint and client cert source for mutual TLS.
|
|
144
|
+
|
|
145
|
+
The client cert source is determined in the following order:
|
|
146
|
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
|
147
|
+
client cert source is None.
|
|
148
|
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
|
149
|
+
default client cert source exists, use the default one; otherwise the client cert
|
|
150
|
+
source is None.
|
|
151
|
+
|
|
152
|
+
The API endpoint is determined in the following order:
|
|
153
|
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
|
154
|
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
|
155
|
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
|
156
|
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
|
157
|
+
use the default API endpoint.
|
|
158
|
+
|
|
159
|
+
More details can be found at https://google.aip.dev/auth/4114.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
|
163
|
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
|
164
|
+
in this method.
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
|
168
|
+
client cert source to use.
|
|
169
|
+
|
|
170
|
+
Raises:
|
|
171
|
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
|
172
|
+
"""
|
|
173
|
+
return MaintenanceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
|
|
174
|
+
|
|
175
|
+
@property
|
|
176
|
+
def transport(self) -> MaintenanceTransport:
|
|
177
|
+
"""Returns the transport used by the client instance.
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
MaintenanceTransport: The transport used by the client instance.
|
|
181
|
+
"""
|
|
182
|
+
return self._client.transport
|
|
183
|
+
|
|
184
|
+
@property
|
|
185
|
+
def api_endpoint(self):
|
|
186
|
+
"""Return the API endpoint used by the client instance.
|
|
187
|
+
|
|
188
|
+
Returns:
|
|
189
|
+
str: The API endpoint used by the client instance.
|
|
190
|
+
"""
|
|
191
|
+
return self._client._api_endpoint
|
|
192
|
+
|
|
193
|
+
@property
|
|
194
|
+
def universe_domain(self) -> str:
|
|
195
|
+
"""Return the universe domain used by the client instance.
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
str: The universe domain used
|
|
199
|
+
by the client instance.
|
|
200
|
+
"""
|
|
201
|
+
return self._client._universe_domain
|
|
202
|
+
|
|
203
|
+
get_transport_class = MaintenanceClient.get_transport_class
|
|
204
|
+
|
|
205
|
+
def __init__(
|
|
206
|
+
self,
|
|
207
|
+
*,
|
|
208
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
209
|
+
transport: Optional[
|
|
210
|
+
Union[str, MaintenanceTransport, Callable[..., MaintenanceTransport]]
|
|
211
|
+
] = "grpc_asyncio",
|
|
212
|
+
client_options: Optional[ClientOptions] = None,
|
|
213
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
214
|
+
) -> None:
|
|
215
|
+
"""Instantiates the maintenance async client.
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
219
|
+
authorization credentials to attach to requests. These
|
|
220
|
+
credentials identify the application to the service; if none
|
|
221
|
+
are specified, the client will attempt to ascertain the
|
|
222
|
+
credentials from the environment.
|
|
223
|
+
transport (Optional[Union[str,MaintenanceTransport,Callable[..., MaintenanceTransport]]]):
|
|
224
|
+
The transport to use, or a Callable that constructs and returns a new transport to use.
|
|
225
|
+
If a Callable is given, it will be called with the same set of initialization
|
|
226
|
+
arguments as used in the MaintenanceTransport constructor.
|
|
227
|
+
If set to None, a transport is chosen automatically.
|
|
228
|
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
|
229
|
+
Custom options for the client.
|
|
230
|
+
|
|
231
|
+
1. The ``api_endpoint`` property can be used to override the
|
|
232
|
+
default endpoint provided by the client when ``transport`` is
|
|
233
|
+
not explicitly provided. Only if this property is not set and
|
|
234
|
+
``transport`` was not explicitly provided, the endpoint is
|
|
235
|
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
|
236
|
+
variable, which have one of the following values:
|
|
237
|
+
"always" (always use the default mTLS endpoint), "never" (always
|
|
238
|
+
use the default regular endpoint) and "auto" (auto-switch to the
|
|
239
|
+
default mTLS endpoint if client certificate is present; this is
|
|
240
|
+
the default value).
|
|
241
|
+
|
|
242
|
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
|
243
|
+
is "true", then the ``client_cert_source`` property can be used
|
|
244
|
+
to provide a client certificate for mTLS transport. If
|
|
245
|
+
not provided, the default SSL client certificate will be used if
|
|
246
|
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
|
247
|
+
set, no client certificate will be used.
|
|
248
|
+
|
|
249
|
+
3. The ``universe_domain`` property can be used to override the
|
|
250
|
+
default "googleapis.com" universe. Note that ``api_endpoint``
|
|
251
|
+
property still takes precedence; and ``universe_domain`` is
|
|
252
|
+
currently not supported for mTLS.
|
|
253
|
+
|
|
254
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
255
|
+
The client info used to send a user-agent string along with
|
|
256
|
+
API requests. If ``None``, then default info will be used.
|
|
257
|
+
Generally, you only need to set this if you're developing
|
|
258
|
+
your own client library.
|
|
259
|
+
|
|
260
|
+
Raises:
|
|
261
|
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
|
262
|
+
creation failed for any reason.
|
|
263
|
+
"""
|
|
264
|
+
self._client = MaintenanceClient(
|
|
265
|
+
credentials=credentials,
|
|
266
|
+
transport=transport,
|
|
267
|
+
client_options=client_options,
|
|
268
|
+
client_info=client_info,
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
272
|
+
std_logging.DEBUG
|
|
273
|
+
): # pragma: NO COVER
|
|
274
|
+
_LOGGER.debug(
|
|
275
|
+
"Created client `google.cloud.maintenance.api_v1beta.MaintenanceAsyncClient`.",
|
|
276
|
+
extra={
|
|
277
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
278
|
+
"universeDomain": getattr(
|
|
279
|
+
self._client._transport._credentials, "universe_domain", ""
|
|
280
|
+
),
|
|
281
|
+
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
|
|
282
|
+
"credentialsInfo": getattr(
|
|
283
|
+
self.transport._credentials, "get_cred_info", lambda: None
|
|
284
|
+
)(),
|
|
285
|
+
}
|
|
286
|
+
if hasattr(self._client._transport, "_credentials")
|
|
287
|
+
else {
|
|
288
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
289
|
+
"credentialsType": None,
|
|
290
|
+
},
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
async def summarize_maintenances(
|
|
294
|
+
self,
|
|
295
|
+
request: Optional[
|
|
296
|
+
Union[maintenance_service.SummarizeMaintenancesRequest, dict]
|
|
297
|
+
] = None,
|
|
298
|
+
*,
|
|
299
|
+
parent: Optional[str] = None,
|
|
300
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
301
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
302
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
303
|
+
) -> pagers.SummarizeMaintenancesAsyncPager:
|
|
304
|
+
r"""Retrieves the statistics of a specific maintenance.
|
|
305
|
+
|
|
306
|
+
.. code-block:: python
|
|
307
|
+
|
|
308
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
309
|
+
# code template only.
|
|
310
|
+
# It will require modifications to work:
|
|
311
|
+
# - It may require correct/in-range values for request initialization.
|
|
312
|
+
# - It may require specifying regional endpoints when creating the service
|
|
313
|
+
# client as shown in:
|
|
314
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
315
|
+
from google.cloud import maintenance_api_v1beta
|
|
316
|
+
|
|
317
|
+
async def sample_summarize_maintenances():
|
|
318
|
+
# Create a client
|
|
319
|
+
client = maintenance_api_v1beta.MaintenanceAsyncClient()
|
|
320
|
+
|
|
321
|
+
# Initialize request argument(s)
|
|
322
|
+
request = maintenance_api_v1beta.SummarizeMaintenancesRequest(
|
|
323
|
+
parent="parent_value",
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
# Make the request
|
|
327
|
+
page_result = client.summarize_maintenances(request=request)
|
|
328
|
+
|
|
329
|
+
# Handle the response
|
|
330
|
+
async for response in page_result:
|
|
331
|
+
print(response)
|
|
332
|
+
|
|
333
|
+
Args:
|
|
334
|
+
request (Optional[Union[google.cloud.maintenance_api_v1beta.types.SummarizeMaintenancesRequest, dict]]):
|
|
335
|
+
The request object. Request message for
|
|
336
|
+
SummarizeMaintenances custom method.
|
|
337
|
+
parent (:class:`str`):
|
|
338
|
+
Required. The parent of the resource maintenance. eg.
|
|
339
|
+
``projects/123/locations/*``
|
|
340
|
+
|
|
341
|
+
This corresponds to the ``parent`` field
|
|
342
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
343
|
+
should not be set.
|
|
344
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
345
|
+
should be retried.
|
|
346
|
+
timeout (float): The timeout for this request.
|
|
347
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
348
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
349
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
350
|
+
be of type `bytes`.
|
|
351
|
+
|
|
352
|
+
Returns:
|
|
353
|
+
google.cloud.maintenance_api_v1beta.services.maintenance.pagers.SummarizeMaintenancesAsyncPager:
|
|
354
|
+
Iterating over this object will yield
|
|
355
|
+
results and resolve additional pages
|
|
356
|
+
automatically.
|
|
357
|
+
|
|
358
|
+
"""
|
|
359
|
+
# Create or coerce a protobuf request object.
|
|
360
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
361
|
+
# gotten any keyword arguments that map to the request.
|
|
362
|
+
flattened_params = [parent]
|
|
363
|
+
has_flattened_params = (
|
|
364
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
365
|
+
)
|
|
366
|
+
if request is not None and has_flattened_params:
|
|
367
|
+
raise ValueError(
|
|
368
|
+
"If the `request` argument is set, then none of "
|
|
369
|
+
"the individual field arguments should be set."
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
373
|
+
# there are no flattened fields), or create one.
|
|
374
|
+
if not isinstance(request, maintenance_service.SummarizeMaintenancesRequest):
|
|
375
|
+
request = maintenance_service.SummarizeMaintenancesRequest(request)
|
|
376
|
+
|
|
377
|
+
# If we have keyword arguments corresponding to fields on the
|
|
378
|
+
# request, apply these.
|
|
379
|
+
if parent is not None:
|
|
380
|
+
request.parent = parent
|
|
381
|
+
|
|
382
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
383
|
+
# and friendly error handling.
|
|
384
|
+
rpc = self._client._transport._wrapped_methods[
|
|
385
|
+
self._client._transport.summarize_maintenances
|
|
386
|
+
]
|
|
387
|
+
|
|
388
|
+
# Certain fields should be provided within the metadata header;
|
|
389
|
+
# add these here.
|
|
390
|
+
metadata = tuple(metadata) + (
|
|
391
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
# Validate the universe domain.
|
|
395
|
+
self._client._validate_universe_domain()
|
|
396
|
+
|
|
397
|
+
# Send the request.
|
|
398
|
+
response = await rpc(
|
|
399
|
+
request,
|
|
400
|
+
retry=retry,
|
|
401
|
+
timeout=timeout,
|
|
402
|
+
metadata=metadata,
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
406
|
+
# an `__aiter__` convenience method.
|
|
407
|
+
response = pagers.SummarizeMaintenancesAsyncPager(
|
|
408
|
+
method=rpc,
|
|
409
|
+
request=request,
|
|
410
|
+
response=response,
|
|
411
|
+
retry=retry,
|
|
412
|
+
timeout=timeout,
|
|
413
|
+
metadata=metadata,
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
# Done; return the response.
|
|
417
|
+
return response
|
|
418
|
+
|
|
419
|
+
async def list_resource_maintenances(
|
|
420
|
+
self,
|
|
421
|
+
request: Optional[
|
|
422
|
+
Union[maintenance_service.ListResourceMaintenancesRequest, dict]
|
|
423
|
+
] = None,
|
|
424
|
+
*,
|
|
425
|
+
parent: Optional[str] = None,
|
|
426
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
427
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
428
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
429
|
+
) -> pagers.ListResourceMaintenancesAsyncPager:
|
|
430
|
+
r"""Retrieve a collection of resource maintenances.
|
|
431
|
+
|
|
432
|
+
.. code-block:: python
|
|
433
|
+
|
|
434
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
435
|
+
# code template only.
|
|
436
|
+
# It will require modifications to work:
|
|
437
|
+
# - It may require correct/in-range values for request initialization.
|
|
438
|
+
# - It may require specifying regional endpoints when creating the service
|
|
439
|
+
# client as shown in:
|
|
440
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
441
|
+
from google.cloud import maintenance_api_v1beta
|
|
442
|
+
|
|
443
|
+
async def sample_list_resource_maintenances():
|
|
444
|
+
# Create a client
|
|
445
|
+
client = maintenance_api_v1beta.MaintenanceAsyncClient()
|
|
446
|
+
|
|
447
|
+
# Initialize request argument(s)
|
|
448
|
+
request = maintenance_api_v1beta.ListResourceMaintenancesRequest(
|
|
449
|
+
parent="parent_value",
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
# Make the request
|
|
453
|
+
page_result = client.list_resource_maintenances(request=request)
|
|
454
|
+
|
|
455
|
+
# Handle the response
|
|
456
|
+
async for response in page_result:
|
|
457
|
+
print(response)
|
|
458
|
+
|
|
459
|
+
Args:
|
|
460
|
+
request (Optional[Union[google.cloud.maintenance_api_v1beta.types.ListResourceMaintenancesRequest, dict]]):
|
|
461
|
+
The request object. The request structure for the
|
|
462
|
+
ListResourceMaintenances method.
|
|
463
|
+
parent (:class:`str`):
|
|
464
|
+
Required. The parent of the resource
|
|
465
|
+
maintenance.
|
|
466
|
+
|
|
467
|
+
This corresponds to the ``parent`` field
|
|
468
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
469
|
+
should not be set.
|
|
470
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
471
|
+
should be retried.
|
|
472
|
+
timeout (float): The timeout for this request.
|
|
473
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
474
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
475
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
476
|
+
be of type `bytes`.
|
|
477
|
+
|
|
478
|
+
Returns:
|
|
479
|
+
google.cloud.maintenance_api_v1beta.services.maintenance.pagers.ListResourceMaintenancesAsyncPager:
|
|
480
|
+
The response structure for the
|
|
481
|
+
ListResourceMaintenances method.
|
|
482
|
+
Iterating over this object will yield
|
|
483
|
+
results and resolve additional pages
|
|
484
|
+
automatically.
|
|
485
|
+
|
|
486
|
+
"""
|
|
487
|
+
# Create or coerce a protobuf request object.
|
|
488
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
489
|
+
# gotten any keyword arguments that map to the request.
|
|
490
|
+
flattened_params = [parent]
|
|
491
|
+
has_flattened_params = (
|
|
492
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
493
|
+
)
|
|
494
|
+
if request is not None and has_flattened_params:
|
|
495
|
+
raise ValueError(
|
|
496
|
+
"If the `request` argument is set, then none of "
|
|
497
|
+
"the individual field arguments should be set."
|
|
498
|
+
)
|
|
499
|
+
|
|
500
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
501
|
+
# there are no flattened fields), or create one.
|
|
502
|
+
if not isinstance(request, maintenance_service.ListResourceMaintenancesRequest):
|
|
503
|
+
request = maintenance_service.ListResourceMaintenancesRequest(request)
|
|
504
|
+
|
|
505
|
+
# If we have keyword arguments corresponding to fields on the
|
|
506
|
+
# request, apply these.
|
|
507
|
+
if parent is not None:
|
|
508
|
+
request.parent = parent
|
|
509
|
+
|
|
510
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
511
|
+
# and friendly error handling.
|
|
512
|
+
rpc = self._client._transport._wrapped_methods[
|
|
513
|
+
self._client._transport.list_resource_maintenances
|
|
514
|
+
]
|
|
515
|
+
|
|
516
|
+
# Certain fields should be provided within the metadata header;
|
|
517
|
+
# add these here.
|
|
518
|
+
metadata = tuple(metadata) + (
|
|
519
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
# Validate the universe domain.
|
|
523
|
+
self._client._validate_universe_domain()
|
|
524
|
+
|
|
525
|
+
# Send the request.
|
|
526
|
+
response = await rpc(
|
|
527
|
+
request,
|
|
528
|
+
retry=retry,
|
|
529
|
+
timeout=timeout,
|
|
530
|
+
metadata=metadata,
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
534
|
+
# an `__aiter__` convenience method.
|
|
535
|
+
response = pagers.ListResourceMaintenancesAsyncPager(
|
|
536
|
+
method=rpc,
|
|
537
|
+
request=request,
|
|
538
|
+
response=response,
|
|
539
|
+
retry=retry,
|
|
540
|
+
timeout=timeout,
|
|
541
|
+
metadata=metadata,
|
|
542
|
+
)
|
|
543
|
+
|
|
544
|
+
# Done; return the response.
|
|
545
|
+
return response
|
|
546
|
+
|
|
547
|
+
async def get_resource_maintenance(
|
|
548
|
+
self,
|
|
549
|
+
request: Optional[
|
|
550
|
+
Union[maintenance_service.GetResourceMaintenanceRequest, dict]
|
|
551
|
+
] = None,
|
|
552
|
+
*,
|
|
553
|
+
name: Optional[str] = None,
|
|
554
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
555
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
556
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
557
|
+
) -> maintenance_service.ResourceMaintenance:
|
|
558
|
+
r"""Retrieve a single resource maintenance.
|
|
559
|
+
|
|
560
|
+
.. code-block:: python
|
|
561
|
+
|
|
562
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
563
|
+
# code template only.
|
|
564
|
+
# It will require modifications to work:
|
|
565
|
+
# - It may require correct/in-range values for request initialization.
|
|
566
|
+
# - It may require specifying regional endpoints when creating the service
|
|
567
|
+
# client as shown in:
|
|
568
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
569
|
+
from google.cloud import maintenance_api_v1beta
|
|
570
|
+
|
|
571
|
+
async def sample_get_resource_maintenance():
|
|
572
|
+
# Create a client
|
|
573
|
+
client = maintenance_api_v1beta.MaintenanceAsyncClient()
|
|
574
|
+
|
|
575
|
+
# Initialize request argument(s)
|
|
576
|
+
request = maintenance_api_v1beta.GetResourceMaintenanceRequest(
|
|
577
|
+
name="name_value",
|
|
578
|
+
)
|
|
579
|
+
|
|
580
|
+
# Make the request
|
|
581
|
+
response = await client.get_resource_maintenance(request=request)
|
|
582
|
+
|
|
583
|
+
# Handle the response
|
|
584
|
+
print(response)
|
|
585
|
+
|
|
586
|
+
Args:
|
|
587
|
+
request (Optional[Union[google.cloud.maintenance_api_v1beta.types.GetResourceMaintenanceRequest, dict]]):
|
|
588
|
+
The request object. The request structure for the
|
|
589
|
+
GetResourceMaintenance method.
|
|
590
|
+
name (:class:`str`):
|
|
591
|
+
Required. The resource name of the
|
|
592
|
+
resource within a service.
|
|
593
|
+
|
|
594
|
+
This corresponds to the ``name`` field
|
|
595
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
596
|
+
should not be set.
|
|
597
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
598
|
+
should be retried.
|
|
599
|
+
timeout (float): The timeout for this request.
|
|
600
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
601
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
602
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
603
|
+
be of type `bytes`.
|
|
604
|
+
|
|
605
|
+
Returns:
|
|
606
|
+
google.cloud.maintenance_api_v1beta.types.ResourceMaintenance:
|
|
607
|
+
ResourceMaintenance is a resource
|
|
608
|
+
that represents a maintenance operation
|
|
609
|
+
on a resource.
|
|
610
|
+
|
|
611
|
+
"""
|
|
612
|
+
# Create or coerce a protobuf request object.
|
|
613
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
614
|
+
# gotten any keyword arguments that map to the request.
|
|
615
|
+
flattened_params = [name]
|
|
616
|
+
has_flattened_params = (
|
|
617
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
618
|
+
)
|
|
619
|
+
if request is not None and has_flattened_params:
|
|
620
|
+
raise ValueError(
|
|
621
|
+
"If the `request` argument is set, then none of "
|
|
622
|
+
"the individual field arguments should be set."
|
|
623
|
+
)
|
|
624
|
+
|
|
625
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
626
|
+
# there are no flattened fields), or create one.
|
|
627
|
+
if not isinstance(request, maintenance_service.GetResourceMaintenanceRequest):
|
|
628
|
+
request = maintenance_service.GetResourceMaintenanceRequest(request)
|
|
629
|
+
|
|
630
|
+
# If we have keyword arguments corresponding to fields on the
|
|
631
|
+
# request, apply these.
|
|
632
|
+
if name is not None:
|
|
633
|
+
request.name = name
|
|
634
|
+
|
|
635
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
636
|
+
# and friendly error handling.
|
|
637
|
+
rpc = self._client._transport._wrapped_methods[
|
|
638
|
+
self._client._transport.get_resource_maintenance
|
|
639
|
+
]
|
|
640
|
+
|
|
641
|
+
# Certain fields should be provided within the metadata header;
|
|
642
|
+
# add these here.
|
|
643
|
+
metadata = tuple(metadata) + (
|
|
644
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
645
|
+
)
|
|
646
|
+
|
|
647
|
+
# Validate the universe domain.
|
|
648
|
+
self._client._validate_universe_domain()
|
|
649
|
+
|
|
650
|
+
# Send the request.
|
|
651
|
+
response = await rpc(
|
|
652
|
+
request,
|
|
653
|
+
retry=retry,
|
|
654
|
+
timeout=timeout,
|
|
655
|
+
metadata=metadata,
|
|
656
|
+
)
|
|
657
|
+
|
|
658
|
+
# Done; return the response.
|
|
659
|
+
return response
|
|
660
|
+
|
|
661
|
+
async def get_location(
|
|
662
|
+
self,
|
|
663
|
+
request: Optional[locations_pb2.GetLocationRequest] = None,
|
|
664
|
+
*,
|
|
665
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
666
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
667
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
668
|
+
) -> locations_pb2.Location:
|
|
669
|
+
r"""Gets information about a location.
|
|
670
|
+
|
|
671
|
+
Args:
|
|
672
|
+
request (:class:`~.location_pb2.GetLocationRequest`):
|
|
673
|
+
The request object. Request message for
|
|
674
|
+
`GetLocation` method.
|
|
675
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
676
|
+
if any, should be retried.
|
|
677
|
+
timeout (float): The timeout for this request.
|
|
678
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
679
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
680
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
681
|
+
be of type `bytes`.
|
|
682
|
+
Returns:
|
|
683
|
+
~.location_pb2.Location:
|
|
684
|
+
Location object.
|
|
685
|
+
"""
|
|
686
|
+
# Create or coerce a protobuf request object.
|
|
687
|
+
# The request isn't a proto-plus wrapped type,
|
|
688
|
+
# so it must be constructed via keyword expansion.
|
|
689
|
+
if isinstance(request, dict):
|
|
690
|
+
request = locations_pb2.GetLocationRequest(**request)
|
|
691
|
+
|
|
692
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
693
|
+
# and friendly error handling.
|
|
694
|
+
rpc = self.transport._wrapped_methods[self._client._transport.get_location]
|
|
695
|
+
|
|
696
|
+
# Certain fields should be provided within the metadata header;
|
|
697
|
+
# add these here.
|
|
698
|
+
metadata = tuple(metadata) + (
|
|
699
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
700
|
+
)
|
|
701
|
+
|
|
702
|
+
# Validate the universe domain.
|
|
703
|
+
self._client._validate_universe_domain()
|
|
704
|
+
|
|
705
|
+
# Send the request.
|
|
706
|
+
response = await rpc(
|
|
707
|
+
request,
|
|
708
|
+
retry=retry,
|
|
709
|
+
timeout=timeout,
|
|
710
|
+
metadata=metadata,
|
|
711
|
+
)
|
|
712
|
+
|
|
713
|
+
# Done; return the response.
|
|
714
|
+
return response
|
|
715
|
+
|
|
716
|
+
async def list_locations(
|
|
717
|
+
self,
|
|
718
|
+
request: Optional[locations_pb2.ListLocationsRequest] = None,
|
|
719
|
+
*,
|
|
720
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
721
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
722
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
723
|
+
) -> locations_pb2.ListLocationsResponse:
|
|
724
|
+
r"""Lists information about the supported locations for this service.
|
|
725
|
+
|
|
726
|
+
Args:
|
|
727
|
+
request (:class:`~.location_pb2.ListLocationsRequest`):
|
|
728
|
+
The request object. Request message for
|
|
729
|
+
`ListLocations` method.
|
|
730
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
731
|
+
if any, should be retried.
|
|
732
|
+
timeout (float): The timeout for this request.
|
|
733
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
734
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
735
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
736
|
+
be of type `bytes`.
|
|
737
|
+
Returns:
|
|
738
|
+
~.location_pb2.ListLocationsResponse:
|
|
739
|
+
Response message for ``ListLocations`` method.
|
|
740
|
+
"""
|
|
741
|
+
# Create or coerce a protobuf request object.
|
|
742
|
+
# The request isn't a proto-plus wrapped type,
|
|
743
|
+
# so it must be constructed via keyword expansion.
|
|
744
|
+
if isinstance(request, dict):
|
|
745
|
+
request = locations_pb2.ListLocationsRequest(**request)
|
|
746
|
+
|
|
747
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
748
|
+
# and friendly error handling.
|
|
749
|
+
rpc = self.transport._wrapped_methods[self._client._transport.list_locations]
|
|
750
|
+
|
|
751
|
+
# Certain fields should be provided within the metadata header;
|
|
752
|
+
# add these here.
|
|
753
|
+
metadata = tuple(metadata) + (
|
|
754
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
755
|
+
)
|
|
756
|
+
|
|
757
|
+
# Validate the universe domain.
|
|
758
|
+
self._client._validate_universe_domain()
|
|
759
|
+
|
|
760
|
+
# Send the request.
|
|
761
|
+
response = await rpc(
|
|
762
|
+
request,
|
|
763
|
+
retry=retry,
|
|
764
|
+
timeout=timeout,
|
|
765
|
+
metadata=metadata,
|
|
766
|
+
)
|
|
767
|
+
|
|
768
|
+
# Done; return the response.
|
|
769
|
+
return response
|
|
770
|
+
|
|
771
|
+
async def __aenter__(self) -> "MaintenanceAsyncClient":
|
|
772
|
+
return self
|
|
773
|
+
|
|
774
|
+
async def __aexit__(self, exc_type, exc, tb):
|
|
775
|
+
await self.transport.close()
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
779
|
+
gapic_version=package_version.__version__
|
|
780
|
+
)
|
|
781
|
+
|
|
782
|
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
|
783
|
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
__all__ = ("MaintenanceAsyncClient",)
|