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,1182 @@
|
|
|
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
|
+
import dataclasses
|
|
17
|
+
import json # type: ignore
|
|
18
|
+
import logging
|
|
19
|
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
|
20
|
+
import warnings
|
|
21
|
+
|
|
22
|
+
from google.api_core import exceptions as core_exceptions
|
|
23
|
+
from google.api_core import gapic_v1, rest_helpers, rest_streaming
|
|
24
|
+
from google.api_core import retry as retries
|
|
25
|
+
from google.auth import credentials as ga_credentials # type: ignore
|
|
26
|
+
from google.auth.transport.requests import AuthorizedSession # type: ignore
|
|
27
|
+
from google.cloud.location import locations_pb2 # type: ignore
|
|
28
|
+
import google.protobuf
|
|
29
|
+
from google.protobuf import json_format
|
|
30
|
+
from requests import __version__ as requests_version
|
|
31
|
+
|
|
32
|
+
from google.cloud.maintenance_api_v1beta.types import maintenance_service
|
|
33
|
+
|
|
34
|
+
from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
|
|
35
|
+
from .rest_base import _BaseMaintenanceRestTransport
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
|
39
|
+
except AttributeError: # pragma: NO COVER
|
|
40
|
+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
from google.api_core import client_logging # type: ignore
|
|
44
|
+
|
|
45
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
46
|
+
except ImportError: # pragma: NO COVER
|
|
47
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
48
|
+
|
|
49
|
+
_LOGGER = logging.getLogger(__name__)
|
|
50
|
+
|
|
51
|
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
52
|
+
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
|
|
53
|
+
grpc_version=None,
|
|
54
|
+
rest_version=f"requests@{requests_version}",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
|
58
|
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class MaintenanceRestInterceptor:
|
|
62
|
+
"""Interceptor for Maintenance.
|
|
63
|
+
|
|
64
|
+
Interceptors are used to manipulate requests, request metadata, and responses
|
|
65
|
+
in arbitrary ways.
|
|
66
|
+
Example use cases include:
|
|
67
|
+
* Logging
|
|
68
|
+
* Verifying requests according to service or custom semantics
|
|
69
|
+
* Stripping extraneous information from responses
|
|
70
|
+
|
|
71
|
+
These use cases and more can be enabled by injecting an
|
|
72
|
+
instance of a custom subclass when constructing the MaintenanceRestTransport.
|
|
73
|
+
|
|
74
|
+
.. code-block:: python
|
|
75
|
+
class MyCustomMaintenanceInterceptor(MaintenanceRestInterceptor):
|
|
76
|
+
def pre_get_resource_maintenance(self, request, metadata):
|
|
77
|
+
logging.log(f"Received request: {request}")
|
|
78
|
+
return request, metadata
|
|
79
|
+
|
|
80
|
+
def post_get_resource_maintenance(self, response):
|
|
81
|
+
logging.log(f"Received response: {response}")
|
|
82
|
+
return response
|
|
83
|
+
|
|
84
|
+
def pre_list_resource_maintenances(self, request, metadata):
|
|
85
|
+
logging.log(f"Received request: {request}")
|
|
86
|
+
return request, metadata
|
|
87
|
+
|
|
88
|
+
def post_list_resource_maintenances(self, response):
|
|
89
|
+
logging.log(f"Received response: {response}")
|
|
90
|
+
return response
|
|
91
|
+
|
|
92
|
+
def pre_summarize_maintenances(self, request, metadata):
|
|
93
|
+
logging.log(f"Received request: {request}")
|
|
94
|
+
return request, metadata
|
|
95
|
+
|
|
96
|
+
def post_summarize_maintenances(self, response):
|
|
97
|
+
logging.log(f"Received response: {response}")
|
|
98
|
+
return response
|
|
99
|
+
|
|
100
|
+
transport = MaintenanceRestTransport(interceptor=MyCustomMaintenanceInterceptor())
|
|
101
|
+
client = MaintenanceClient(transport=transport)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
def pre_get_resource_maintenance(
|
|
107
|
+
self,
|
|
108
|
+
request: maintenance_service.GetResourceMaintenanceRequest,
|
|
109
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
110
|
+
) -> Tuple[
|
|
111
|
+
maintenance_service.GetResourceMaintenanceRequest,
|
|
112
|
+
Sequence[Tuple[str, Union[str, bytes]]],
|
|
113
|
+
]:
|
|
114
|
+
"""Pre-rpc interceptor for get_resource_maintenance
|
|
115
|
+
|
|
116
|
+
Override in a subclass to manipulate the request or metadata
|
|
117
|
+
before they are sent to the Maintenance server.
|
|
118
|
+
"""
|
|
119
|
+
return request, metadata
|
|
120
|
+
|
|
121
|
+
def post_get_resource_maintenance(
|
|
122
|
+
self, response: maintenance_service.ResourceMaintenance
|
|
123
|
+
) -> maintenance_service.ResourceMaintenance:
|
|
124
|
+
"""Post-rpc interceptor for get_resource_maintenance
|
|
125
|
+
|
|
126
|
+
DEPRECATED. Please use the `post_get_resource_maintenance_with_metadata`
|
|
127
|
+
interceptor instead.
|
|
128
|
+
|
|
129
|
+
Override in a subclass to read or manipulate the response
|
|
130
|
+
after it is returned by the Maintenance server but before
|
|
131
|
+
it is returned to user code. This `post_get_resource_maintenance` interceptor runs
|
|
132
|
+
before the `post_get_resource_maintenance_with_metadata` interceptor.
|
|
133
|
+
"""
|
|
134
|
+
return response
|
|
135
|
+
|
|
136
|
+
def post_get_resource_maintenance_with_metadata(
|
|
137
|
+
self,
|
|
138
|
+
response: maintenance_service.ResourceMaintenance,
|
|
139
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
140
|
+
) -> Tuple[
|
|
141
|
+
maintenance_service.ResourceMaintenance, Sequence[Tuple[str, Union[str, bytes]]]
|
|
142
|
+
]:
|
|
143
|
+
"""Post-rpc interceptor for get_resource_maintenance
|
|
144
|
+
|
|
145
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
146
|
+
is returned by the Maintenance server but before it is returned to user code.
|
|
147
|
+
|
|
148
|
+
We recommend only using this `post_get_resource_maintenance_with_metadata`
|
|
149
|
+
interceptor in new development instead of the `post_get_resource_maintenance` interceptor.
|
|
150
|
+
When both interceptors are used, this `post_get_resource_maintenance_with_metadata` interceptor runs after the
|
|
151
|
+
`post_get_resource_maintenance` interceptor. The (possibly modified) response returned by
|
|
152
|
+
`post_get_resource_maintenance` will be passed to
|
|
153
|
+
`post_get_resource_maintenance_with_metadata`.
|
|
154
|
+
"""
|
|
155
|
+
return response, metadata
|
|
156
|
+
|
|
157
|
+
def pre_list_resource_maintenances(
|
|
158
|
+
self,
|
|
159
|
+
request: maintenance_service.ListResourceMaintenancesRequest,
|
|
160
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
161
|
+
) -> Tuple[
|
|
162
|
+
maintenance_service.ListResourceMaintenancesRequest,
|
|
163
|
+
Sequence[Tuple[str, Union[str, bytes]]],
|
|
164
|
+
]:
|
|
165
|
+
"""Pre-rpc interceptor for list_resource_maintenances
|
|
166
|
+
|
|
167
|
+
Override in a subclass to manipulate the request or metadata
|
|
168
|
+
before they are sent to the Maintenance server.
|
|
169
|
+
"""
|
|
170
|
+
return request, metadata
|
|
171
|
+
|
|
172
|
+
def post_list_resource_maintenances(
|
|
173
|
+
self, response: maintenance_service.ListResourceMaintenancesResponse
|
|
174
|
+
) -> maintenance_service.ListResourceMaintenancesResponse:
|
|
175
|
+
"""Post-rpc interceptor for list_resource_maintenances
|
|
176
|
+
|
|
177
|
+
DEPRECATED. Please use the `post_list_resource_maintenances_with_metadata`
|
|
178
|
+
interceptor instead.
|
|
179
|
+
|
|
180
|
+
Override in a subclass to read or manipulate the response
|
|
181
|
+
after it is returned by the Maintenance server but before
|
|
182
|
+
it is returned to user code. This `post_list_resource_maintenances` interceptor runs
|
|
183
|
+
before the `post_list_resource_maintenances_with_metadata` interceptor.
|
|
184
|
+
"""
|
|
185
|
+
return response
|
|
186
|
+
|
|
187
|
+
def post_list_resource_maintenances_with_metadata(
|
|
188
|
+
self,
|
|
189
|
+
response: maintenance_service.ListResourceMaintenancesResponse,
|
|
190
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
191
|
+
) -> Tuple[
|
|
192
|
+
maintenance_service.ListResourceMaintenancesResponse,
|
|
193
|
+
Sequence[Tuple[str, Union[str, bytes]]],
|
|
194
|
+
]:
|
|
195
|
+
"""Post-rpc interceptor for list_resource_maintenances
|
|
196
|
+
|
|
197
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
198
|
+
is returned by the Maintenance server but before it is returned to user code.
|
|
199
|
+
|
|
200
|
+
We recommend only using this `post_list_resource_maintenances_with_metadata`
|
|
201
|
+
interceptor in new development instead of the `post_list_resource_maintenances` interceptor.
|
|
202
|
+
When both interceptors are used, this `post_list_resource_maintenances_with_metadata` interceptor runs after the
|
|
203
|
+
`post_list_resource_maintenances` interceptor. The (possibly modified) response returned by
|
|
204
|
+
`post_list_resource_maintenances` will be passed to
|
|
205
|
+
`post_list_resource_maintenances_with_metadata`.
|
|
206
|
+
"""
|
|
207
|
+
return response, metadata
|
|
208
|
+
|
|
209
|
+
def pre_summarize_maintenances(
|
|
210
|
+
self,
|
|
211
|
+
request: maintenance_service.SummarizeMaintenancesRequest,
|
|
212
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
213
|
+
) -> Tuple[
|
|
214
|
+
maintenance_service.SummarizeMaintenancesRequest,
|
|
215
|
+
Sequence[Tuple[str, Union[str, bytes]]],
|
|
216
|
+
]:
|
|
217
|
+
"""Pre-rpc interceptor for summarize_maintenances
|
|
218
|
+
|
|
219
|
+
Override in a subclass to manipulate the request or metadata
|
|
220
|
+
before they are sent to the Maintenance server.
|
|
221
|
+
"""
|
|
222
|
+
return request, metadata
|
|
223
|
+
|
|
224
|
+
def post_summarize_maintenances(
|
|
225
|
+
self, response: maintenance_service.SummarizeMaintenancesResponse
|
|
226
|
+
) -> maintenance_service.SummarizeMaintenancesResponse:
|
|
227
|
+
"""Post-rpc interceptor for summarize_maintenances
|
|
228
|
+
|
|
229
|
+
DEPRECATED. Please use the `post_summarize_maintenances_with_metadata`
|
|
230
|
+
interceptor instead.
|
|
231
|
+
|
|
232
|
+
Override in a subclass to read or manipulate the response
|
|
233
|
+
after it is returned by the Maintenance server but before
|
|
234
|
+
it is returned to user code. This `post_summarize_maintenances` interceptor runs
|
|
235
|
+
before the `post_summarize_maintenances_with_metadata` interceptor.
|
|
236
|
+
"""
|
|
237
|
+
return response
|
|
238
|
+
|
|
239
|
+
def post_summarize_maintenances_with_metadata(
|
|
240
|
+
self,
|
|
241
|
+
response: maintenance_service.SummarizeMaintenancesResponse,
|
|
242
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
243
|
+
) -> Tuple[
|
|
244
|
+
maintenance_service.SummarizeMaintenancesResponse,
|
|
245
|
+
Sequence[Tuple[str, Union[str, bytes]]],
|
|
246
|
+
]:
|
|
247
|
+
"""Post-rpc interceptor for summarize_maintenances
|
|
248
|
+
|
|
249
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
250
|
+
is returned by the Maintenance server but before it is returned to user code.
|
|
251
|
+
|
|
252
|
+
We recommend only using this `post_summarize_maintenances_with_metadata`
|
|
253
|
+
interceptor in new development instead of the `post_summarize_maintenances` interceptor.
|
|
254
|
+
When both interceptors are used, this `post_summarize_maintenances_with_metadata` interceptor runs after the
|
|
255
|
+
`post_summarize_maintenances` interceptor. The (possibly modified) response returned by
|
|
256
|
+
`post_summarize_maintenances` will be passed to
|
|
257
|
+
`post_summarize_maintenances_with_metadata`.
|
|
258
|
+
"""
|
|
259
|
+
return response, metadata
|
|
260
|
+
|
|
261
|
+
def pre_get_location(
|
|
262
|
+
self,
|
|
263
|
+
request: locations_pb2.GetLocationRequest,
|
|
264
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
265
|
+
) -> Tuple[
|
|
266
|
+
locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
|
267
|
+
]:
|
|
268
|
+
"""Pre-rpc interceptor for get_location
|
|
269
|
+
|
|
270
|
+
Override in a subclass to manipulate the request or metadata
|
|
271
|
+
before they are sent to the Maintenance server.
|
|
272
|
+
"""
|
|
273
|
+
return request, metadata
|
|
274
|
+
|
|
275
|
+
def post_get_location(
|
|
276
|
+
self, response: locations_pb2.Location
|
|
277
|
+
) -> locations_pb2.Location:
|
|
278
|
+
"""Post-rpc interceptor for get_location
|
|
279
|
+
|
|
280
|
+
Override in a subclass to manipulate the response
|
|
281
|
+
after it is returned by the Maintenance server but before
|
|
282
|
+
it is returned to user code.
|
|
283
|
+
"""
|
|
284
|
+
return response
|
|
285
|
+
|
|
286
|
+
def pre_list_locations(
|
|
287
|
+
self,
|
|
288
|
+
request: locations_pb2.ListLocationsRequest,
|
|
289
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
290
|
+
) -> Tuple[
|
|
291
|
+
locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
|
292
|
+
]:
|
|
293
|
+
"""Pre-rpc interceptor for list_locations
|
|
294
|
+
|
|
295
|
+
Override in a subclass to manipulate the request or metadata
|
|
296
|
+
before they are sent to the Maintenance server.
|
|
297
|
+
"""
|
|
298
|
+
return request, metadata
|
|
299
|
+
|
|
300
|
+
def post_list_locations(
|
|
301
|
+
self, response: locations_pb2.ListLocationsResponse
|
|
302
|
+
) -> locations_pb2.ListLocationsResponse:
|
|
303
|
+
"""Post-rpc interceptor for list_locations
|
|
304
|
+
|
|
305
|
+
Override in a subclass to manipulate the response
|
|
306
|
+
after it is returned by the Maintenance server but before
|
|
307
|
+
it is returned to user code.
|
|
308
|
+
"""
|
|
309
|
+
return response
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
@dataclasses.dataclass
|
|
313
|
+
class MaintenanceRestStub:
|
|
314
|
+
_session: AuthorizedSession
|
|
315
|
+
_host: str
|
|
316
|
+
_interceptor: MaintenanceRestInterceptor
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
class MaintenanceRestTransport(_BaseMaintenanceRestTransport):
|
|
320
|
+
"""REST backend synchronous transport for Maintenance.
|
|
321
|
+
|
|
322
|
+
Unified Maintenance service
|
|
323
|
+
|
|
324
|
+
This class defines the same methods as the primary client, so the
|
|
325
|
+
primary client can load the underlying transport implementation
|
|
326
|
+
and call it.
|
|
327
|
+
|
|
328
|
+
It sends JSON representations of protocol buffers over HTTP/1.1
|
|
329
|
+
"""
|
|
330
|
+
|
|
331
|
+
def __init__(
|
|
332
|
+
self,
|
|
333
|
+
*,
|
|
334
|
+
host: str = "maintenance.googleapis.com",
|
|
335
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
336
|
+
credentials_file: Optional[str] = None,
|
|
337
|
+
scopes: Optional[Sequence[str]] = None,
|
|
338
|
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
|
339
|
+
quota_project_id: Optional[str] = None,
|
|
340
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
341
|
+
always_use_jwt_access: Optional[bool] = False,
|
|
342
|
+
url_scheme: str = "https",
|
|
343
|
+
interceptor: Optional[MaintenanceRestInterceptor] = None,
|
|
344
|
+
api_audience: Optional[str] = None,
|
|
345
|
+
) -> None:
|
|
346
|
+
"""Instantiate the transport.
|
|
347
|
+
|
|
348
|
+
Args:
|
|
349
|
+
host (Optional[str]):
|
|
350
|
+
The hostname to connect to (default: 'maintenance.googleapis.com').
|
|
351
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
352
|
+
authorization credentials to attach to requests. These
|
|
353
|
+
credentials identify the application to the service; if none
|
|
354
|
+
are specified, the client will attempt to ascertain the
|
|
355
|
+
credentials from the environment.
|
|
356
|
+
|
|
357
|
+
credentials_file (Optional[str]): A file with credentials that can
|
|
358
|
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
|
359
|
+
This argument is ignored if ``channel`` is provided.
|
|
360
|
+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
|
|
361
|
+
ignored if ``channel`` is provided.
|
|
362
|
+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
|
|
363
|
+
certificate to configure mutual TLS HTTP channel. It is ignored
|
|
364
|
+
if ``channel`` is provided.
|
|
365
|
+
quota_project_id (Optional[str]): An optional project to use for billing
|
|
366
|
+
and quota.
|
|
367
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
368
|
+
The client info used to send a user-agent string along with
|
|
369
|
+
API requests. If ``None``, then default info will be used.
|
|
370
|
+
Generally, you only need to set this if you are developing
|
|
371
|
+
your own client library.
|
|
372
|
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
|
373
|
+
be used for service account credentials.
|
|
374
|
+
url_scheme: the protocol scheme for the API endpoint. Normally
|
|
375
|
+
"https", but for testing or local servers,
|
|
376
|
+
"http" can be specified.
|
|
377
|
+
"""
|
|
378
|
+
# Run the base constructor
|
|
379
|
+
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
|
|
380
|
+
# TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
|
|
381
|
+
# credentials object
|
|
382
|
+
super().__init__(
|
|
383
|
+
host=host,
|
|
384
|
+
credentials=credentials,
|
|
385
|
+
client_info=client_info,
|
|
386
|
+
always_use_jwt_access=always_use_jwt_access,
|
|
387
|
+
url_scheme=url_scheme,
|
|
388
|
+
api_audience=api_audience,
|
|
389
|
+
)
|
|
390
|
+
self._session = AuthorizedSession(
|
|
391
|
+
self._credentials, default_host=self.DEFAULT_HOST
|
|
392
|
+
)
|
|
393
|
+
if client_cert_source_for_mtls:
|
|
394
|
+
self._session.configure_mtls_channel(client_cert_source_for_mtls)
|
|
395
|
+
self._interceptor = interceptor or MaintenanceRestInterceptor()
|
|
396
|
+
self._prep_wrapped_messages(client_info)
|
|
397
|
+
|
|
398
|
+
class _GetResourceMaintenance(
|
|
399
|
+
_BaseMaintenanceRestTransport._BaseGetResourceMaintenance, MaintenanceRestStub
|
|
400
|
+
):
|
|
401
|
+
def __hash__(self):
|
|
402
|
+
return hash("MaintenanceRestTransport.GetResourceMaintenance")
|
|
403
|
+
|
|
404
|
+
@staticmethod
|
|
405
|
+
def _get_response(
|
|
406
|
+
host,
|
|
407
|
+
metadata,
|
|
408
|
+
query_params,
|
|
409
|
+
session,
|
|
410
|
+
timeout,
|
|
411
|
+
transcoded_request,
|
|
412
|
+
body=None,
|
|
413
|
+
):
|
|
414
|
+
uri = transcoded_request["uri"]
|
|
415
|
+
method = transcoded_request["method"]
|
|
416
|
+
headers = dict(metadata)
|
|
417
|
+
headers["Content-Type"] = "application/json"
|
|
418
|
+
response = getattr(session, method)(
|
|
419
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
420
|
+
timeout=timeout,
|
|
421
|
+
headers=headers,
|
|
422
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
423
|
+
)
|
|
424
|
+
return response
|
|
425
|
+
|
|
426
|
+
def __call__(
|
|
427
|
+
self,
|
|
428
|
+
request: maintenance_service.GetResourceMaintenanceRequest,
|
|
429
|
+
*,
|
|
430
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
431
|
+
timeout: Optional[float] = None,
|
|
432
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
433
|
+
) -> maintenance_service.ResourceMaintenance:
|
|
434
|
+
r"""Call the get resource maintenance method over HTTP.
|
|
435
|
+
|
|
436
|
+
Args:
|
|
437
|
+
request (~.maintenance_service.GetResourceMaintenanceRequest):
|
|
438
|
+
The request object. The request structure for the
|
|
439
|
+
GetResourceMaintenance method.
|
|
440
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
441
|
+
should be retried.
|
|
442
|
+
timeout (float): The timeout for this request.
|
|
443
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
444
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
445
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
446
|
+
be of type `bytes`.
|
|
447
|
+
|
|
448
|
+
Returns:
|
|
449
|
+
~.maintenance_service.ResourceMaintenance:
|
|
450
|
+
ResourceMaintenance is a resource
|
|
451
|
+
that represents a maintenance operation
|
|
452
|
+
on a resource.
|
|
453
|
+
|
|
454
|
+
"""
|
|
455
|
+
|
|
456
|
+
http_options = (
|
|
457
|
+
_BaseMaintenanceRestTransport._BaseGetResourceMaintenance._get_http_options()
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
request, metadata = self._interceptor.pre_get_resource_maintenance(
|
|
461
|
+
request, metadata
|
|
462
|
+
)
|
|
463
|
+
transcoded_request = _BaseMaintenanceRestTransport._BaseGetResourceMaintenance._get_transcoded_request(
|
|
464
|
+
http_options, request
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
# Jsonify the query params
|
|
468
|
+
query_params = _BaseMaintenanceRestTransport._BaseGetResourceMaintenance._get_query_params_json(
|
|
469
|
+
transcoded_request
|
|
470
|
+
)
|
|
471
|
+
|
|
472
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
473
|
+
logging.DEBUG
|
|
474
|
+
): # pragma: NO COVER
|
|
475
|
+
request_url = "{host}{uri}".format(
|
|
476
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
477
|
+
)
|
|
478
|
+
method = transcoded_request["method"]
|
|
479
|
+
try:
|
|
480
|
+
request_payload = type(request).to_json(request)
|
|
481
|
+
except:
|
|
482
|
+
request_payload = None
|
|
483
|
+
http_request = {
|
|
484
|
+
"payload": request_payload,
|
|
485
|
+
"requestMethod": method,
|
|
486
|
+
"requestUrl": request_url,
|
|
487
|
+
"headers": dict(metadata),
|
|
488
|
+
}
|
|
489
|
+
_LOGGER.debug(
|
|
490
|
+
f"Sending request for google.cloud.maintenance.api_v1beta.MaintenanceClient.GetResourceMaintenance",
|
|
491
|
+
extra={
|
|
492
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
493
|
+
"rpcName": "GetResourceMaintenance",
|
|
494
|
+
"httpRequest": http_request,
|
|
495
|
+
"metadata": http_request["headers"],
|
|
496
|
+
},
|
|
497
|
+
)
|
|
498
|
+
|
|
499
|
+
# Send the request
|
|
500
|
+
response = MaintenanceRestTransport._GetResourceMaintenance._get_response(
|
|
501
|
+
self._host,
|
|
502
|
+
metadata,
|
|
503
|
+
query_params,
|
|
504
|
+
self._session,
|
|
505
|
+
timeout,
|
|
506
|
+
transcoded_request,
|
|
507
|
+
)
|
|
508
|
+
|
|
509
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
510
|
+
# subclass.
|
|
511
|
+
if response.status_code >= 400:
|
|
512
|
+
raise core_exceptions.from_http_response(response)
|
|
513
|
+
|
|
514
|
+
# Return the response
|
|
515
|
+
resp = maintenance_service.ResourceMaintenance()
|
|
516
|
+
pb_resp = maintenance_service.ResourceMaintenance.pb(resp)
|
|
517
|
+
|
|
518
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
519
|
+
|
|
520
|
+
resp = self._interceptor.post_get_resource_maintenance(resp)
|
|
521
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
522
|
+
resp, _ = self._interceptor.post_get_resource_maintenance_with_metadata(
|
|
523
|
+
resp, response_metadata
|
|
524
|
+
)
|
|
525
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
526
|
+
logging.DEBUG
|
|
527
|
+
): # pragma: NO COVER
|
|
528
|
+
try:
|
|
529
|
+
response_payload = maintenance_service.ResourceMaintenance.to_json(
|
|
530
|
+
response
|
|
531
|
+
)
|
|
532
|
+
except:
|
|
533
|
+
response_payload = None
|
|
534
|
+
http_response = {
|
|
535
|
+
"payload": response_payload,
|
|
536
|
+
"headers": dict(response.headers),
|
|
537
|
+
"status": response.status_code,
|
|
538
|
+
}
|
|
539
|
+
_LOGGER.debug(
|
|
540
|
+
"Received response for google.cloud.maintenance.api_v1beta.MaintenanceClient.get_resource_maintenance",
|
|
541
|
+
extra={
|
|
542
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
543
|
+
"rpcName": "GetResourceMaintenance",
|
|
544
|
+
"metadata": http_response["headers"],
|
|
545
|
+
"httpResponse": http_response,
|
|
546
|
+
},
|
|
547
|
+
)
|
|
548
|
+
return resp
|
|
549
|
+
|
|
550
|
+
class _ListResourceMaintenances(
|
|
551
|
+
_BaseMaintenanceRestTransport._BaseListResourceMaintenances, MaintenanceRestStub
|
|
552
|
+
):
|
|
553
|
+
def __hash__(self):
|
|
554
|
+
return hash("MaintenanceRestTransport.ListResourceMaintenances")
|
|
555
|
+
|
|
556
|
+
@staticmethod
|
|
557
|
+
def _get_response(
|
|
558
|
+
host,
|
|
559
|
+
metadata,
|
|
560
|
+
query_params,
|
|
561
|
+
session,
|
|
562
|
+
timeout,
|
|
563
|
+
transcoded_request,
|
|
564
|
+
body=None,
|
|
565
|
+
):
|
|
566
|
+
uri = transcoded_request["uri"]
|
|
567
|
+
method = transcoded_request["method"]
|
|
568
|
+
headers = dict(metadata)
|
|
569
|
+
headers["Content-Type"] = "application/json"
|
|
570
|
+
response = getattr(session, method)(
|
|
571
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
572
|
+
timeout=timeout,
|
|
573
|
+
headers=headers,
|
|
574
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
575
|
+
)
|
|
576
|
+
return response
|
|
577
|
+
|
|
578
|
+
def __call__(
|
|
579
|
+
self,
|
|
580
|
+
request: maintenance_service.ListResourceMaintenancesRequest,
|
|
581
|
+
*,
|
|
582
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
583
|
+
timeout: Optional[float] = None,
|
|
584
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
585
|
+
) -> maintenance_service.ListResourceMaintenancesResponse:
|
|
586
|
+
r"""Call the list resource
|
|
587
|
+
maintenances method over HTTP.
|
|
588
|
+
|
|
589
|
+
Args:
|
|
590
|
+
request (~.maintenance_service.ListResourceMaintenancesRequest):
|
|
591
|
+
The request object. The request structure for the
|
|
592
|
+
ListResourceMaintenances method.
|
|
593
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
594
|
+
should be retried.
|
|
595
|
+
timeout (float): The timeout for this request.
|
|
596
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
597
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
598
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
599
|
+
be of type `bytes`.
|
|
600
|
+
|
|
601
|
+
Returns:
|
|
602
|
+
~.maintenance_service.ListResourceMaintenancesResponse:
|
|
603
|
+
The response structure for the
|
|
604
|
+
ListResourceMaintenances method.
|
|
605
|
+
|
|
606
|
+
"""
|
|
607
|
+
|
|
608
|
+
http_options = (
|
|
609
|
+
_BaseMaintenanceRestTransport._BaseListResourceMaintenances._get_http_options()
|
|
610
|
+
)
|
|
611
|
+
|
|
612
|
+
request, metadata = self._interceptor.pre_list_resource_maintenances(
|
|
613
|
+
request, metadata
|
|
614
|
+
)
|
|
615
|
+
transcoded_request = _BaseMaintenanceRestTransport._BaseListResourceMaintenances._get_transcoded_request(
|
|
616
|
+
http_options, request
|
|
617
|
+
)
|
|
618
|
+
|
|
619
|
+
# Jsonify the query params
|
|
620
|
+
query_params = _BaseMaintenanceRestTransport._BaseListResourceMaintenances._get_query_params_json(
|
|
621
|
+
transcoded_request
|
|
622
|
+
)
|
|
623
|
+
|
|
624
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
625
|
+
logging.DEBUG
|
|
626
|
+
): # pragma: NO COVER
|
|
627
|
+
request_url = "{host}{uri}".format(
|
|
628
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
629
|
+
)
|
|
630
|
+
method = transcoded_request["method"]
|
|
631
|
+
try:
|
|
632
|
+
request_payload = type(request).to_json(request)
|
|
633
|
+
except:
|
|
634
|
+
request_payload = None
|
|
635
|
+
http_request = {
|
|
636
|
+
"payload": request_payload,
|
|
637
|
+
"requestMethod": method,
|
|
638
|
+
"requestUrl": request_url,
|
|
639
|
+
"headers": dict(metadata),
|
|
640
|
+
}
|
|
641
|
+
_LOGGER.debug(
|
|
642
|
+
f"Sending request for google.cloud.maintenance.api_v1beta.MaintenanceClient.ListResourceMaintenances",
|
|
643
|
+
extra={
|
|
644
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
645
|
+
"rpcName": "ListResourceMaintenances",
|
|
646
|
+
"httpRequest": http_request,
|
|
647
|
+
"metadata": http_request["headers"],
|
|
648
|
+
},
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
# Send the request
|
|
652
|
+
response = MaintenanceRestTransport._ListResourceMaintenances._get_response(
|
|
653
|
+
self._host,
|
|
654
|
+
metadata,
|
|
655
|
+
query_params,
|
|
656
|
+
self._session,
|
|
657
|
+
timeout,
|
|
658
|
+
transcoded_request,
|
|
659
|
+
)
|
|
660
|
+
|
|
661
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
662
|
+
# subclass.
|
|
663
|
+
if response.status_code >= 400:
|
|
664
|
+
raise core_exceptions.from_http_response(response)
|
|
665
|
+
|
|
666
|
+
# Return the response
|
|
667
|
+
resp = maintenance_service.ListResourceMaintenancesResponse()
|
|
668
|
+
pb_resp = maintenance_service.ListResourceMaintenancesResponse.pb(resp)
|
|
669
|
+
|
|
670
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
671
|
+
|
|
672
|
+
resp = self._interceptor.post_list_resource_maintenances(resp)
|
|
673
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
674
|
+
resp, _ = self._interceptor.post_list_resource_maintenances_with_metadata(
|
|
675
|
+
resp, response_metadata
|
|
676
|
+
)
|
|
677
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
678
|
+
logging.DEBUG
|
|
679
|
+
): # pragma: NO COVER
|
|
680
|
+
try:
|
|
681
|
+
response_payload = (
|
|
682
|
+
maintenance_service.ListResourceMaintenancesResponse.to_json(
|
|
683
|
+
response
|
|
684
|
+
)
|
|
685
|
+
)
|
|
686
|
+
except:
|
|
687
|
+
response_payload = None
|
|
688
|
+
http_response = {
|
|
689
|
+
"payload": response_payload,
|
|
690
|
+
"headers": dict(response.headers),
|
|
691
|
+
"status": response.status_code,
|
|
692
|
+
}
|
|
693
|
+
_LOGGER.debug(
|
|
694
|
+
"Received response for google.cloud.maintenance.api_v1beta.MaintenanceClient.list_resource_maintenances",
|
|
695
|
+
extra={
|
|
696
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
697
|
+
"rpcName": "ListResourceMaintenances",
|
|
698
|
+
"metadata": http_response["headers"],
|
|
699
|
+
"httpResponse": http_response,
|
|
700
|
+
},
|
|
701
|
+
)
|
|
702
|
+
return resp
|
|
703
|
+
|
|
704
|
+
class _SummarizeMaintenances(
|
|
705
|
+
_BaseMaintenanceRestTransport._BaseSummarizeMaintenances, MaintenanceRestStub
|
|
706
|
+
):
|
|
707
|
+
def __hash__(self):
|
|
708
|
+
return hash("MaintenanceRestTransport.SummarizeMaintenances")
|
|
709
|
+
|
|
710
|
+
@staticmethod
|
|
711
|
+
def _get_response(
|
|
712
|
+
host,
|
|
713
|
+
metadata,
|
|
714
|
+
query_params,
|
|
715
|
+
session,
|
|
716
|
+
timeout,
|
|
717
|
+
transcoded_request,
|
|
718
|
+
body=None,
|
|
719
|
+
):
|
|
720
|
+
uri = transcoded_request["uri"]
|
|
721
|
+
method = transcoded_request["method"]
|
|
722
|
+
headers = dict(metadata)
|
|
723
|
+
headers["Content-Type"] = "application/json"
|
|
724
|
+
response = getattr(session, method)(
|
|
725
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
726
|
+
timeout=timeout,
|
|
727
|
+
headers=headers,
|
|
728
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
729
|
+
)
|
|
730
|
+
return response
|
|
731
|
+
|
|
732
|
+
def __call__(
|
|
733
|
+
self,
|
|
734
|
+
request: maintenance_service.SummarizeMaintenancesRequest,
|
|
735
|
+
*,
|
|
736
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
737
|
+
timeout: Optional[float] = None,
|
|
738
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
739
|
+
) -> maintenance_service.SummarizeMaintenancesResponse:
|
|
740
|
+
r"""Call the summarize maintenances method over HTTP.
|
|
741
|
+
|
|
742
|
+
Args:
|
|
743
|
+
request (~.maintenance_service.SummarizeMaintenancesRequest):
|
|
744
|
+
The request object. Request message for
|
|
745
|
+
SummarizeMaintenances custom method.
|
|
746
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
747
|
+
should be retried.
|
|
748
|
+
timeout (float): The timeout for this request.
|
|
749
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
750
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
751
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
752
|
+
be of type `bytes`.
|
|
753
|
+
|
|
754
|
+
Returns:
|
|
755
|
+
~.maintenance_service.SummarizeMaintenancesResponse:
|
|
756
|
+
|
|
757
|
+
"""
|
|
758
|
+
|
|
759
|
+
http_options = (
|
|
760
|
+
_BaseMaintenanceRestTransport._BaseSummarizeMaintenances._get_http_options()
|
|
761
|
+
)
|
|
762
|
+
|
|
763
|
+
request, metadata = self._interceptor.pre_summarize_maintenances(
|
|
764
|
+
request, metadata
|
|
765
|
+
)
|
|
766
|
+
transcoded_request = _BaseMaintenanceRestTransport._BaseSummarizeMaintenances._get_transcoded_request(
|
|
767
|
+
http_options, request
|
|
768
|
+
)
|
|
769
|
+
|
|
770
|
+
# Jsonify the query params
|
|
771
|
+
query_params = _BaseMaintenanceRestTransport._BaseSummarizeMaintenances._get_query_params_json(
|
|
772
|
+
transcoded_request
|
|
773
|
+
)
|
|
774
|
+
|
|
775
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
776
|
+
logging.DEBUG
|
|
777
|
+
): # pragma: NO COVER
|
|
778
|
+
request_url = "{host}{uri}".format(
|
|
779
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
780
|
+
)
|
|
781
|
+
method = transcoded_request["method"]
|
|
782
|
+
try:
|
|
783
|
+
request_payload = type(request).to_json(request)
|
|
784
|
+
except:
|
|
785
|
+
request_payload = None
|
|
786
|
+
http_request = {
|
|
787
|
+
"payload": request_payload,
|
|
788
|
+
"requestMethod": method,
|
|
789
|
+
"requestUrl": request_url,
|
|
790
|
+
"headers": dict(metadata),
|
|
791
|
+
}
|
|
792
|
+
_LOGGER.debug(
|
|
793
|
+
f"Sending request for google.cloud.maintenance.api_v1beta.MaintenanceClient.SummarizeMaintenances",
|
|
794
|
+
extra={
|
|
795
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
796
|
+
"rpcName": "SummarizeMaintenances",
|
|
797
|
+
"httpRequest": http_request,
|
|
798
|
+
"metadata": http_request["headers"],
|
|
799
|
+
},
|
|
800
|
+
)
|
|
801
|
+
|
|
802
|
+
# Send the request
|
|
803
|
+
response = MaintenanceRestTransport._SummarizeMaintenances._get_response(
|
|
804
|
+
self._host,
|
|
805
|
+
metadata,
|
|
806
|
+
query_params,
|
|
807
|
+
self._session,
|
|
808
|
+
timeout,
|
|
809
|
+
transcoded_request,
|
|
810
|
+
)
|
|
811
|
+
|
|
812
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
813
|
+
# subclass.
|
|
814
|
+
if response.status_code >= 400:
|
|
815
|
+
raise core_exceptions.from_http_response(response)
|
|
816
|
+
|
|
817
|
+
# Return the response
|
|
818
|
+
resp = maintenance_service.SummarizeMaintenancesResponse()
|
|
819
|
+
pb_resp = maintenance_service.SummarizeMaintenancesResponse.pb(resp)
|
|
820
|
+
|
|
821
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
822
|
+
|
|
823
|
+
resp = self._interceptor.post_summarize_maintenances(resp)
|
|
824
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
825
|
+
resp, _ = self._interceptor.post_summarize_maintenances_with_metadata(
|
|
826
|
+
resp, response_metadata
|
|
827
|
+
)
|
|
828
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
829
|
+
logging.DEBUG
|
|
830
|
+
): # pragma: NO COVER
|
|
831
|
+
try:
|
|
832
|
+
response_payload = (
|
|
833
|
+
maintenance_service.SummarizeMaintenancesResponse.to_json(
|
|
834
|
+
response
|
|
835
|
+
)
|
|
836
|
+
)
|
|
837
|
+
except:
|
|
838
|
+
response_payload = None
|
|
839
|
+
http_response = {
|
|
840
|
+
"payload": response_payload,
|
|
841
|
+
"headers": dict(response.headers),
|
|
842
|
+
"status": response.status_code,
|
|
843
|
+
}
|
|
844
|
+
_LOGGER.debug(
|
|
845
|
+
"Received response for google.cloud.maintenance.api_v1beta.MaintenanceClient.summarize_maintenances",
|
|
846
|
+
extra={
|
|
847
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
848
|
+
"rpcName": "SummarizeMaintenances",
|
|
849
|
+
"metadata": http_response["headers"],
|
|
850
|
+
"httpResponse": http_response,
|
|
851
|
+
},
|
|
852
|
+
)
|
|
853
|
+
return resp
|
|
854
|
+
|
|
855
|
+
@property
|
|
856
|
+
def get_resource_maintenance(
|
|
857
|
+
self,
|
|
858
|
+
) -> Callable[
|
|
859
|
+
[maintenance_service.GetResourceMaintenanceRequest],
|
|
860
|
+
maintenance_service.ResourceMaintenance,
|
|
861
|
+
]:
|
|
862
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
863
|
+
# In C++ this would require a dynamic_cast
|
|
864
|
+
return self._GetResourceMaintenance(self._session, self._host, self._interceptor) # type: ignore
|
|
865
|
+
|
|
866
|
+
@property
|
|
867
|
+
def list_resource_maintenances(
|
|
868
|
+
self,
|
|
869
|
+
) -> Callable[
|
|
870
|
+
[maintenance_service.ListResourceMaintenancesRequest],
|
|
871
|
+
maintenance_service.ListResourceMaintenancesResponse,
|
|
872
|
+
]:
|
|
873
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
874
|
+
# In C++ this would require a dynamic_cast
|
|
875
|
+
return self._ListResourceMaintenances(self._session, self._host, self._interceptor) # type: ignore
|
|
876
|
+
|
|
877
|
+
@property
|
|
878
|
+
def summarize_maintenances(
|
|
879
|
+
self,
|
|
880
|
+
) -> Callable[
|
|
881
|
+
[maintenance_service.SummarizeMaintenancesRequest],
|
|
882
|
+
maintenance_service.SummarizeMaintenancesResponse,
|
|
883
|
+
]:
|
|
884
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
885
|
+
# In C++ this would require a dynamic_cast
|
|
886
|
+
return self._SummarizeMaintenances(self._session, self._host, self._interceptor) # type: ignore
|
|
887
|
+
|
|
888
|
+
@property
|
|
889
|
+
def get_location(self):
|
|
890
|
+
return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore
|
|
891
|
+
|
|
892
|
+
class _GetLocation(
|
|
893
|
+
_BaseMaintenanceRestTransport._BaseGetLocation, MaintenanceRestStub
|
|
894
|
+
):
|
|
895
|
+
def __hash__(self):
|
|
896
|
+
return hash("MaintenanceRestTransport.GetLocation")
|
|
897
|
+
|
|
898
|
+
@staticmethod
|
|
899
|
+
def _get_response(
|
|
900
|
+
host,
|
|
901
|
+
metadata,
|
|
902
|
+
query_params,
|
|
903
|
+
session,
|
|
904
|
+
timeout,
|
|
905
|
+
transcoded_request,
|
|
906
|
+
body=None,
|
|
907
|
+
):
|
|
908
|
+
uri = transcoded_request["uri"]
|
|
909
|
+
method = transcoded_request["method"]
|
|
910
|
+
headers = dict(metadata)
|
|
911
|
+
headers["Content-Type"] = "application/json"
|
|
912
|
+
response = getattr(session, method)(
|
|
913
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
914
|
+
timeout=timeout,
|
|
915
|
+
headers=headers,
|
|
916
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
917
|
+
)
|
|
918
|
+
return response
|
|
919
|
+
|
|
920
|
+
def __call__(
|
|
921
|
+
self,
|
|
922
|
+
request: locations_pb2.GetLocationRequest,
|
|
923
|
+
*,
|
|
924
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
925
|
+
timeout: Optional[float] = None,
|
|
926
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
927
|
+
) -> locations_pb2.Location:
|
|
928
|
+
r"""Call the get location method over HTTP.
|
|
929
|
+
|
|
930
|
+
Args:
|
|
931
|
+
request (locations_pb2.GetLocationRequest):
|
|
932
|
+
The request object for GetLocation method.
|
|
933
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
934
|
+
should be retried.
|
|
935
|
+
timeout (float): The timeout for this request.
|
|
936
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
937
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
938
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
939
|
+
be of type `bytes`.
|
|
940
|
+
|
|
941
|
+
Returns:
|
|
942
|
+
locations_pb2.Location: Response from GetLocation method.
|
|
943
|
+
"""
|
|
944
|
+
|
|
945
|
+
http_options = (
|
|
946
|
+
_BaseMaintenanceRestTransport._BaseGetLocation._get_http_options()
|
|
947
|
+
)
|
|
948
|
+
|
|
949
|
+
request, metadata = self._interceptor.pre_get_location(request, metadata)
|
|
950
|
+
transcoded_request = (
|
|
951
|
+
_BaseMaintenanceRestTransport._BaseGetLocation._get_transcoded_request(
|
|
952
|
+
http_options, request
|
|
953
|
+
)
|
|
954
|
+
)
|
|
955
|
+
|
|
956
|
+
# Jsonify the query params
|
|
957
|
+
query_params = (
|
|
958
|
+
_BaseMaintenanceRestTransport._BaseGetLocation._get_query_params_json(
|
|
959
|
+
transcoded_request
|
|
960
|
+
)
|
|
961
|
+
)
|
|
962
|
+
|
|
963
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
964
|
+
logging.DEBUG
|
|
965
|
+
): # pragma: NO COVER
|
|
966
|
+
request_url = "{host}{uri}".format(
|
|
967
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
968
|
+
)
|
|
969
|
+
method = transcoded_request["method"]
|
|
970
|
+
try:
|
|
971
|
+
request_payload = json_format.MessageToJson(request)
|
|
972
|
+
except:
|
|
973
|
+
request_payload = None
|
|
974
|
+
http_request = {
|
|
975
|
+
"payload": request_payload,
|
|
976
|
+
"requestMethod": method,
|
|
977
|
+
"requestUrl": request_url,
|
|
978
|
+
"headers": dict(metadata),
|
|
979
|
+
}
|
|
980
|
+
_LOGGER.debug(
|
|
981
|
+
f"Sending request for google.cloud.maintenance.api_v1beta.MaintenanceClient.GetLocation",
|
|
982
|
+
extra={
|
|
983
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
984
|
+
"rpcName": "GetLocation",
|
|
985
|
+
"httpRequest": http_request,
|
|
986
|
+
"metadata": http_request["headers"],
|
|
987
|
+
},
|
|
988
|
+
)
|
|
989
|
+
|
|
990
|
+
# Send the request
|
|
991
|
+
response = MaintenanceRestTransport._GetLocation._get_response(
|
|
992
|
+
self._host,
|
|
993
|
+
metadata,
|
|
994
|
+
query_params,
|
|
995
|
+
self._session,
|
|
996
|
+
timeout,
|
|
997
|
+
transcoded_request,
|
|
998
|
+
)
|
|
999
|
+
|
|
1000
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
1001
|
+
# subclass.
|
|
1002
|
+
if response.status_code >= 400:
|
|
1003
|
+
raise core_exceptions.from_http_response(response)
|
|
1004
|
+
|
|
1005
|
+
content = response.content.decode("utf-8")
|
|
1006
|
+
resp = locations_pb2.Location()
|
|
1007
|
+
resp = json_format.Parse(content, resp)
|
|
1008
|
+
resp = self._interceptor.post_get_location(resp)
|
|
1009
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1010
|
+
logging.DEBUG
|
|
1011
|
+
): # pragma: NO COVER
|
|
1012
|
+
try:
|
|
1013
|
+
response_payload = json_format.MessageToJson(resp)
|
|
1014
|
+
except:
|
|
1015
|
+
response_payload = None
|
|
1016
|
+
http_response = {
|
|
1017
|
+
"payload": response_payload,
|
|
1018
|
+
"headers": dict(response.headers),
|
|
1019
|
+
"status": response.status_code,
|
|
1020
|
+
}
|
|
1021
|
+
_LOGGER.debug(
|
|
1022
|
+
"Received response for google.cloud.maintenance.api_v1beta.MaintenanceAsyncClient.GetLocation",
|
|
1023
|
+
extra={
|
|
1024
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
1025
|
+
"rpcName": "GetLocation",
|
|
1026
|
+
"httpResponse": http_response,
|
|
1027
|
+
"metadata": http_response["headers"],
|
|
1028
|
+
},
|
|
1029
|
+
)
|
|
1030
|
+
return resp
|
|
1031
|
+
|
|
1032
|
+
@property
|
|
1033
|
+
def list_locations(self):
|
|
1034
|
+
return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore
|
|
1035
|
+
|
|
1036
|
+
class _ListLocations(
|
|
1037
|
+
_BaseMaintenanceRestTransport._BaseListLocations, MaintenanceRestStub
|
|
1038
|
+
):
|
|
1039
|
+
def __hash__(self):
|
|
1040
|
+
return hash("MaintenanceRestTransport.ListLocations")
|
|
1041
|
+
|
|
1042
|
+
@staticmethod
|
|
1043
|
+
def _get_response(
|
|
1044
|
+
host,
|
|
1045
|
+
metadata,
|
|
1046
|
+
query_params,
|
|
1047
|
+
session,
|
|
1048
|
+
timeout,
|
|
1049
|
+
transcoded_request,
|
|
1050
|
+
body=None,
|
|
1051
|
+
):
|
|
1052
|
+
uri = transcoded_request["uri"]
|
|
1053
|
+
method = transcoded_request["method"]
|
|
1054
|
+
headers = dict(metadata)
|
|
1055
|
+
headers["Content-Type"] = "application/json"
|
|
1056
|
+
response = getattr(session, method)(
|
|
1057
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
1058
|
+
timeout=timeout,
|
|
1059
|
+
headers=headers,
|
|
1060
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
1061
|
+
)
|
|
1062
|
+
return response
|
|
1063
|
+
|
|
1064
|
+
def __call__(
|
|
1065
|
+
self,
|
|
1066
|
+
request: locations_pb2.ListLocationsRequest,
|
|
1067
|
+
*,
|
|
1068
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1069
|
+
timeout: Optional[float] = None,
|
|
1070
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1071
|
+
) -> locations_pb2.ListLocationsResponse:
|
|
1072
|
+
r"""Call the list locations method over HTTP.
|
|
1073
|
+
|
|
1074
|
+
Args:
|
|
1075
|
+
request (locations_pb2.ListLocationsRequest):
|
|
1076
|
+
The request object for ListLocations method.
|
|
1077
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1078
|
+
should be retried.
|
|
1079
|
+
timeout (float): The timeout for this request.
|
|
1080
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1081
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1082
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1083
|
+
be of type `bytes`.
|
|
1084
|
+
|
|
1085
|
+
Returns:
|
|
1086
|
+
locations_pb2.ListLocationsResponse: Response from ListLocations method.
|
|
1087
|
+
"""
|
|
1088
|
+
|
|
1089
|
+
http_options = (
|
|
1090
|
+
_BaseMaintenanceRestTransport._BaseListLocations._get_http_options()
|
|
1091
|
+
)
|
|
1092
|
+
|
|
1093
|
+
request, metadata = self._interceptor.pre_list_locations(request, metadata)
|
|
1094
|
+
transcoded_request = _BaseMaintenanceRestTransport._BaseListLocations._get_transcoded_request(
|
|
1095
|
+
http_options, request
|
|
1096
|
+
)
|
|
1097
|
+
|
|
1098
|
+
# Jsonify the query params
|
|
1099
|
+
query_params = (
|
|
1100
|
+
_BaseMaintenanceRestTransport._BaseListLocations._get_query_params_json(
|
|
1101
|
+
transcoded_request
|
|
1102
|
+
)
|
|
1103
|
+
)
|
|
1104
|
+
|
|
1105
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1106
|
+
logging.DEBUG
|
|
1107
|
+
): # pragma: NO COVER
|
|
1108
|
+
request_url = "{host}{uri}".format(
|
|
1109
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
1110
|
+
)
|
|
1111
|
+
method = transcoded_request["method"]
|
|
1112
|
+
try:
|
|
1113
|
+
request_payload = json_format.MessageToJson(request)
|
|
1114
|
+
except:
|
|
1115
|
+
request_payload = None
|
|
1116
|
+
http_request = {
|
|
1117
|
+
"payload": request_payload,
|
|
1118
|
+
"requestMethod": method,
|
|
1119
|
+
"requestUrl": request_url,
|
|
1120
|
+
"headers": dict(metadata),
|
|
1121
|
+
}
|
|
1122
|
+
_LOGGER.debug(
|
|
1123
|
+
f"Sending request for google.cloud.maintenance.api_v1beta.MaintenanceClient.ListLocations",
|
|
1124
|
+
extra={
|
|
1125
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
1126
|
+
"rpcName": "ListLocations",
|
|
1127
|
+
"httpRequest": http_request,
|
|
1128
|
+
"metadata": http_request["headers"],
|
|
1129
|
+
},
|
|
1130
|
+
)
|
|
1131
|
+
|
|
1132
|
+
# Send the request
|
|
1133
|
+
response = MaintenanceRestTransport._ListLocations._get_response(
|
|
1134
|
+
self._host,
|
|
1135
|
+
metadata,
|
|
1136
|
+
query_params,
|
|
1137
|
+
self._session,
|
|
1138
|
+
timeout,
|
|
1139
|
+
transcoded_request,
|
|
1140
|
+
)
|
|
1141
|
+
|
|
1142
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
1143
|
+
# subclass.
|
|
1144
|
+
if response.status_code >= 400:
|
|
1145
|
+
raise core_exceptions.from_http_response(response)
|
|
1146
|
+
|
|
1147
|
+
content = response.content.decode("utf-8")
|
|
1148
|
+
resp = locations_pb2.ListLocationsResponse()
|
|
1149
|
+
resp = json_format.Parse(content, resp)
|
|
1150
|
+
resp = self._interceptor.post_list_locations(resp)
|
|
1151
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1152
|
+
logging.DEBUG
|
|
1153
|
+
): # pragma: NO COVER
|
|
1154
|
+
try:
|
|
1155
|
+
response_payload = json_format.MessageToJson(resp)
|
|
1156
|
+
except:
|
|
1157
|
+
response_payload = None
|
|
1158
|
+
http_response = {
|
|
1159
|
+
"payload": response_payload,
|
|
1160
|
+
"headers": dict(response.headers),
|
|
1161
|
+
"status": response.status_code,
|
|
1162
|
+
}
|
|
1163
|
+
_LOGGER.debug(
|
|
1164
|
+
"Received response for google.cloud.maintenance.api_v1beta.MaintenanceAsyncClient.ListLocations",
|
|
1165
|
+
extra={
|
|
1166
|
+
"serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
|
|
1167
|
+
"rpcName": "ListLocations",
|
|
1168
|
+
"httpResponse": http_response,
|
|
1169
|
+
"metadata": http_response["headers"],
|
|
1170
|
+
},
|
|
1171
|
+
)
|
|
1172
|
+
return resp
|
|
1173
|
+
|
|
1174
|
+
@property
|
|
1175
|
+
def kind(self) -> str:
|
|
1176
|
+
return "rest"
|
|
1177
|
+
|
|
1178
|
+
def close(self):
|
|
1179
|
+
self._session.close()
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
__all__ = ("MaintenanceRestTransport",)
|