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