google-cloud-memorystore 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. google/cloud/memorystore/__init__.py +63 -0
  2. google/cloud/memorystore/gapic_version.py +16 -0
  3. google/cloud/memorystore/py.typed +2 -0
  4. google/cloud/memorystore_v1/__init__.py +63 -0
  5. google/cloud/memorystore_v1/gapic_metadata.json +48 -0
  6. google/cloud/memorystore_v1/gapic_version.py +16 -0
  7. google/cloud/memorystore_v1/py.typed +2 -0
  8. google/cloud/memorystore_v1/services/__init__.py +15 -0
  9. google/cloud/memorystore_v1/services/memorystore/__init__.py +18 -0
  10. google/cloud/memorystore_v1/services/memorystore/client.py +1868 -0
  11. google/cloud/memorystore_v1/services/memorystore/pagers.py +117 -0
  12. google/cloud/memorystore_v1/services/memorystore/transports/__init__.py +30 -0
  13. google/cloud/memorystore_v1/services/memorystore/transports/base.py +355 -0
  14. google/cloud/memorystore_v1/services/memorystore/transports/rest.py +2287 -0
  15. google/cloud/memorystore_v1/services/memorystore/transports/rest_base.py +547 -0
  16. google/cloud/memorystore_v1/types/__init__.py +56 -0
  17. google/cloud/memorystore_v1/types/memorystore.py +1230 -0
  18. google/cloud/memorystore_v1beta/__init__.py +63 -0
  19. google/cloud/memorystore_v1beta/gapic_metadata.json +48 -0
  20. google/cloud/memorystore_v1beta/gapic_version.py +16 -0
  21. google/cloud/memorystore_v1beta/py.typed +2 -0
  22. google/cloud/memorystore_v1beta/services/__init__.py +15 -0
  23. google/cloud/memorystore_v1beta/services/memorystore/__init__.py +18 -0
  24. google/cloud/memorystore_v1beta/services/memorystore/client.py +1868 -0
  25. google/cloud/memorystore_v1beta/services/memorystore/pagers.py +117 -0
  26. google/cloud/memorystore_v1beta/services/memorystore/transports/__init__.py +30 -0
  27. google/cloud/memorystore_v1beta/services/memorystore/transports/base.py +355 -0
  28. google/cloud/memorystore_v1beta/services/memorystore/transports/rest.py +2287 -0
  29. google/cloud/memorystore_v1beta/services/memorystore/transports/rest_base.py +547 -0
  30. google/cloud/memorystore_v1beta/types/__init__.py +56 -0
  31. google/cloud/memorystore_v1beta/types/memorystore.py +1230 -0
  32. google_cloud_memorystore-0.1.0.dist-info/LICENSE +202 -0
  33. google_cloud_memorystore-0.1.0.dist-info/METADATA +139 -0
  34. google_cloud_memorystore-0.1.0.dist-info/RECORD +36 -0
  35. google_cloud_memorystore-0.1.0.dist-info/WHEEL +5 -0
  36. google_cloud_memorystore-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,2287 @@
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
+ 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 gapic_v1, operations_v1, rest_helpers, rest_streaming
23
+ from google.api_core import exceptions as core_exceptions
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
+ from google.longrunning import operations_pb2 # type: ignore
29
+ from google.protobuf import json_format
30
+ from requests import __version__ as requests_version
31
+
32
+ from google.cloud.memorystore_v1.types import memorystore
33
+
34
+ from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
35
+ from .rest_base import _BaseMemorystoreRestTransport
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
+
58
+ class MemorystoreRestInterceptor:
59
+ """Interceptor for Memorystore.
60
+
61
+ Interceptors are used to manipulate requests, request metadata, and responses
62
+ in arbitrary ways.
63
+ Example use cases include:
64
+ * Logging
65
+ * Verifying requests according to service or custom semantics
66
+ * Stripping extraneous information from responses
67
+
68
+ These use cases and more can be enabled by injecting an
69
+ instance of a custom subclass when constructing the MemorystoreRestTransport.
70
+
71
+ .. code-block:: python
72
+ class MyCustomMemorystoreInterceptor(MemorystoreRestInterceptor):
73
+ def pre_create_instance(self, request, metadata):
74
+ logging.log(f"Received request: {request}")
75
+ return request, metadata
76
+
77
+ def post_create_instance(self, response):
78
+ logging.log(f"Received response: {response}")
79
+ return response
80
+
81
+ def pre_delete_instance(self, request, metadata):
82
+ logging.log(f"Received request: {request}")
83
+ return request, metadata
84
+
85
+ def post_delete_instance(self, response):
86
+ logging.log(f"Received response: {response}")
87
+ return response
88
+
89
+ def pre_get_certificate_authority(self, request, metadata):
90
+ logging.log(f"Received request: {request}")
91
+ return request, metadata
92
+
93
+ def post_get_certificate_authority(self, response):
94
+ logging.log(f"Received response: {response}")
95
+ return response
96
+
97
+ def pre_get_instance(self, request, metadata):
98
+ logging.log(f"Received request: {request}")
99
+ return request, metadata
100
+
101
+ def post_get_instance(self, response):
102
+ logging.log(f"Received response: {response}")
103
+ return response
104
+
105
+ def pre_list_instances(self, request, metadata):
106
+ logging.log(f"Received request: {request}")
107
+ return request, metadata
108
+
109
+ def post_list_instances(self, response):
110
+ logging.log(f"Received response: {response}")
111
+ return response
112
+
113
+ def pre_update_instance(self, request, metadata):
114
+ logging.log(f"Received request: {request}")
115
+ return request, metadata
116
+
117
+ def post_update_instance(self, response):
118
+ logging.log(f"Received response: {response}")
119
+ return response
120
+
121
+ transport = MemorystoreRestTransport(interceptor=MyCustomMemorystoreInterceptor())
122
+ client = MemorystoreClient(transport=transport)
123
+
124
+
125
+ """
126
+
127
+ def pre_create_instance(
128
+ self,
129
+ request: memorystore.CreateInstanceRequest,
130
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
131
+ ) -> Tuple[
132
+ memorystore.CreateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]
133
+ ]:
134
+ """Pre-rpc interceptor for create_instance
135
+
136
+ Override in a subclass to manipulate the request or metadata
137
+ before they are sent to the Memorystore server.
138
+ """
139
+ return request, metadata
140
+
141
+ def post_create_instance(
142
+ self, response: operations_pb2.Operation
143
+ ) -> operations_pb2.Operation:
144
+ """Post-rpc interceptor for create_instance
145
+
146
+ Override in a subclass to manipulate the response
147
+ after it is returned by the Memorystore server but before
148
+ it is returned to user code.
149
+ """
150
+ return response
151
+
152
+ def pre_delete_instance(
153
+ self,
154
+ request: memorystore.DeleteInstanceRequest,
155
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
156
+ ) -> Tuple[
157
+ memorystore.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]
158
+ ]:
159
+ """Pre-rpc interceptor for delete_instance
160
+
161
+ Override in a subclass to manipulate the request or metadata
162
+ before they are sent to the Memorystore server.
163
+ """
164
+ return request, metadata
165
+
166
+ def post_delete_instance(
167
+ self, response: operations_pb2.Operation
168
+ ) -> operations_pb2.Operation:
169
+ """Post-rpc interceptor for delete_instance
170
+
171
+ Override in a subclass to manipulate the response
172
+ after it is returned by the Memorystore server but before
173
+ it is returned to user code.
174
+ """
175
+ return response
176
+
177
+ def pre_get_certificate_authority(
178
+ self,
179
+ request: memorystore.GetCertificateAuthorityRequest,
180
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
181
+ ) -> Tuple[
182
+ memorystore.GetCertificateAuthorityRequest,
183
+ Sequence[Tuple[str, Union[str, bytes]]],
184
+ ]:
185
+ """Pre-rpc interceptor for get_certificate_authority
186
+
187
+ Override in a subclass to manipulate the request or metadata
188
+ before they are sent to the Memorystore server.
189
+ """
190
+ return request, metadata
191
+
192
+ def post_get_certificate_authority(
193
+ self, response: memorystore.CertificateAuthority
194
+ ) -> memorystore.CertificateAuthority:
195
+ """Post-rpc interceptor for get_certificate_authority
196
+
197
+ Override in a subclass to manipulate the response
198
+ after it is returned by the Memorystore server but before
199
+ it is returned to user code.
200
+ """
201
+ return response
202
+
203
+ def pre_get_instance(
204
+ self,
205
+ request: memorystore.GetInstanceRequest,
206
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
207
+ ) -> Tuple[memorystore.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
208
+ """Pre-rpc interceptor for get_instance
209
+
210
+ Override in a subclass to manipulate the request or metadata
211
+ before they are sent to the Memorystore server.
212
+ """
213
+ return request, metadata
214
+
215
+ def post_get_instance(self, response: memorystore.Instance) -> memorystore.Instance:
216
+ """Post-rpc interceptor for get_instance
217
+
218
+ Override in a subclass to manipulate the response
219
+ after it is returned by the Memorystore server but before
220
+ it is returned to user code.
221
+ """
222
+ return response
223
+
224
+ def pre_list_instances(
225
+ self,
226
+ request: memorystore.ListInstancesRequest,
227
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
228
+ ) -> Tuple[
229
+ memorystore.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]
230
+ ]:
231
+ """Pre-rpc interceptor for list_instances
232
+
233
+ Override in a subclass to manipulate the request or metadata
234
+ before they are sent to the Memorystore server.
235
+ """
236
+ return request, metadata
237
+
238
+ def post_list_instances(
239
+ self, response: memorystore.ListInstancesResponse
240
+ ) -> memorystore.ListInstancesResponse:
241
+ """Post-rpc interceptor for list_instances
242
+
243
+ Override in a subclass to manipulate the response
244
+ after it is returned by the Memorystore server but before
245
+ it is returned to user code.
246
+ """
247
+ return response
248
+
249
+ def pre_update_instance(
250
+ self,
251
+ request: memorystore.UpdateInstanceRequest,
252
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
253
+ ) -> Tuple[
254
+ memorystore.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]
255
+ ]:
256
+ """Pre-rpc interceptor for update_instance
257
+
258
+ Override in a subclass to manipulate the request or metadata
259
+ before they are sent to the Memorystore server.
260
+ """
261
+ return request, metadata
262
+
263
+ def post_update_instance(
264
+ self, response: operations_pb2.Operation
265
+ ) -> operations_pb2.Operation:
266
+ """Post-rpc interceptor for update_instance
267
+
268
+ Override in a subclass to manipulate the response
269
+ after it is returned by the Memorystore server but before
270
+ it is returned to user code.
271
+ """
272
+ return response
273
+
274
+ def pre_get_location(
275
+ self,
276
+ request: locations_pb2.GetLocationRequest,
277
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
278
+ ) -> Tuple[
279
+ locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]]
280
+ ]:
281
+ """Pre-rpc interceptor for get_location
282
+
283
+ Override in a subclass to manipulate the request or metadata
284
+ before they are sent to the Memorystore server.
285
+ """
286
+ return request, metadata
287
+
288
+ def post_get_location(
289
+ self, response: locations_pb2.Location
290
+ ) -> locations_pb2.Location:
291
+ """Post-rpc interceptor for get_location
292
+
293
+ Override in a subclass to manipulate the response
294
+ after it is returned by the Memorystore server but before
295
+ it is returned to user code.
296
+ """
297
+ return response
298
+
299
+ def pre_list_locations(
300
+ self,
301
+ request: locations_pb2.ListLocationsRequest,
302
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
303
+ ) -> Tuple[
304
+ locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
305
+ ]:
306
+ """Pre-rpc interceptor for list_locations
307
+
308
+ Override in a subclass to manipulate the request or metadata
309
+ before they are sent to the Memorystore server.
310
+ """
311
+ return request, metadata
312
+
313
+ def post_list_locations(
314
+ self, response: locations_pb2.ListLocationsResponse
315
+ ) -> locations_pb2.ListLocationsResponse:
316
+ """Post-rpc interceptor for list_locations
317
+
318
+ Override in a subclass to manipulate the response
319
+ after it is returned by the Memorystore server but before
320
+ it is returned to user code.
321
+ """
322
+ return response
323
+
324
+ def pre_cancel_operation(
325
+ self,
326
+ request: operations_pb2.CancelOperationRequest,
327
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
328
+ ) -> Tuple[
329
+ operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
330
+ ]:
331
+ """Pre-rpc interceptor for cancel_operation
332
+
333
+ Override in a subclass to manipulate the request or metadata
334
+ before they are sent to the Memorystore server.
335
+ """
336
+ return request, metadata
337
+
338
+ def post_cancel_operation(self, response: None) -> None:
339
+ """Post-rpc interceptor for cancel_operation
340
+
341
+ Override in a subclass to manipulate the response
342
+ after it is returned by the Memorystore server but before
343
+ it is returned to user code.
344
+ """
345
+ return response
346
+
347
+ def pre_delete_operation(
348
+ self,
349
+ request: operations_pb2.DeleteOperationRequest,
350
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
351
+ ) -> Tuple[
352
+ operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
353
+ ]:
354
+ """Pre-rpc interceptor for delete_operation
355
+
356
+ Override in a subclass to manipulate the request or metadata
357
+ before they are sent to the Memorystore server.
358
+ """
359
+ return request, metadata
360
+
361
+ def post_delete_operation(self, response: None) -> None:
362
+ """Post-rpc interceptor for delete_operation
363
+
364
+ Override in a subclass to manipulate the response
365
+ after it is returned by the Memorystore server but before
366
+ it is returned to user code.
367
+ """
368
+ return response
369
+
370
+ def pre_get_operation(
371
+ self,
372
+ request: operations_pb2.GetOperationRequest,
373
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
374
+ ) -> Tuple[
375
+ operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
376
+ ]:
377
+ """Pre-rpc interceptor for get_operation
378
+
379
+ Override in a subclass to manipulate the request or metadata
380
+ before they are sent to the Memorystore server.
381
+ """
382
+ return request, metadata
383
+
384
+ def post_get_operation(
385
+ self, response: operations_pb2.Operation
386
+ ) -> operations_pb2.Operation:
387
+ """Post-rpc interceptor for get_operation
388
+
389
+ Override in a subclass to manipulate the response
390
+ after it is returned by the Memorystore server but before
391
+ it is returned to user code.
392
+ """
393
+ return response
394
+
395
+ def pre_list_operations(
396
+ self,
397
+ request: operations_pb2.ListOperationsRequest,
398
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
399
+ ) -> Tuple[
400
+ operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
401
+ ]:
402
+ """Pre-rpc interceptor for list_operations
403
+
404
+ Override in a subclass to manipulate the request or metadata
405
+ before they are sent to the Memorystore server.
406
+ """
407
+ return request, metadata
408
+
409
+ def post_list_operations(
410
+ self, response: operations_pb2.ListOperationsResponse
411
+ ) -> operations_pb2.ListOperationsResponse:
412
+ """Post-rpc interceptor for list_operations
413
+
414
+ Override in a subclass to manipulate the response
415
+ after it is returned by the Memorystore server but before
416
+ it is returned to user code.
417
+ """
418
+ return response
419
+
420
+
421
+ @dataclasses.dataclass
422
+ class MemorystoreRestStub:
423
+ _session: AuthorizedSession
424
+ _host: str
425
+ _interceptor: MemorystoreRestInterceptor
426
+
427
+
428
+ class MemorystoreRestTransport(_BaseMemorystoreRestTransport):
429
+ """REST backend synchronous transport for Memorystore.
430
+
431
+ Service describing handlers for resources
432
+
433
+ This class defines the same methods as the primary client, so the
434
+ primary client can load the underlying transport implementation
435
+ and call it.
436
+
437
+ It sends JSON representations of protocol buffers over HTTP/1.1
438
+ """
439
+
440
+ def __init__(
441
+ self,
442
+ *,
443
+ host: str = "memorystore.googleapis.com",
444
+ credentials: Optional[ga_credentials.Credentials] = None,
445
+ credentials_file: Optional[str] = None,
446
+ scopes: Optional[Sequence[str]] = None,
447
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
448
+ quota_project_id: Optional[str] = None,
449
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
450
+ always_use_jwt_access: Optional[bool] = False,
451
+ url_scheme: str = "https",
452
+ interceptor: Optional[MemorystoreRestInterceptor] = None,
453
+ api_audience: Optional[str] = None,
454
+ ) -> None:
455
+ """Instantiate the transport.
456
+
457
+ Args:
458
+ host (Optional[str]):
459
+ The hostname to connect to (default: 'memorystore.googleapis.com').
460
+ credentials (Optional[google.auth.credentials.Credentials]): The
461
+ authorization credentials to attach to requests. These
462
+ credentials identify the application to the service; if none
463
+ are specified, the client will attempt to ascertain the
464
+ credentials from the environment.
465
+
466
+ credentials_file (Optional[str]): A file with credentials that can
467
+ be loaded with :func:`google.auth.load_credentials_from_file`.
468
+ This argument is ignored if ``channel`` is provided.
469
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
470
+ ignored if ``channel`` is provided.
471
+ client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
472
+ certificate to configure mutual TLS HTTP channel. It is ignored
473
+ if ``channel`` is provided.
474
+ quota_project_id (Optional[str]): An optional project to use for billing
475
+ and quota.
476
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
477
+ The client info used to send a user-agent string along with
478
+ API requests. If ``None``, then default info will be used.
479
+ Generally, you only need to set this if you are developing
480
+ your own client library.
481
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
482
+ be used for service account credentials.
483
+ url_scheme: the protocol scheme for the API endpoint. Normally
484
+ "https", but for testing or local servers,
485
+ "http" can be specified.
486
+ """
487
+ # Run the base constructor
488
+ # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
489
+ # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
490
+ # credentials object
491
+ super().__init__(
492
+ host=host,
493
+ credentials=credentials,
494
+ client_info=client_info,
495
+ always_use_jwt_access=always_use_jwt_access,
496
+ url_scheme=url_scheme,
497
+ api_audience=api_audience,
498
+ )
499
+ self._session = AuthorizedSession(
500
+ self._credentials, default_host=self.DEFAULT_HOST
501
+ )
502
+ self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None
503
+ if client_cert_source_for_mtls:
504
+ self._session.configure_mtls_channel(client_cert_source_for_mtls)
505
+ self._interceptor = interceptor or MemorystoreRestInterceptor()
506
+ self._prep_wrapped_messages(client_info)
507
+
508
+ @property
509
+ def operations_client(self) -> operations_v1.AbstractOperationsClient:
510
+ """Create the client designed to process long-running operations.
511
+
512
+ This property caches on the instance; repeated calls return the same
513
+ client.
514
+ """
515
+ # Only create a new client if we do not already have one.
516
+ if self._operations_client is None:
517
+ http_options: Dict[str, List[Dict[str, str]]] = {
518
+ "google.longrunning.Operations.CancelOperation": [
519
+ {
520
+ "method": "post",
521
+ "uri": "/v1/{name=projects/*/locations/*/operations/*}:cancel",
522
+ },
523
+ ],
524
+ "google.longrunning.Operations.DeleteOperation": [
525
+ {
526
+ "method": "delete",
527
+ "uri": "/v1/{name=projects/*/locations/*/operations/*}",
528
+ },
529
+ ],
530
+ "google.longrunning.Operations.GetOperation": [
531
+ {
532
+ "method": "get",
533
+ "uri": "/v1/{name=projects/*/locations/*/operations/*}",
534
+ },
535
+ ],
536
+ "google.longrunning.Operations.ListOperations": [
537
+ {
538
+ "method": "get",
539
+ "uri": "/v1/{name=projects/*/locations/*}/operations",
540
+ },
541
+ ],
542
+ }
543
+
544
+ rest_transport = operations_v1.OperationsRestTransport(
545
+ host=self._host,
546
+ # use the credentials which are saved
547
+ credentials=self._credentials,
548
+ scopes=self._scopes,
549
+ http_options=http_options,
550
+ path_prefix="v1",
551
+ )
552
+
553
+ self._operations_client = operations_v1.AbstractOperationsClient(
554
+ transport=rest_transport
555
+ )
556
+
557
+ # Return the client from cache.
558
+ return self._operations_client
559
+
560
+ class _CreateInstance(
561
+ _BaseMemorystoreRestTransport._BaseCreateInstance, MemorystoreRestStub
562
+ ):
563
+ def __hash__(self):
564
+ return hash("MemorystoreRestTransport.CreateInstance")
565
+
566
+ @staticmethod
567
+ def _get_response(
568
+ host,
569
+ metadata,
570
+ query_params,
571
+ session,
572
+ timeout,
573
+ transcoded_request,
574
+ body=None,
575
+ ):
576
+ uri = transcoded_request["uri"]
577
+ method = transcoded_request["method"]
578
+ headers = dict(metadata)
579
+ headers["Content-Type"] = "application/json"
580
+ response = getattr(session, method)(
581
+ "{host}{uri}".format(host=host, uri=uri),
582
+ timeout=timeout,
583
+ headers=headers,
584
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
585
+ data=body,
586
+ )
587
+ return response
588
+
589
+ def __call__(
590
+ self,
591
+ request: memorystore.CreateInstanceRequest,
592
+ *,
593
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
594
+ timeout: Optional[float] = None,
595
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
596
+ ) -> operations_pb2.Operation:
597
+ r"""Call the create instance method over HTTP.
598
+
599
+ Args:
600
+ request (~.memorystore.CreateInstanceRequest):
601
+ The request object. Request message for [CreateInstance][].
602
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
603
+ should be retried.
604
+ timeout (float): The timeout for this request.
605
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
606
+ sent along with the request as metadata. Normally, each value must be of type `str`,
607
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
608
+ be of type `bytes`.
609
+
610
+ Returns:
611
+ ~.operations_pb2.Operation:
612
+ This resource represents a
613
+ long-running operation that is the
614
+ result of a network API call.
615
+
616
+ """
617
+
618
+ http_options = (
619
+ _BaseMemorystoreRestTransport._BaseCreateInstance._get_http_options()
620
+ )
621
+
622
+ request, metadata = self._interceptor.pre_create_instance(request, metadata)
623
+ transcoded_request = _BaseMemorystoreRestTransport._BaseCreateInstance._get_transcoded_request(
624
+ http_options, request
625
+ )
626
+
627
+ body = _BaseMemorystoreRestTransport._BaseCreateInstance._get_request_body_json(
628
+ transcoded_request
629
+ )
630
+
631
+ # Jsonify the query params
632
+ query_params = _BaseMemorystoreRestTransport._BaseCreateInstance._get_query_params_json(
633
+ transcoded_request
634
+ )
635
+
636
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
637
+ logging.DEBUG
638
+ ): # pragma: NO COVER
639
+ request_url = "{host}{uri}".format(
640
+ host=self._host, uri=transcoded_request["uri"]
641
+ )
642
+ method = transcoded_request["method"]
643
+ try:
644
+ request_payload = json_format.MessageToJson(request)
645
+ except:
646
+ request_payload = None
647
+ http_request = {
648
+ "payload": request_payload,
649
+ "requestMethod": method,
650
+ "requestUrl": request_url,
651
+ "headers": dict(metadata),
652
+ }
653
+ _LOGGER.debug(
654
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.CreateInstance",
655
+ extra={
656
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
657
+ "rpcName": "CreateInstance",
658
+ "httpRequest": http_request,
659
+ "metadata": http_request["headers"],
660
+ },
661
+ )
662
+
663
+ # Send the request
664
+ response = MemorystoreRestTransport._CreateInstance._get_response(
665
+ self._host,
666
+ metadata,
667
+ query_params,
668
+ self._session,
669
+ timeout,
670
+ transcoded_request,
671
+ body,
672
+ )
673
+
674
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
675
+ # subclass.
676
+ if response.status_code >= 400:
677
+ raise core_exceptions.from_http_response(response)
678
+
679
+ # Return the response
680
+ resp = operations_pb2.Operation()
681
+ json_format.Parse(response.content, resp, ignore_unknown_fields=True)
682
+
683
+ resp = self._interceptor.post_create_instance(resp)
684
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
685
+ logging.DEBUG
686
+ ): # pragma: NO COVER
687
+ try:
688
+ response_payload = json_format.MessageToJson(resp)
689
+ except:
690
+ response_payload = None
691
+ http_response = {
692
+ "payload": response_payload,
693
+ "headers": dict(response.headers),
694
+ "status": response.status_code,
695
+ }
696
+ _LOGGER.debug(
697
+ "Received response for google.cloud.memorystore_v1.MemorystoreClient.create_instance",
698
+ extra={
699
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
700
+ "rpcName": "CreateInstance",
701
+ "metadata": http_response["headers"],
702
+ "httpResponse": http_response,
703
+ },
704
+ )
705
+ return resp
706
+
707
+ class _DeleteInstance(
708
+ _BaseMemorystoreRestTransport._BaseDeleteInstance, MemorystoreRestStub
709
+ ):
710
+ def __hash__(self):
711
+ return hash("MemorystoreRestTransport.DeleteInstance")
712
+
713
+ @staticmethod
714
+ def _get_response(
715
+ host,
716
+ metadata,
717
+ query_params,
718
+ session,
719
+ timeout,
720
+ transcoded_request,
721
+ body=None,
722
+ ):
723
+ uri = transcoded_request["uri"]
724
+ method = transcoded_request["method"]
725
+ headers = dict(metadata)
726
+ headers["Content-Type"] = "application/json"
727
+ response = getattr(session, method)(
728
+ "{host}{uri}".format(host=host, uri=uri),
729
+ timeout=timeout,
730
+ headers=headers,
731
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
732
+ )
733
+ return response
734
+
735
+ def __call__(
736
+ self,
737
+ request: memorystore.DeleteInstanceRequest,
738
+ *,
739
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
740
+ timeout: Optional[float] = None,
741
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
742
+ ) -> operations_pb2.Operation:
743
+ r"""Call the delete instance method over HTTP.
744
+
745
+ Args:
746
+ request (~.memorystore.DeleteInstanceRequest):
747
+ The request object. Request message for [DeleteInstance][].
748
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
749
+ should be retried.
750
+ timeout (float): The timeout for this request.
751
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
752
+ sent along with the request as metadata. Normally, each value must be of type `str`,
753
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
754
+ be of type `bytes`.
755
+
756
+ Returns:
757
+ ~.operations_pb2.Operation:
758
+ This resource represents a
759
+ long-running operation that is the
760
+ result of a network API call.
761
+
762
+ """
763
+
764
+ http_options = (
765
+ _BaseMemorystoreRestTransport._BaseDeleteInstance._get_http_options()
766
+ )
767
+
768
+ request, metadata = self._interceptor.pre_delete_instance(request, metadata)
769
+ transcoded_request = _BaseMemorystoreRestTransport._BaseDeleteInstance._get_transcoded_request(
770
+ http_options, request
771
+ )
772
+
773
+ # Jsonify the query params
774
+ query_params = _BaseMemorystoreRestTransport._BaseDeleteInstance._get_query_params_json(
775
+ transcoded_request
776
+ )
777
+
778
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
779
+ logging.DEBUG
780
+ ): # pragma: NO COVER
781
+ request_url = "{host}{uri}".format(
782
+ host=self._host, uri=transcoded_request["uri"]
783
+ )
784
+ method = transcoded_request["method"]
785
+ try:
786
+ request_payload = json_format.MessageToJson(request)
787
+ except:
788
+ request_payload = None
789
+ http_request = {
790
+ "payload": request_payload,
791
+ "requestMethod": method,
792
+ "requestUrl": request_url,
793
+ "headers": dict(metadata),
794
+ }
795
+ _LOGGER.debug(
796
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.DeleteInstance",
797
+ extra={
798
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
799
+ "rpcName": "DeleteInstance",
800
+ "httpRequest": http_request,
801
+ "metadata": http_request["headers"],
802
+ },
803
+ )
804
+
805
+ # Send the request
806
+ response = MemorystoreRestTransport._DeleteInstance._get_response(
807
+ self._host,
808
+ metadata,
809
+ query_params,
810
+ self._session,
811
+ timeout,
812
+ transcoded_request,
813
+ )
814
+
815
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
816
+ # subclass.
817
+ if response.status_code >= 400:
818
+ raise core_exceptions.from_http_response(response)
819
+
820
+ # Return the response
821
+ resp = operations_pb2.Operation()
822
+ json_format.Parse(response.content, resp, ignore_unknown_fields=True)
823
+
824
+ resp = self._interceptor.post_delete_instance(resp)
825
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
826
+ logging.DEBUG
827
+ ): # pragma: NO COVER
828
+ try:
829
+ response_payload = json_format.MessageToJson(resp)
830
+ except:
831
+ response_payload = None
832
+ http_response = {
833
+ "payload": response_payload,
834
+ "headers": dict(response.headers),
835
+ "status": response.status_code,
836
+ }
837
+ _LOGGER.debug(
838
+ "Received response for google.cloud.memorystore_v1.MemorystoreClient.delete_instance",
839
+ extra={
840
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
841
+ "rpcName": "DeleteInstance",
842
+ "metadata": http_response["headers"],
843
+ "httpResponse": http_response,
844
+ },
845
+ )
846
+ return resp
847
+
848
+ class _GetCertificateAuthority(
849
+ _BaseMemorystoreRestTransport._BaseGetCertificateAuthority, MemorystoreRestStub
850
+ ):
851
+ def __hash__(self):
852
+ return hash("MemorystoreRestTransport.GetCertificateAuthority")
853
+
854
+ @staticmethod
855
+ def _get_response(
856
+ host,
857
+ metadata,
858
+ query_params,
859
+ session,
860
+ timeout,
861
+ transcoded_request,
862
+ body=None,
863
+ ):
864
+ uri = transcoded_request["uri"]
865
+ method = transcoded_request["method"]
866
+ headers = dict(metadata)
867
+ headers["Content-Type"] = "application/json"
868
+ response = getattr(session, method)(
869
+ "{host}{uri}".format(host=host, uri=uri),
870
+ timeout=timeout,
871
+ headers=headers,
872
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
873
+ )
874
+ return response
875
+
876
+ def __call__(
877
+ self,
878
+ request: memorystore.GetCertificateAuthorityRequest,
879
+ *,
880
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
881
+ timeout: Optional[float] = None,
882
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
883
+ ) -> memorystore.CertificateAuthority:
884
+ r"""Call the get certificate authority method over HTTP.
885
+
886
+ Args:
887
+ request (~.memorystore.GetCertificateAuthorityRequest):
888
+ The request object. Request message for [GetCertificateAuthority][].
889
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
890
+ should be retried.
891
+ timeout (float): The timeout for this request.
892
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
893
+ sent along with the request as metadata. Normally, each value must be of type `str`,
894
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
895
+ be of type `bytes`.
896
+
897
+ Returns:
898
+ ~.memorystore.CertificateAuthority:
899
+ A certificate authority for an
900
+ instance.
901
+
902
+ """
903
+
904
+ http_options = (
905
+ _BaseMemorystoreRestTransport._BaseGetCertificateAuthority._get_http_options()
906
+ )
907
+
908
+ request, metadata = self._interceptor.pre_get_certificate_authority(
909
+ request, metadata
910
+ )
911
+ transcoded_request = _BaseMemorystoreRestTransport._BaseGetCertificateAuthority._get_transcoded_request(
912
+ http_options, request
913
+ )
914
+
915
+ # Jsonify the query params
916
+ query_params = _BaseMemorystoreRestTransport._BaseGetCertificateAuthority._get_query_params_json(
917
+ transcoded_request
918
+ )
919
+
920
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
921
+ logging.DEBUG
922
+ ): # pragma: NO COVER
923
+ request_url = "{host}{uri}".format(
924
+ host=self._host, uri=transcoded_request["uri"]
925
+ )
926
+ method = transcoded_request["method"]
927
+ try:
928
+ request_payload = type(request).to_json(request)
929
+ except:
930
+ request_payload = None
931
+ http_request = {
932
+ "payload": request_payload,
933
+ "requestMethod": method,
934
+ "requestUrl": request_url,
935
+ "headers": dict(metadata),
936
+ }
937
+ _LOGGER.debug(
938
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.GetCertificateAuthority",
939
+ extra={
940
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
941
+ "rpcName": "GetCertificateAuthority",
942
+ "httpRequest": http_request,
943
+ "metadata": http_request["headers"],
944
+ },
945
+ )
946
+
947
+ # Send the request
948
+ response = MemorystoreRestTransport._GetCertificateAuthority._get_response(
949
+ self._host,
950
+ metadata,
951
+ query_params,
952
+ self._session,
953
+ timeout,
954
+ transcoded_request,
955
+ )
956
+
957
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
958
+ # subclass.
959
+ if response.status_code >= 400:
960
+ raise core_exceptions.from_http_response(response)
961
+
962
+ # Return the response
963
+ resp = memorystore.CertificateAuthority()
964
+ pb_resp = memorystore.CertificateAuthority.pb(resp)
965
+
966
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
967
+
968
+ resp = self._interceptor.post_get_certificate_authority(resp)
969
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
970
+ logging.DEBUG
971
+ ): # pragma: NO COVER
972
+ try:
973
+ response_payload = memorystore.CertificateAuthority.to_json(
974
+ response
975
+ )
976
+ except:
977
+ response_payload = None
978
+ http_response = {
979
+ "payload": response_payload,
980
+ "headers": dict(response.headers),
981
+ "status": response.status_code,
982
+ }
983
+ _LOGGER.debug(
984
+ "Received response for google.cloud.memorystore_v1.MemorystoreClient.get_certificate_authority",
985
+ extra={
986
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
987
+ "rpcName": "GetCertificateAuthority",
988
+ "metadata": http_response["headers"],
989
+ "httpResponse": http_response,
990
+ },
991
+ )
992
+ return resp
993
+
994
+ class _GetInstance(
995
+ _BaseMemorystoreRestTransport._BaseGetInstance, MemorystoreRestStub
996
+ ):
997
+ def __hash__(self):
998
+ return hash("MemorystoreRestTransport.GetInstance")
999
+
1000
+ @staticmethod
1001
+ def _get_response(
1002
+ host,
1003
+ metadata,
1004
+ query_params,
1005
+ session,
1006
+ timeout,
1007
+ transcoded_request,
1008
+ body=None,
1009
+ ):
1010
+ uri = transcoded_request["uri"]
1011
+ method = transcoded_request["method"]
1012
+ headers = dict(metadata)
1013
+ headers["Content-Type"] = "application/json"
1014
+ response = getattr(session, method)(
1015
+ "{host}{uri}".format(host=host, uri=uri),
1016
+ timeout=timeout,
1017
+ headers=headers,
1018
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1019
+ )
1020
+ return response
1021
+
1022
+ def __call__(
1023
+ self,
1024
+ request: memorystore.GetInstanceRequest,
1025
+ *,
1026
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1027
+ timeout: Optional[float] = None,
1028
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1029
+ ) -> memorystore.Instance:
1030
+ r"""Call the get instance method over HTTP.
1031
+
1032
+ Args:
1033
+ request (~.memorystore.GetInstanceRequest):
1034
+ The request object. Request message for [GetInstance][].
1035
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1036
+ should be retried.
1037
+ timeout (float): The timeout for this request.
1038
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1039
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1040
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1041
+ be of type `bytes`.
1042
+
1043
+ Returns:
1044
+ ~.memorystore.Instance:
1045
+ A Memorystore instance.
1046
+ """
1047
+
1048
+ http_options = (
1049
+ _BaseMemorystoreRestTransport._BaseGetInstance._get_http_options()
1050
+ )
1051
+
1052
+ request, metadata = self._interceptor.pre_get_instance(request, metadata)
1053
+ transcoded_request = (
1054
+ _BaseMemorystoreRestTransport._BaseGetInstance._get_transcoded_request(
1055
+ http_options, request
1056
+ )
1057
+ )
1058
+
1059
+ # Jsonify the query params
1060
+ query_params = (
1061
+ _BaseMemorystoreRestTransport._BaseGetInstance._get_query_params_json(
1062
+ transcoded_request
1063
+ )
1064
+ )
1065
+
1066
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1067
+ logging.DEBUG
1068
+ ): # pragma: NO COVER
1069
+ request_url = "{host}{uri}".format(
1070
+ host=self._host, uri=transcoded_request["uri"]
1071
+ )
1072
+ method = transcoded_request["method"]
1073
+ try:
1074
+ request_payload = type(request).to_json(request)
1075
+ except:
1076
+ request_payload = None
1077
+ http_request = {
1078
+ "payload": request_payload,
1079
+ "requestMethod": method,
1080
+ "requestUrl": request_url,
1081
+ "headers": dict(metadata),
1082
+ }
1083
+ _LOGGER.debug(
1084
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.GetInstance",
1085
+ extra={
1086
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1087
+ "rpcName": "GetInstance",
1088
+ "httpRequest": http_request,
1089
+ "metadata": http_request["headers"],
1090
+ },
1091
+ )
1092
+
1093
+ # Send the request
1094
+ response = MemorystoreRestTransport._GetInstance._get_response(
1095
+ self._host,
1096
+ metadata,
1097
+ query_params,
1098
+ self._session,
1099
+ timeout,
1100
+ transcoded_request,
1101
+ )
1102
+
1103
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1104
+ # subclass.
1105
+ if response.status_code >= 400:
1106
+ raise core_exceptions.from_http_response(response)
1107
+
1108
+ # Return the response
1109
+ resp = memorystore.Instance()
1110
+ pb_resp = memorystore.Instance.pb(resp)
1111
+
1112
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1113
+
1114
+ resp = self._interceptor.post_get_instance(resp)
1115
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1116
+ logging.DEBUG
1117
+ ): # pragma: NO COVER
1118
+ try:
1119
+ response_payload = memorystore.Instance.to_json(response)
1120
+ except:
1121
+ response_payload = None
1122
+ http_response = {
1123
+ "payload": response_payload,
1124
+ "headers": dict(response.headers),
1125
+ "status": response.status_code,
1126
+ }
1127
+ _LOGGER.debug(
1128
+ "Received response for google.cloud.memorystore_v1.MemorystoreClient.get_instance",
1129
+ extra={
1130
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1131
+ "rpcName": "GetInstance",
1132
+ "metadata": http_response["headers"],
1133
+ "httpResponse": http_response,
1134
+ },
1135
+ )
1136
+ return resp
1137
+
1138
+ class _ListInstances(
1139
+ _BaseMemorystoreRestTransport._BaseListInstances, MemorystoreRestStub
1140
+ ):
1141
+ def __hash__(self):
1142
+ return hash("MemorystoreRestTransport.ListInstances")
1143
+
1144
+ @staticmethod
1145
+ def _get_response(
1146
+ host,
1147
+ metadata,
1148
+ query_params,
1149
+ session,
1150
+ timeout,
1151
+ transcoded_request,
1152
+ body=None,
1153
+ ):
1154
+ uri = transcoded_request["uri"]
1155
+ method = transcoded_request["method"]
1156
+ headers = dict(metadata)
1157
+ headers["Content-Type"] = "application/json"
1158
+ response = getattr(session, method)(
1159
+ "{host}{uri}".format(host=host, uri=uri),
1160
+ timeout=timeout,
1161
+ headers=headers,
1162
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1163
+ )
1164
+ return response
1165
+
1166
+ def __call__(
1167
+ self,
1168
+ request: memorystore.ListInstancesRequest,
1169
+ *,
1170
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1171
+ timeout: Optional[float] = None,
1172
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1173
+ ) -> memorystore.ListInstancesResponse:
1174
+ r"""Call the list instances method over HTTP.
1175
+
1176
+ Args:
1177
+ request (~.memorystore.ListInstancesRequest):
1178
+ The request object. Request message for [ListInstances][].
1179
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1180
+ should be retried.
1181
+ timeout (float): The timeout for this request.
1182
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1183
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1184
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1185
+ be of type `bytes`.
1186
+
1187
+ Returns:
1188
+ ~.memorystore.ListInstancesResponse:
1189
+ Response message for [ListInstances][].
1190
+ """
1191
+
1192
+ http_options = (
1193
+ _BaseMemorystoreRestTransport._BaseListInstances._get_http_options()
1194
+ )
1195
+
1196
+ request, metadata = self._interceptor.pre_list_instances(request, metadata)
1197
+ transcoded_request = _BaseMemorystoreRestTransport._BaseListInstances._get_transcoded_request(
1198
+ http_options, request
1199
+ )
1200
+
1201
+ # Jsonify the query params
1202
+ query_params = (
1203
+ _BaseMemorystoreRestTransport._BaseListInstances._get_query_params_json(
1204
+ transcoded_request
1205
+ )
1206
+ )
1207
+
1208
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1209
+ logging.DEBUG
1210
+ ): # pragma: NO COVER
1211
+ request_url = "{host}{uri}".format(
1212
+ host=self._host, uri=transcoded_request["uri"]
1213
+ )
1214
+ method = transcoded_request["method"]
1215
+ try:
1216
+ request_payload = type(request).to_json(request)
1217
+ except:
1218
+ request_payload = None
1219
+ http_request = {
1220
+ "payload": request_payload,
1221
+ "requestMethod": method,
1222
+ "requestUrl": request_url,
1223
+ "headers": dict(metadata),
1224
+ }
1225
+ _LOGGER.debug(
1226
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.ListInstances",
1227
+ extra={
1228
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1229
+ "rpcName": "ListInstances",
1230
+ "httpRequest": http_request,
1231
+ "metadata": http_request["headers"],
1232
+ },
1233
+ )
1234
+
1235
+ # Send the request
1236
+ response = MemorystoreRestTransport._ListInstances._get_response(
1237
+ self._host,
1238
+ metadata,
1239
+ query_params,
1240
+ self._session,
1241
+ timeout,
1242
+ transcoded_request,
1243
+ )
1244
+
1245
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1246
+ # subclass.
1247
+ if response.status_code >= 400:
1248
+ raise core_exceptions.from_http_response(response)
1249
+
1250
+ # Return the response
1251
+ resp = memorystore.ListInstancesResponse()
1252
+ pb_resp = memorystore.ListInstancesResponse.pb(resp)
1253
+
1254
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1255
+
1256
+ resp = self._interceptor.post_list_instances(resp)
1257
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1258
+ logging.DEBUG
1259
+ ): # pragma: NO COVER
1260
+ try:
1261
+ response_payload = memorystore.ListInstancesResponse.to_json(
1262
+ response
1263
+ )
1264
+ except:
1265
+ response_payload = None
1266
+ http_response = {
1267
+ "payload": response_payload,
1268
+ "headers": dict(response.headers),
1269
+ "status": response.status_code,
1270
+ }
1271
+ _LOGGER.debug(
1272
+ "Received response for google.cloud.memorystore_v1.MemorystoreClient.list_instances",
1273
+ extra={
1274
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1275
+ "rpcName": "ListInstances",
1276
+ "metadata": http_response["headers"],
1277
+ "httpResponse": http_response,
1278
+ },
1279
+ )
1280
+ return resp
1281
+
1282
+ class _UpdateInstance(
1283
+ _BaseMemorystoreRestTransport._BaseUpdateInstance, MemorystoreRestStub
1284
+ ):
1285
+ def __hash__(self):
1286
+ return hash("MemorystoreRestTransport.UpdateInstance")
1287
+
1288
+ @staticmethod
1289
+ def _get_response(
1290
+ host,
1291
+ metadata,
1292
+ query_params,
1293
+ session,
1294
+ timeout,
1295
+ transcoded_request,
1296
+ body=None,
1297
+ ):
1298
+ uri = transcoded_request["uri"]
1299
+ method = transcoded_request["method"]
1300
+ headers = dict(metadata)
1301
+ headers["Content-Type"] = "application/json"
1302
+ response = getattr(session, method)(
1303
+ "{host}{uri}".format(host=host, uri=uri),
1304
+ timeout=timeout,
1305
+ headers=headers,
1306
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1307
+ data=body,
1308
+ )
1309
+ return response
1310
+
1311
+ def __call__(
1312
+ self,
1313
+ request: memorystore.UpdateInstanceRequest,
1314
+ *,
1315
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1316
+ timeout: Optional[float] = None,
1317
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1318
+ ) -> operations_pb2.Operation:
1319
+ r"""Call the update instance method over HTTP.
1320
+
1321
+ Args:
1322
+ request (~.memorystore.UpdateInstanceRequest):
1323
+ The request object. Request message for [UpdateInstance][].
1324
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1325
+ should be retried.
1326
+ timeout (float): The timeout for this request.
1327
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1328
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1329
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1330
+ be of type `bytes`.
1331
+
1332
+ Returns:
1333
+ ~.operations_pb2.Operation:
1334
+ This resource represents a
1335
+ long-running operation that is the
1336
+ result of a network API call.
1337
+
1338
+ """
1339
+
1340
+ http_options = (
1341
+ _BaseMemorystoreRestTransport._BaseUpdateInstance._get_http_options()
1342
+ )
1343
+
1344
+ request, metadata = self._interceptor.pre_update_instance(request, metadata)
1345
+ transcoded_request = _BaseMemorystoreRestTransport._BaseUpdateInstance._get_transcoded_request(
1346
+ http_options, request
1347
+ )
1348
+
1349
+ body = _BaseMemorystoreRestTransport._BaseUpdateInstance._get_request_body_json(
1350
+ transcoded_request
1351
+ )
1352
+
1353
+ # Jsonify the query params
1354
+ query_params = _BaseMemorystoreRestTransport._BaseUpdateInstance._get_query_params_json(
1355
+ transcoded_request
1356
+ )
1357
+
1358
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1359
+ logging.DEBUG
1360
+ ): # pragma: NO COVER
1361
+ request_url = "{host}{uri}".format(
1362
+ host=self._host, uri=transcoded_request["uri"]
1363
+ )
1364
+ method = transcoded_request["method"]
1365
+ try:
1366
+ request_payload = json_format.MessageToJson(request)
1367
+ except:
1368
+ request_payload = None
1369
+ http_request = {
1370
+ "payload": request_payload,
1371
+ "requestMethod": method,
1372
+ "requestUrl": request_url,
1373
+ "headers": dict(metadata),
1374
+ }
1375
+ _LOGGER.debug(
1376
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.UpdateInstance",
1377
+ extra={
1378
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1379
+ "rpcName": "UpdateInstance",
1380
+ "httpRequest": http_request,
1381
+ "metadata": http_request["headers"],
1382
+ },
1383
+ )
1384
+
1385
+ # Send the request
1386
+ response = MemorystoreRestTransport._UpdateInstance._get_response(
1387
+ self._host,
1388
+ metadata,
1389
+ query_params,
1390
+ self._session,
1391
+ timeout,
1392
+ transcoded_request,
1393
+ body,
1394
+ )
1395
+
1396
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1397
+ # subclass.
1398
+ if response.status_code >= 400:
1399
+ raise core_exceptions.from_http_response(response)
1400
+
1401
+ # Return the response
1402
+ resp = operations_pb2.Operation()
1403
+ json_format.Parse(response.content, resp, ignore_unknown_fields=True)
1404
+
1405
+ resp = self._interceptor.post_update_instance(resp)
1406
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1407
+ logging.DEBUG
1408
+ ): # pragma: NO COVER
1409
+ try:
1410
+ response_payload = json_format.MessageToJson(resp)
1411
+ except:
1412
+ response_payload = None
1413
+ http_response = {
1414
+ "payload": response_payload,
1415
+ "headers": dict(response.headers),
1416
+ "status": response.status_code,
1417
+ }
1418
+ _LOGGER.debug(
1419
+ "Received response for google.cloud.memorystore_v1.MemorystoreClient.update_instance",
1420
+ extra={
1421
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1422
+ "rpcName": "UpdateInstance",
1423
+ "metadata": http_response["headers"],
1424
+ "httpResponse": http_response,
1425
+ },
1426
+ )
1427
+ return resp
1428
+
1429
+ @property
1430
+ def create_instance(
1431
+ self,
1432
+ ) -> Callable[[memorystore.CreateInstanceRequest], operations_pb2.Operation]:
1433
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1434
+ # In C++ this would require a dynamic_cast
1435
+ return self._CreateInstance(self._session, self._host, self._interceptor) # type: ignore
1436
+
1437
+ @property
1438
+ def delete_instance(
1439
+ self,
1440
+ ) -> Callable[[memorystore.DeleteInstanceRequest], operations_pb2.Operation]:
1441
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1442
+ # In C++ this would require a dynamic_cast
1443
+ return self._DeleteInstance(self._session, self._host, self._interceptor) # type: ignore
1444
+
1445
+ @property
1446
+ def get_certificate_authority(
1447
+ self,
1448
+ ) -> Callable[
1449
+ [memorystore.GetCertificateAuthorityRequest], memorystore.CertificateAuthority
1450
+ ]:
1451
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1452
+ # In C++ this would require a dynamic_cast
1453
+ return self._GetCertificateAuthority(self._session, self._host, self._interceptor) # type: ignore
1454
+
1455
+ @property
1456
+ def get_instance(
1457
+ self,
1458
+ ) -> Callable[[memorystore.GetInstanceRequest], memorystore.Instance]:
1459
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1460
+ # In C++ this would require a dynamic_cast
1461
+ return self._GetInstance(self._session, self._host, self._interceptor) # type: ignore
1462
+
1463
+ @property
1464
+ def list_instances(
1465
+ self,
1466
+ ) -> Callable[
1467
+ [memorystore.ListInstancesRequest], memorystore.ListInstancesResponse
1468
+ ]:
1469
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1470
+ # In C++ this would require a dynamic_cast
1471
+ return self._ListInstances(self._session, self._host, self._interceptor) # type: ignore
1472
+
1473
+ @property
1474
+ def update_instance(
1475
+ self,
1476
+ ) -> Callable[[memorystore.UpdateInstanceRequest], operations_pb2.Operation]:
1477
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1478
+ # In C++ this would require a dynamic_cast
1479
+ return self._UpdateInstance(self._session, self._host, self._interceptor) # type: ignore
1480
+
1481
+ @property
1482
+ def get_location(self):
1483
+ return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore
1484
+
1485
+ class _GetLocation(
1486
+ _BaseMemorystoreRestTransport._BaseGetLocation, MemorystoreRestStub
1487
+ ):
1488
+ def __hash__(self):
1489
+ return hash("MemorystoreRestTransport.GetLocation")
1490
+
1491
+ @staticmethod
1492
+ def _get_response(
1493
+ host,
1494
+ metadata,
1495
+ query_params,
1496
+ session,
1497
+ timeout,
1498
+ transcoded_request,
1499
+ body=None,
1500
+ ):
1501
+ uri = transcoded_request["uri"]
1502
+ method = transcoded_request["method"]
1503
+ headers = dict(metadata)
1504
+ headers["Content-Type"] = "application/json"
1505
+ response = getattr(session, method)(
1506
+ "{host}{uri}".format(host=host, uri=uri),
1507
+ timeout=timeout,
1508
+ headers=headers,
1509
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1510
+ )
1511
+ return response
1512
+
1513
+ def __call__(
1514
+ self,
1515
+ request: locations_pb2.GetLocationRequest,
1516
+ *,
1517
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1518
+ timeout: Optional[float] = None,
1519
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1520
+ ) -> locations_pb2.Location:
1521
+ r"""Call the get location method over HTTP.
1522
+
1523
+ Args:
1524
+ request (locations_pb2.GetLocationRequest):
1525
+ The request object for GetLocation method.
1526
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1527
+ should be retried.
1528
+ timeout (float): The timeout for this request.
1529
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1530
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1531
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1532
+ be of type `bytes`.
1533
+
1534
+ Returns:
1535
+ locations_pb2.Location: Response from GetLocation method.
1536
+ """
1537
+
1538
+ http_options = (
1539
+ _BaseMemorystoreRestTransport._BaseGetLocation._get_http_options()
1540
+ )
1541
+
1542
+ request, metadata = self._interceptor.pre_get_location(request, metadata)
1543
+ transcoded_request = (
1544
+ _BaseMemorystoreRestTransport._BaseGetLocation._get_transcoded_request(
1545
+ http_options, request
1546
+ )
1547
+ )
1548
+
1549
+ # Jsonify the query params
1550
+ query_params = (
1551
+ _BaseMemorystoreRestTransport._BaseGetLocation._get_query_params_json(
1552
+ transcoded_request
1553
+ )
1554
+ )
1555
+
1556
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1557
+ logging.DEBUG
1558
+ ): # pragma: NO COVER
1559
+ request_url = "{host}{uri}".format(
1560
+ host=self._host, uri=transcoded_request["uri"]
1561
+ )
1562
+ method = transcoded_request["method"]
1563
+ try:
1564
+ request_payload = json_format.MessageToJson(request)
1565
+ except:
1566
+ request_payload = None
1567
+ http_request = {
1568
+ "payload": request_payload,
1569
+ "requestMethod": method,
1570
+ "requestUrl": request_url,
1571
+ "headers": dict(metadata),
1572
+ }
1573
+ _LOGGER.debug(
1574
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.GetLocation",
1575
+ extra={
1576
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1577
+ "rpcName": "GetLocation",
1578
+ "httpRequest": http_request,
1579
+ "metadata": http_request["headers"],
1580
+ },
1581
+ )
1582
+
1583
+ # Send the request
1584
+ response = MemorystoreRestTransport._GetLocation._get_response(
1585
+ self._host,
1586
+ metadata,
1587
+ query_params,
1588
+ self._session,
1589
+ timeout,
1590
+ transcoded_request,
1591
+ )
1592
+
1593
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1594
+ # subclass.
1595
+ if response.status_code >= 400:
1596
+ raise core_exceptions.from_http_response(response)
1597
+
1598
+ content = response.content.decode("utf-8")
1599
+ resp = locations_pb2.Location()
1600
+ resp = json_format.Parse(content, resp)
1601
+ resp = self._interceptor.post_get_location(resp)
1602
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1603
+ logging.DEBUG
1604
+ ): # pragma: NO COVER
1605
+ try:
1606
+ response_payload = json_format.MessageToJson(resp)
1607
+ except:
1608
+ response_payload = None
1609
+ http_response = {
1610
+ "payload": response_payload,
1611
+ "headers": dict(response.headers),
1612
+ "status": response.status_code,
1613
+ }
1614
+ _LOGGER.debug(
1615
+ "Received response for google.cloud.memorystore_v1.MemorystoreAsyncClient.GetLocation",
1616
+ extra={
1617
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1618
+ "rpcName": "GetLocation",
1619
+ "httpResponse": http_response,
1620
+ "metadata": http_response["headers"],
1621
+ },
1622
+ )
1623
+ return resp
1624
+
1625
+ @property
1626
+ def list_locations(self):
1627
+ return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore
1628
+
1629
+ class _ListLocations(
1630
+ _BaseMemorystoreRestTransport._BaseListLocations, MemorystoreRestStub
1631
+ ):
1632
+ def __hash__(self):
1633
+ return hash("MemorystoreRestTransport.ListLocations")
1634
+
1635
+ @staticmethod
1636
+ def _get_response(
1637
+ host,
1638
+ metadata,
1639
+ query_params,
1640
+ session,
1641
+ timeout,
1642
+ transcoded_request,
1643
+ body=None,
1644
+ ):
1645
+ uri = transcoded_request["uri"]
1646
+ method = transcoded_request["method"]
1647
+ headers = dict(metadata)
1648
+ headers["Content-Type"] = "application/json"
1649
+ response = getattr(session, method)(
1650
+ "{host}{uri}".format(host=host, uri=uri),
1651
+ timeout=timeout,
1652
+ headers=headers,
1653
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1654
+ )
1655
+ return response
1656
+
1657
+ def __call__(
1658
+ self,
1659
+ request: locations_pb2.ListLocationsRequest,
1660
+ *,
1661
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1662
+ timeout: Optional[float] = None,
1663
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1664
+ ) -> locations_pb2.ListLocationsResponse:
1665
+ r"""Call the list locations method over HTTP.
1666
+
1667
+ Args:
1668
+ request (locations_pb2.ListLocationsRequest):
1669
+ The request object for ListLocations method.
1670
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1671
+ should be retried.
1672
+ timeout (float): The timeout for this request.
1673
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1674
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1675
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1676
+ be of type `bytes`.
1677
+
1678
+ Returns:
1679
+ locations_pb2.ListLocationsResponse: Response from ListLocations method.
1680
+ """
1681
+
1682
+ http_options = (
1683
+ _BaseMemorystoreRestTransport._BaseListLocations._get_http_options()
1684
+ )
1685
+
1686
+ request, metadata = self._interceptor.pre_list_locations(request, metadata)
1687
+ transcoded_request = _BaseMemorystoreRestTransport._BaseListLocations._get_transcoded_request(
1688
+ http_options, request
1689
+ )
1690
+
1691
+ # Jsonify the query params
1692
+ query_params = (
1693
+ _BaseMemorystoreRestTransport._BaseListLocations._get_query_params_json(
1694
+ transcoded_request
1695
+ )
1696
+ )
1697
+
1698
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1699
+ logging.DEBUG
1700
+ ): # pragma: NO COVER
1701
+ request_url = "{host}{uri}".format(
1702
+ host=self._host, uri=transcoded_request["uri"]
1703
+ )
1704
+ method = transcoded_request["method"]
1705
+ try:
1706
+ request_payload = json_format.MessageToJson(request)
1707
+ except:
1708
+ request_payload = None
1709
+ http_request = {
1710
+ "payload": request_payload,
1711
+ "requestMethod": method,
1712
+ "requestUrl": request_url,
1713
+ "headers": dict(metadata),
1714
+ }
1715
+ _LOGGER.debug(
1716
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.ListLocations",
1717
+ extra={
1718
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1719
+ "rpcName": "ListLocations",
1720
+ "httpRequest": http_request,
1721
+ "metadata": http_request["headers"],
1722
+ },
1723
+ )
1724
+
1725
+ # Send the request
1726
+ response = MemorystoreRestTransport._ListLocations._get_response(
1727
+ self._host,
1728
+ metadata,
1729
+ query_params,
1730
+ self._session,
1731
+ timeout,
1732
+ transcoded_request,
1733
+ )
1734
+
1735
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1736
+ # subclass.
1737
+ if response.status_code >= 400:
1738
+ raise core_exceptions.from_http_response(response)
1739
+
1740
+ content = response.content.decode("utf-8")
1741
+ resp = locations_pb2.ListLocationsResponse()
1742
+ resp = json_format.Parse(content, resp)
1743
+ resp = self._interceptor.post_list_locations(resp)
1744
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1745
+ logging.DEBUG
1746
+ ): # pragma: NO COVER
1747
+ try:
1748
+ response_payload = json_format.MessageToJson(resp)
1749
+ except:
1750
+ response_payload = None
1751
+ http_response = {
1752
+ "payload": response_payload,
1753
+ "headers": dict(response.headers),
1754
+ "status": response.status_code,
1755
+ }
1756
+ _LOGGER.debug(
1757
+ "Received response for google.cloud.memorystore_v1.MemorystoreAsyncClient.ListLocations",
1758
+ extra={
1759
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1760
+ "rpcName": "ListLocations",
1761
+ "httpResponse": http_response,
1762
+ "metadata": http_response["headers"],
1763
+ },
1764
+ )
1765
+ return resp
1766
+
1767
+ @property
1768
+ def cancel_operation(self):
1769
+ return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore
1770
+
1771
+ class _CancelOperation(
1772
+ _BaseMemorystoreRestTransport._BaseCancelOperation, MemorystoreRestStub
1773
+ ):
1774
+ def __hash__(self):
1775
+ return hash("MemorystoreRestTransport.CancelOperation")
1776
+
1777
+ @staticmethod
1778
+ def _get_response(
1779
+ host,
1780
+ metadata,
1781
+ query_params,
1782
+ session,
1783
+ timeout,
1784
+ transcoded_request,
1785
+ body=None,
1786
+ ):
1787
+ uri = transcoded_request["uri"]
1788
+ method = transcoded_request["method"]
1789
+ headers = dict(metadata)
1790
+ headers["Content-Type"] = "application/json"
1791
+ response = getattr(session, method)(
1792
+ "{host}{uri}".format(host=host, uri=uri),
1793
+ timeout=timeout,
1794
+ headers=headers,
1795
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1796
+ )
1797
+ return response
1798
+
1799
+ def __call__(
1800
+ self,
1801
+ request: operations_pb2.CancelOperationRequest,
1802
+ *,
1803
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1804
+ timeout: Optional[float] = None,
1805
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1806
+ ) -> None:
1807
+ r"""Call the cancel operation method over HTTP.
1808
+
1809
+ Args:
1810
+ request (operations_pb2.CancelOperationRequest):
1811
+ The request object for CancelOperation method.
1812
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1813
+ should be retried.
1814
+ timeout (float): The timeout for this request.
1815
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1816
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1817
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1818
+ be of type `bytes`.
1819
+ """
1820
+
1821
+ http_options = (
1822
+ _BaseMemorystoreRestTransport._BaseCancelOperation._get_http_options()
1823
+ )
1824
+
1825
+ request, metadata = self._interceptor.pre_cancel_operation(
1826
+ request, metadata
1827
+ )
1828
+ transcoded_request = _BaseMemorystoreRestTransport._BaseCancelOperation._get_transcoded_request(
1829
+ http_options, request
1830
+ )
1831
+
1832
+ # Jsonify the query params
1833
+ query_params = _BaseMemorystoreRestTransport._BaseCancelOperation._get_query_params_json(
1834
+ transcoded_request
1835
+ )
1836
+
1837
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1838
+ logging.DEBUG
1839
+ ): # pragma: NO COVER
1840
+ request_url = "{host}{uri}".format(
1841
+ host=self._host, uri=transcoded_request["uri"]
1842
+ )
1843
+ method = transcoded_request["method"]
1844
+ try:
1845
+ request_payload = json_format.MessageToJson(request)
1846
+ except:
1847
+ request_payload = None
1848
+ http_request = {
1849
+ "payload": request_payload,
1850
+ "requestMethod": method,
1851
+ "requestUrl": request_url,
1852
+ "headers": dict(metadata),
1853
+ }
1854
+ _LOGGER.debug(
1855
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.CancelOperation",
1856
+ extra={
1857
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1858
+ "rpcName": "CancelOperation",
1859
+ "httpRequest": http_request,
1860
+ "metadata": http_request["headers"],
1861
+ },
1862
+ )
1863
+
1864
+ # Send the request
1865
+ response = MemorystoreRestTransport._CancelOperation._get_response(
1866
+ self._host,
1867
+ metadata,
1868
+ query_params,
1869
+ self._session,
1870
+ timeout,
1871
+ transcoded_request,
1872
+ )
1873
+
1874
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1875
+ # subclass.
1876
+ if response.status_code >= 400:
1877
+ raise core_exceptions.from_http_response(response)
1878
+
1879
+ return self._interceptor.post_cancel_operation(None)
1880
+
1881
+ @property
1882
+ def delete_operation(self):
1883
+ return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore
1884
+
1885
+ class _DeleteOperation(
1886
+ _BaseMemorystoreRestTransport._BaseDeleteOperation, MemorystoreRestStub
1887
+ ):
1888
+ def __hash__(self):
1889
+ return hash("MemorystoreRestTransport.DeleteOperation")
1890
+
1891
+ @staticmethod
1892
+ def _get_response(
1893
+ host,
1894
+ metadata,
1895
+ query_params,
1896
+ session,
1897
+ timeout,
1898
+ transcoded_request,
1899
+ body=None,
1900
+ ):
1901
+ uri = transcoded_request["uri"]
1902
+ method = transcoded_request["method"]
1903
+ headers = dict(metadata)
1904
+ headers["Content-Type"] = "application/json"
1905
+ response = getattr(session, method)(
1906
+ "{host}{uri}".format(host=host, uri=uri),
1907
+ timeout=timeout,
1908
+ headers=headers,
1909
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1910
+ )
1911
+ return response
1912
+
1913
+ def __call__(
1914
+ self,
1915
+ request: operations_pb2.DeleteOperationRequest,
1916
+ *,
1917
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1918
+ timeout: Optional[float] = None,
1919
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1920
+ ) -> None:
1921
+ r"""Call the delete operation method over HTTP.
1922
+
1923
+ Args:
1924
+ request (operations_pb2.DeleteOperationRequest):
1925
+ The request object for DeleteOperation method.
1926
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1927
+ should be retried.
1928
+ timeout (float): The timeout for this request.
1929
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1930
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1931
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1932
+ be of type `bytes`.
1933
+ """
1934
+
1935
+ http_options = (
1936
+ _BaseMemorystoreRestTransport._BaseDeleteOperation._get_http_options()
1937
+ )
1938
+
1939
+ request, metadata = self._interceptor.pre_delete_operation(
1940
+ request, metadata
1941
+ )
1942
+ transcoded_request = _BaseMemorystoreRestTransport._BaseDeleteOperation._get_transcoded_request(
1943
+ http_options, request
1944
+ )
1945
+
1946
+ # Jsonify the query params
1947
+ query_params = _BaseMemorystoreRestTransport._BaseDeleteOperation._get_query_params_json(
1948
+ transcoded_request
1949
+ )
1950
+
1951
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1952
+ logging.DEBUG
1953
+ ): # pragma: NO COVER
1954
+ request_url = "{host}{uri}".format(
1955
+ host=self._host, uri=transcoded_request["uri"]
1956
+ )
1957
+ method = transcoded_request["method"]
1958
+ try:
1959
+ request_payload = json_format.MessageToJson(request)
1960
+ except:
1961
+ request_payload = None
1962
+ http_request = {
1963
+ "payload": request_payload,
1964
+ "requestMethod": method,
1965
+ "requestUrl": request_url,
1966
+ "headers": dict(metadata),
1967
+ }
1968
+ _LOGGER.debug(
1969
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.DeleteOperation",
1970
+ extra={
1971
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
1972
+ "rpcName": "DeleteOperation",
1973
+ "httpRequest": http_request,
1974
+ "metadata": http_request["headers"],
1975
+ },
1976
+ )
1977
+
1978
+ # Send the request
1979
+ response = MemorystoreRestTransport._DeleteOperation._get_response(
1980
+ self._host,
1981
+ metadata,
1982
+ query_params,
1983
+ self._session,
1984
+ timeout,
1985
+ transcoded_request,
1986
+ )
1987
+
1988
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1989
+ # subclass.
1990
+ if response.status_code >= 400:
1991
+ raise core_exceptions.from_http_response(response)
1992
+
1993
+ return self._interceptor.post_delete_operation(None)
1994
+
1995
+ @property
1996
+ def get_operation(self):
1997
+ return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore
1998
+
1999
+ class _GetOperation(
2000
+ _BaseMemorystoreRestTransport._BaseGetOperation, MemorystoreRestStub
2001
+ ):
2002
+ def __hash__(self):
2003
+ return hash("MemorystoreRestTransport.GetOperation")
2004
+
2005
+ @staticmethod
2006
+ def _get_response(
2007
+ host,
2008
+ metadata,
2009
+ query_params,
2010
+ session,
2011
+ timeout,
2012
+ transcoded_request,
2013
+ body=None,
2014
+ ):
2015
+ uri = transcoded_request["uri"]
2016
+ method = transcoded_request["method"]
2017
+ headers = dict(metadata)
2018
+ headers["Content-Type"] = "application/json"
2019
+ response = getattr(session, method)(
2020
+ "{host}{uri}".format(host=host, uri=uri),
2021
+ timeout=timeout,
2022
+ headers=headers,
2023
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2024
+ )
2025
+ return response
2026
+
2027
+ def __call__(
2028
+ self,
2029
+ request: operations_pb2.GetOperationRequest,
2030
+ *,
2031
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2032
+ timeout: Optional[float] = None,
2033
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2034
+ ) -> operations_pb2.Operation:
2035
+ r"""Call the get operation method over HTTP.
2036
+
2037
+ Args:
2038
+ request (operations_pb2.GetOperationRequest):
2039
+ The request object for GetOperation method.
2040
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2041
+ should be retried.
2042
+ timeout (float): The timeout for this request.
2043
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2044
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2045
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2046
+ be of type `bytes`.
2047
+
2048
+ Returns:
2049
+ operations_pb2.Operation: Response from GetOperation method.
2050
+ """
2051
+
2052
+ http_options = (
2053
+ _BaseMemorystoreRestTransport._BaseGetOperation._get_http_options()
2054
+ )
2055
+
2056
+ request, metadata = self._interceptor.pre_get_operation(request, metadata)
2057
+ transcoded_request = (
2058
+ _BaseMemorystoreRestTransport._BaseGetOperation._get_transcoded_request(
2059
+ http_options, request
2060
+ )
2061
+ )
2062
+
2063
+ # Jsonify the query params
2064
+ query_params = (
2065
+ _BaseMemorystoreRestTransport._BaseGetOperation._get_query_params_json(
2066
+ transcoded_request
2067
+ )
2068
+ )
2069
+
2070
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2071
+ logging.DEBUG
2072
+ ): # pragma: NO COVER
2073
+ request_url = "{host}{uri}".format(
2074
+ host=self._host, uri=transcoded_request["uri"]
2075
+ )
2076
+ method = transcoded_request["method"]
2077
+ try:
2078
+ request_payload = json_format.MessageToJson(request)
2079
+ except:
2080
+ request_payload = None
2081
+ http_request = {
2082
+ "payload": request_payload,
2083
+ "requestMethod": method,
2084
+ "requestUrl": request_url,
2085
+ "headers": dict(metadata),
2086
+ }
2087
+ _LOGGER.debug(
2088
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.GetOperation",
2089
+ extra={
2090
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
2091
+ "rpcName": "GetOperation",
2092
+ "httpRequest": http_request,
2093
+ "metadata": http_request["headers"],
2094
+ },
2095
+ )
2096
+
2097
+ # Send the request
2098
+ response = MemorystoreRestTransport._GetOperation._get_response(
2099
+ self._host,
2100
+ metadata,
2101
+ query_params,
2102
+ self._session,
2103
+ timeout,
2104
+ transcoded_request,
2105
+ )
2106
+
2107
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2108
+ # subclass.
2109
+ if response.status_code >= 400:
2110
+ raise core_exceptions.from_http_response(response)
2111
+
2112
+ content = response.content.decode("utf-8")
2113
+ resp = operations_pb2.Operation()
2114
+ resp = json_format.Parse(content, resp)
2115
+ resp = self._interceptor.post_get_operation(resp)
2116
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2117
+ logging.DEBUG
2118
+ ): # pragma: NO COVER
2119
+ try:
2120
+ response_payload = json_format.MessageToJson(resp)
2121
+ except:
2122
+ response_payload = None
2123
+ http_response = {
2124
+ "payload": response_payload,
2125
+ "headers": dict(response.headers),
2126
+ "status": response.status_code,
2127
+ }
2128
+ _LOGGER.debug(
2129
+ "Received response for google.cloud.memorystore_v1.MemorystoreAsyncClient.GetOperation",
2130
+ extra={
2131
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
2132
+ "rpcName": "GetOperation",
2133
+ "httpResponse": http_response,
2134
+ "metadata": http_response["headers"],
2135
+ },
2136
+ )
2137
+ return resp
2138
+
2139
+ @property
2140
+ def list_operations(self):
2141
+ return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore
2142
+
2143
+ class _ListOperations(
2144
+ _BaseMemorystoreRestTransport._BaseListOperations, MemorystoreRestStub
2145
+ ):
2146
+ def __hash__(self):
2147
+ return hash("MemorystoreRestTransport.ListOperations")
2148
+
2149
+ @staticmethod
2150
+ def _get_response(
2151
+ host,
2152
+ metadata,
2153
+ query_params,
2154
+ session,
2155
+ timeout,
2156
+ transcoded_request,
2157
+ body=None,
2158
+ ):
2159
+ uri = transcoded_request["uri"]
2160
+ method = transcoded_request["method"]
2161
+ headers = dict(metadata)
2162
+ headers["Content-Type"] = "application/json"
2163
+ response = getattr(session, method)(
2164
+ "{host}{uri}".format(host=host, uri=uri),
2165
+ timeout=timeout,
2166
+ headers=headers,
2167
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2168
+ )
2169
+ return response
2170
+
2171
+ def __call__(
2172
+ self,
2173
+ request: operations_pb2.ListOperationsRequest,
2174
+ *,
2175
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2176
+ timeout: Optional[float] = None,
2177
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2178
+ ) -> operations_pb2.ListOperationsResponse:
2179
+ r"""Call the list operations method over HTTP.
2180
+
2181
+ Args:
2182
+ request (operations_pb2.ListOperationsRequest):
2183
+ The request object for ListOperations method.
2184
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2185
+ should be retried.
2186
+ timeout (float): The timeout for this request.
2187
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2188
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2189
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2190
+ be of type `bytes`.
2191
+
2192
+ Returns:
2193
+ operations_pb2.ListOperationsResponse: Response from ListOperations method.
2194
+ """
2195
+
2196
+ http_options = (
2197
+ _BaseMemorystoreRestTransport._BaseListOperations._get_http_options()
2198
+ )
2199
+
2200
+ request, metadata = self._interceptor.pre_list_operations(request, metadata)
2201
+ transcoded_request = _BaseMemorystoreRestTransport._BaseListOperations._get_transcoded_request(
2202
+ http_options, request
2203
+ )
2204
+
2205
+ # Jsonify the query params
2206
+ query_params = _BaseMemorystoreRestTransport._BaseListOperations._get_query_params_json(
2207
+ transcoded_request
2208
+ )
2209
+
2210
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2211
+ logging.DEBUG
2212
+ ): # pragma: NO COVER
2213
+ request_url = "{host}{uri}".format(
2214
+ host=self._host, uri=transcoded_request["uri"]
2215
+ )
2216
+ method = transcoded_request["method"]
2217
+ try:
2218
+ request_payload = json_format.MessageToJson(request)
2219
+ except:
2220
+ request_payload = None
2221
+ http_request = {
2222
+ "payload": request_payload,
2223
+ "requestMethod": method,
2224
+ "requestUrl": request_url,
2225
+ "headers": dict(metadata),
2226
+ }
2227
+ _LOGGER.debug(
2228
+ f"Sending request for google.cloud.memorystore_v1.MemorystoreClient.ListOperations",
2229
+ extra={
2230
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
2231
+ "rpcName": "ListOperations",
2232
+ "httpRequest": http_request,
2233
+ "metadata": http_request["headers"],
2234
+ },
2235
+ )
2236
+
2237
+ # Send the request
2238
+ response = MemorystoreRestTransport._ListOperations._get_response(
2239
+ self._host,
2240
+ metadata,
2241
+ query_params,
2242
+ self._session,
2243
+ timeout,
2244
+ transcoded_request,
2245
+ )
2246
+
2247
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2248
+ # subclass.
2249
+ if response.status_code >= 400:
2250
+ raise core_exceptions.from_http_response(response)
2251
+
2252
+ content = response.content.decode("utf-8")
2253
+ resp = operations_pb2.ListOperationsResponse()
2254
+ resp = json_format.Parse(content, resp)
2255
+ resp = self._interceptor.post_list_operations(resp)
2256
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2257
+ logging.DEBUG
2258
+ ): # pragma: NO COVER
2259
+ try:
2260
+ response_payload = json_format.MessageToJson(resp)
2261
+ except:
2262
+ response_payload = None
2263
+ http_response = {
2264
+ "payload": response_payload,
2265
+ "headers": dict(response.headers),
2266
+ "status": response.status_code,
2267
+ }
2268
+ _LOGGER.debug(
2269
+ "Received response for google.cloud.memorystore_v1.MemorystoreAsyncClient.ListOperations",
2270
+ extra={
2271
+ "serviceName": "google.cloud.memorystore.v1.Memorystore",
2272
+ "rpcName": "ListOperations",
2273
+ "httpResponse": http_response,
2274
+ "metadata": http_response["headers"],
2275
+ },
2276
+ )
2277
+ return resp
2278
+
2279
+ @property
2280
+ def kind(self) -> str:
2281
+ return "rest"
2282
+
2283
+ def close(self):
2284
+ self._session.close()
2285
+
2286
+
2287
+ __all__ = ("MemorystoreRestTransport",)