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,117 @@
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 typing import (
17
+ Any,
18
+ AsyncIterator,
19
+ Awaitable,
20
+ Callable,
21
+ Iterator,
22
+ Optional,
23
+ Sequence,
24
+ Tuple,
25
+ Union,
26
+ )
27
+
28
+ from google.api_core import gapic_v1
29
+ from google.api_core import retry as retries
30
+ from google.api_core import retry_async as retries_async
31
+
32
+ try:
33
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
34
+ OptionalAsyncRetry = Union[
35
+ retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None
36
+ ]
37
+ except AttributeError: # pragma: NO COVER
38
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
39
+ OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore
40
+
41
+ from google.cloud.memorystore_v1.types import memorystore
42
+
43
+
44
+ class ListInstancesPager:
45
+ """A pager for iterating through ``list_instances`` requests.
46
+
47
+ This class thinly wraps an initial
48
+ :class:`google.cloud.memorystore_v1.types.ListInstancesResponse` object, and
49
+ provides an ``__iter__`` method to iterate through its
50
+ ``instances`` field.
51
+
52
+ If there are more pages, the ``__iter__`` method will make additional
53
+ ``ListInstances`` requests and continue to iterate
54
+ through the ``instances`` field on the
55
+ corresponding responses.
56
+
57
+ All the usual :class:`google.cloud.memorystore_v1.types.ListInstancesResponse`
58
+ attributes are available on the pager. If multiple requests are made, only
59
+ the most recent response is retained, and thus used for attribute lookup.
60
+ """
61
+
62
+ def __init__(
63
+ self,
64
+ method: Callable[..., memorystore.ListInstancesResponse],
65
+ request: memorystore.ListInstancesRequest,
66
+ response: memorystore.ListInstancesResponse,
67
+ *,
68
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
69
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
70
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
71
+ ):
72
+ """Instantiate the pager.
73
+
74
+ Args:
75
+ method (Callable): The method that was originally called, and
76
+ which instantiated this pager.
77
+ request (google.cloud.memorystore_v1.types.ListInstancesRequest):
78
+ The initial request object.
79
+ response (google.cloud.memorystore_v1.types.ListInstancesResponse):
80
+ The initial response object.
81
+ retry (google.api_core.retry.Retry): Designation of what errors,
82
+ if any, should be retried.
83
+ timeout (float): The timeout for this request.
84
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
85
+ sent along with the request as metadata. Normally, each value must be of type `str`,
86
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
87
+ be of type `bytes`.
88
+ """
89
+ self._method = method
90
+ self._request = memorystore.ListInstancesRequest(request)
91
+ self._response = response
92
+ self._retry = retry
93
+ self._timeout = timeout
94
+ self._metadata = metadata
95
+
96
+ def __getattr__(self, name: str) -> Any:
97
+ return getattr(self._response, name)
98
+
99
+ @property
100
+ def pages(self) -> Iterator[memorystore.ListInstancesResponse]:
101
+ yield self._response
102
+ while self._response.next_page_token:
103
+ self._request.page_token = self._response.next_page_token
104
+ self._response = self._method(
105
+ self._request,
106
+ retry=self._retry,
107
+ timeout=self._timeout,
108
+ metadata=self._metadata,
109
+ )
110
+ yield self._response
111
+
112
+ def __iter__(self) -> Iterator[memorystore.Instance]:
113
+ for page in self.pages:
114
+ yield from page.instances
115
+
116
+ def __repr__(self) -> str:
117
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
@@ -0,0 +1,30 @@
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
+ from typing import Dict, Type
18
+
19
+ from .base import MemorystoreTransport
20
+ from .rest import MemorystoreRestInterceptor, MemorystoreRestTransport
21
+
22
+ # Compile a registry of transports.
23
+ _transport_registry = OrderedDict() # type: Dict[str, Type[MemorystoreTransport]]
24
+ _transport_registry["rest"] = MemorystoreRestTransport
25
+
26
+ __all__ = (
27
+ "MemorystoreTransport",
28
+ "MemorystoreRestTransport",
29
+ "MemorystoreRestInterceptor",
30
+ )
@@ -0,0 +1,355 @@
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 abc
17
+ from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
18
+
19
+ import google.api_core
20
+ from google.api_core import exceptions as core_exceptions
21
+ from google.api_core import gapic_v1, operations_v1
22
+ from google.api_core import retry as retries
23
+ import google.auth # type: ignore
24
+ from google.auth import credentials as ga_credentials # type: ignore
25
+ from google.cloud.location import locations_pb2 # type: ignore
26
+ from google.longrunning import operations_pb2 # type: ignore
27
+ from google.oauth2 import service_account # type: ignore
28
+
29
+ from google.cloud.memorystore_v1 import gapic_version as package_version
30
+ from google.cloud.memorystore_v1.types import memorystore
31
+
32
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
33
+ gapic_version=package_version.__version__
34
+ )
35
+
36
+
37
+ class MemorystoreTransport(abc.ABC):
38
+ """Abstract transport class for Memorystore."""
39
+
40
+ AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
41
+
42
+ DEFAULT_HOST: str = "memorystore.googleapis.com"
43
+
44
+ def __init__(
45
+ self,
46
+ *,
47
+ host: str = DEFAULT_HOST,
48
+ credentials: Optional[ga_credentials.Credentials] = None,
49
+ credentials_file: Optional[str] = None,
50
+ scopes: Optional[Sequence[str]] = None,
51
+ quota_project_id: Optional[str] = None,
52
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
53
+ always_use_jwt_access: Optional[bool] = False,
54
+ api_audience: Optional[str] = None,
55
+ **kwargs,
56
+ ) -> None:
57
+ """Instantiate the transport.
58
+
59
+ Args:
60
+ host (Optional[str]):
61
+ The hostname to connect to (default: 'memorystore.googleapis.com').
62
+ credentials (Optional[google.auth.credentials.Credentials]): The
63
+ authorization credentials to attach to requests. These
64
+ credentials identify the application to the service; if none
65
+ are specified, the client will attempt to ascertain the
66
+ credentials from the environment.
67
+ credentials_file (Optional[str]): A file with credentials that can
68
+ be loaded with :func:`google.auth.load_credentials_from_file`.
69
+ This argument is mutually exclusive with credentials.
70
+ scopes (Optional[Sequence[str]]): A list of scopes.
71
+ quota_project_id (Optional[str]): An optional project to use for billing
72
+ and quota.
73
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
74
+ The client info used to send a user-agent string along with
75
+ API requests. If ``None``, then default info will be used.
76
+ Generally, you only need to set this if you're developing
77
+ your own client library.
78
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
79
+ be used for service account credentials.
80
+ """
81
+
82
+ scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
83
+
84
+ # Save the scopes.
85
+ self._scopes = scopes
86
+ if not hasattr(self, "_ignore_credentials"):
87
+ self._ignore_credentials: bool = False
88
+
89
+ # If no credentials are provided, then determine the appropriate
90
+ # defaults.
91
+ if credentials and credentials_file:
92
+ raise core_exceptions.DuplicateCredentialArgs(
93
+ "'credentials_file' and 'credentials' are mutually exclusive"
94
+ )
95
+
96
+ if credentials_file is not None:
97
+ credentials, _ = google.auth.load_credentials_from_file(
98
+ credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
99
+ )
100
+ elif credentials is None and not self._ignore_credentials:
101
+ credentials, _ = google.auth.default(
102
+ **scopes_kwargs, quota_project_id=quota_project_id
103
+ )
104
+ # Don't apply audience if the credentials file passed from user.
105
+ if hasattr(credentials, "with_gdch_audience"):
106
+ credentials = credentials.with_gdch_audience(
107
+ api_audience if api_audience else host
108
+ )
109
+
110
+ # If the credentials are service account credentials, then always try to use self signed JWT.
111
+ if (
112
+ always_use_jwt_access
113
+ and isinstance(credentials, service_account.Credentials)
114
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
115
+ ):
116
+ credentials = credentials.with_always_use_jwt_access(True)
117
+
118
+ # Save the credentials.
119
+ self._credentials = credentials
120
+
121
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
122
+ if ":" not in host:
123
+ host += ":443"
124
+ self._host = host
125
+
126
+ @property
127
+ def host(self):
128
+ return self._host
129
+
130
+ def _prep_wrapped_messages(self, client_info):
131
+ # Precompute the wrapped methods.
132
+ self._wrapped_methods = {
133
+ self.list_instances: gapic_v1.method.wrap_method(
134
+ self.list_instances,
135
+ default_retry=retries.Retry(
136
+ initial=1.0,
137
+ maximum=10.0,
138
+ multiplier=1.3,
139
+ predicate=retries.if_exception_type(
140
+ core_exceptions.ServiceUnavailable,
141
+ ),
142
+ deadline=60.0,
143
+ ),
144
+ default_timeout=60.0,
145
+ client_info=client_info,
146
+ ),
147
+ self.get_instance: gapic_v1.method.wrap_method(
148
+ self.get_instance,
149
+ default_retry=retries.Retry(
150
+ initial=1.0,
151
+ maximum=10.0,
152
+ multiplier=1.3,
153
+ predicate=retries.if_exception_type(
154
+ core_exceptions.ServiceUnavailable,
155
+ ),
156
+ deadline=60.0,
157
+ ),
158
+ default_timeout=60.0,
159
+ client_info=client_info,
160
+ ),
161
+ self.create_instance: gapic_v1.method.wrap_method(
162
+ self.create_instance,
163
+ default_timeout=600.0,
164
+ client_info=client_info,
165
+ ),
166
+ self.update_instance: gapic_v1.method.wrap_method(
167
+ self.update_instance,
168
+ default_timeout=600.0,
169
+ client_info=client_info,
170
+ ),
171
+ self.delete_instance: gapic_v1.method.wrap_method(
172
+ self.delete_instance,
173
+ default_timeout=600.0,
174
+ client_info=client_info,
175
+ ),
176
+ self.get_certificate_authority: gapic_v1.method.wrap_method(
177
+ self.get_certificate_authority,
178
+ default_retry=retries.Retry(
179
+ initial=1.0,
180
+ maximum=10.0,
181
+ multiplier=1.3,
182
+ predicate=retries.if_exception_type(
183
+ core_exceptions.ServiceUnavailable,
184
+ ),
185
+ deadline=60.0,
186
+ ),
187
+ default_timeout=60.0,
188
+ client_info=client_info,
189
+ ),
190
+ self.get_location: gapic_v1.method.wrap_method(
191
+ self.get_location,
192
+ default_timeout=None,
193
+ client_info=client_info,
194
+ ),
195
+ self.list_locations: gapic_v1.method.wrap_method(
196
+ self.list_locations,
197
+ default_timeout=None,
198
+ client_info=client_info,
199
+ ),
200
+ self.cancel_operation: gapic_v1.method.wrap_method(
201
+ self.cancel_operation,
202
+ default_timeout=None,
203
+ client_info=client_info,
204
+ ),
205
+ self.delete_operation: gapic_v1.method.wrap_method(
206
+ self.delete_operation,
207
+ default_timeout=None,
208
+ client_info=client_info,
209
+ ),
210
+ self.get_operation: gapic_v1.method.wrap_method(
211
+ self.get_operation,
212
+ default_timeout=None,
213
+ client_info=client_info,
214
+ ),
215
+ self.list_operations: gapic_v1.method.wrap_method(
216
+ self.list_operations,
217
+ default_timeout=None,
218
+ client_info=client_info,
219
+ ),
220
+ }
221
+
222
+ def close(self):
223
+ """Closes resources associated with the transport.
224
+
225
+ .. warning::
226
+ Only call this method if the transport is NOT shared
227
+ with other clients - this may cause errors in other clients!
228
+ """
229
+ raise NotImplementedError()
230
+
231
+ @property
232
+ def operations_client(self):
233
+ """Return the client designed to process long-running operations."""
234
+ raise NotImplementedError()
235
+
236
+ @property
237
+ def list_instances(
238
+ self,
239
+ ) -> Callable[
240
+ [memorystore.ListInstancesRequest],
241
+ Union[
242
+ memorystore.ListInstancesResponse,
243
+ Awaitable[memorystore.ListInstancesResponse],
244
+ ],
245
+ ]:
246
+ raise NotImplementedError()
247
+
248
+ @property
249
+ def get_instance(
250
+ self,
251
+ ) -> Callable[
252
+ [memorystore.GetInstanceRequest],
253
+ Union[memorystore.Instance, Awaitable[memorystore.Instance]],
254
+ ]:
255
+ raise NotImplementedError()
256
+
257
+ @property
258
+ def create_instance(
259
+ self,
260
+ ) -> Callable[
261
+ [memorystore.CreateInstanceRequest],
262
+ Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
263
+ ]:
264
+ raise NotImplementedError()
265
+
266
+ @property
267
+ def update_instance(
268
+ self,
269
+ ) -> Callable[
270
+ [memorystore.UpdateInstanceRequest],
271
+ Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
272
+ ]:
273
+ raise NotImplementedError()
274
+
275
+ @property
276
+ def delete_instance(
277
+ self,
278
+ ) -> Callable[
279
+ [memorystore.DeleteInstanceRequest],
280
+ Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
281
+ ]:
282
+ raise NotImplementedError()
283
+
284
+ @property
285
+ def get_certificate_authority(
286
+ self,
287
+ ) -> Callable[
288
+ [memorystore.GetCertificateAuthorityRequest],
289
+ Union[
290
+ memorystore.CertificateAuthority,
291
+ Awaitable[memorystore.CertificateAuthority],
292
+ ],
293
+ ]:
294
+ raise NotImplementedError()
295
+
296
+ @property
297
+ def list_operations(
298
+ self,
299
+ ) -> Callable[
300
+ [operations_pb2.ListOperationsRequest],
301
+ Union[
302
+ operations_pb2.ListOperationsResponse,
303
+ Awaitable[operations_pb2.ListOperationsResponse],
304
+ ],
305
+ ]:
306
+ raise NotImplementedError()
307
+
308
+ @property
309
+ def get_operation(
310
+ self,
311
+ ) -> Callable[
312
+ [operations_pb2.GetOperationRequest],
313
+ Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
314
+ ]:
315
+ raise NotImplementedError()
316
+
317
+ @property
318
+ def cancel_operation(
319
+ self,
320
+ ) -> Callable[[operations_pb2.CancelOperationRequest], None,]:
321
+ raise NotImplementedError()
322
+
323
+ @property
324
+ def delete_operation(
325
+ self,
326
+ ) -> Callable[[operations_pb2.DeleteOperationRequest], None,]:
327
+ raise NotImplementedError()
328
+
329
+ @property
330
+ def get_location(
331
+ self,
332
+ ) -> Callable[
333
+ [locations_pb2.GetLocationRequest],
334
+ Union[locations_pb2.Location, Awaitable[locations_pb2.Location]],
335
+ ]:
336
+ raise NotImplementedError()
337
+
338
+ @property
339
+ def list_locations(
340
+ self,
341
+ ) -> Callable[
342
+ [locations_pb2.ListLocationsRequest],
343
+ Union[
344
+ locations_pb2.ListLocationsResponse,
345
+ Awaitable[locations_pb2.ListLocationsResponse],
346
+ ],
347
+ ]:
348
+ raise NotImplementedError()
349
+
350
+ @property
351
+ def kind(self) -> str:
352
+ raise NotImplementedError()
353
+
354
+
355
+ __all__ = ("MemorystoreTransport",)