google-cloud-datastream 1.13.2__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 (44) hide show
  1. google/cloud/datastream/__init__.py +219 -0
  2. google/cloud/datastream/gapic_version.py +16 -0
  3. google/cloud/datastream/py.typed +2 -0
  4. google/cloud/datastream_v1/__init__.py +216 -0
  5. google/cloud/datastream_v1/gapic_metadata.json +418 -0
  6. google/cloud/datastream_v1/gapic_version.py +16 -0
  7. google/cloud/datastream_v1/py.typed +2 -0
  8. google/cloud/datastream_v1/services/__init__.py +15 -0
  9. google/cloud/datastream_v1/services/datastream/__init__.py +22 -0
  10. google/cloud/datastream_v1/services/datastream/async_client.py +3939 -0
  11. google/cloud/datastream_v1/services/datastream/client.py +4420 -0
  12. google/cloud/datastream_v1/services/datastream/pagers.py +977 -0
  13. google/cloud/datastream_v1/services/datastream/transports/__init__.py +36 -0
  14. google/cloud/datastream_v1/services/datastream/transports/base.py +639 -0
  15. google/cloud/datastream_v1/services/datastream/transports/grpc.py +1193 -0
  16. google/cloud/datastream_v1/services/datastream/transports/grpc_asyncio.py +1389 -0
  17. google/cloud/datastream_v1/services/datastream/transports/rest.py +6861 -0
  18. google/cloud/datastream_v1/services/datastream/transports/rest_base.py +1591 -0
  19. google/cloud/datastream_v1/types/__init__.py +208 -0
  20. google/cloud/datastream_v1/types/datastream.py +1491 -0
  21. google/cloud/datastream_v1/types/datastream_resources.py +2986 -0
  22. google/cloud/datastream_v1alpha1/__init__.py +156 -0
  23. google/cloud/datastream_v1alpha1/gapic_metadata.json +343 -0
  24. google/cloud/datastream_v1alpha1/gapic_version.py +16 -0
  25. google/cloud/datastream_v1alpha1/py.typed +2 -0
  26. google/cloud/datastream_v1alpha1/services/__init__.py +15 -0
  27. google/cloud/datastream_v1alpha1/services/datastream/__init__.py +22 -0
  28. google/cloud/datastream_v1alpha1/services/datastream/async_client.py +3018 -0
  29. google/cloud/datastream_v1alpha1/services/datastream/client.py +3458 -0
  30. google/cloud/datastream_v1alpha1/services/datastream/pagers.py +821 -0
  31. google/cloud/datastream_v1alpha1/services/datastream/transports/__init__.py +36 -0
  32. google/cloud/datastream_v1alpha1/services/datastream/transports/base.py +467 -0
  33. google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py +942 -0
  34. google/cloud/datastream_v1alpha1/services/datastream/transports/grpc_asyncio.py +1078 -0
  35. google/cloud/datastream_v1alpha1/services/datastream/transports/rest.py +4770 -0
  36. google/cloud/datastream_v1alpha1/services/datastream/transports/rest_base.py +1152 -0
  37. google/cloud/datastream_v1alpha1/types/__init__.py +148 -0
  38. google/cloud/datastream_v1alpha1/types/datastream.py +1230 -0
  39. google/cloud/datastream_v1alpha1/types/datastream_resources.py +1416 -0
  40. google_cloud_datastream-1.13.2.dist-info/LICENSE +202 -0
  41. google_cloud_datastream-1.13.2.dist-info/METADATA +229 -0
  42. google_cloud_datastream-1.13.2.dist-info/RECORD +44 -0
  43. google_cloud_datastream-1.13.2.dist-info/WHEEL +5 -0
  44. google_cloud_datastream-1.13.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,4420 @@
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 http import HTTPStatus
18
+ import json
19
+ import logging as std_logging
20
+ import os
21
+ import re
22
+ from typing import (
23
+ Callable,
24
+ Dict,
25
+ Mapping,
26
+ MutableMapping,
27
+ MutableSequence,
28
+ Optional,
29
+ Sequence,
30
+ Tuple,
31
+ Type,
32
+ Union,
33
+ cast,
34
+ )
35
+ import warnings
36
+
37
+ from google.api_core import client_options as client_options_lib
38
+ from google.api_core import exceptions as core_exceptions
39
+ from google.api_core import gapic_v1
40
+ from google.api_core import retry as retries
41
+ from google.auth import credentials as ga_credentials # type: ignore
42
+ from google.auth.exceptions import MutualTLSChannelError # type: ignore
43
+ from google.auth.transport import mtls # type: ignore
44
+ from google.auth.transport.grpc import SslCredentials # type: ignore
45
+ from google.oauth2 import service_account # type: ignore
46
+
47
+ from google.cloud.datastream_v1 import gapic_version as package_version
48
+
49
+ try:
50
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
51
+ except AttributeError: # pragma: NO COVER
52
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
53
+
54
+ try:
55
+ from google.api_core import client_logging # type: ignore
56
+
57
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
58
+ except ImportError: # pragma: NO COVER
59
+ CLIENT_LOGGING_SUPPORTED = False
60
+
61
+ _LOGGER = std_logging.getLogger(__name__)
62
+
63
+ from google.api_core import operation # type: ignore
64
+ from google.api_core import operation_async # type: ignore
65
+ from google.cloud.location import locations_pb2 # type: ignore
66
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
67
+ from google.iam.v1 import policy_pb2 # type: ignore
68
+ from google.longrunning import operations_pb2 # type: ignore
69
+ from google.protobuf import empty_pb2 # type: ignore
70
+ from google.protobuf import field_mask_pb2 # type: ignore
71
+ from google.protobuf import timestamp_pb2 # type: ignore
72
+
73
+ from google.cloud.datastream_v1.services.datastream import pagers
74
+ from google.cloud.datastream_v1.types import datastream, datastream_resources
75
+
76
+ from .transports.base import DEFAULT_CLIENT_INFO, DatastreamTransport
77
+ from .transports.grpc import DatastreamGrpcTransport
78
+ from .transports.grpc_asyncio import DatastreamGrpcAsyncIOTransport
79
+ from .transports.rest import DatastreamRestTransport
80
+
81
+
82
+ class DatastreamClientMeta(type):
83
+ """Metaclass for the Datastream client.
84
+
85
+ This provides class-level methods for building and retrieving
86
+ support objects (e.g. transport) without polluting the client instance
87
+ objects.
88
+ """
89
+
90
+ _transport_registry = OrderedDict() # type: Dict[str, Type[DatastreamTransport]]
91
+ _transport_registry["grpc"] = DatastreamGrpcTransport
92
+ _transport_registry["grpc_asyncio"] = DatastreamGrpcAsyncIOTransport
93
+ _transport_registry["rest"] = DatastreamRestTransport
94
+
95
+ def get_transport_class(
96
+ cls,
97
+ label: Optional[str] = None,
98
+ ) -> Type[DatastreamTransport]:
99
+ """Returns an appropriate transport class.
100
+
101
+ Args:
102
+ label: The name of the desired transport. If none is
103
+ provided, then the first transport in the registry is used.
104
+
105
+ Returns:
106
+ The transport class to use.
107
+ """
108
+ # If a specific transport is requested, return that one.
109
+ if label:
110
+ return cls._transport_registry[label]
111
+
112
+ # No transport is requested; return the default (that is, the first one
113
+ # in the dictionary).
114
+ return next(iter(cls._transport_registry.values()))
115
+
116
+
117
+ class DatastreamClient(metaclass=DatastreamClientMeta):
118
+ """Datastream service"""
119
+
120
+ @staticmethod
121
+ def _get_default_mtls_endpoint(api_endpoint):
122
+ """Converts api endpoint to mTLS endpoint.
123
+
124
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
125
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
126
+ Args:
127
+ api_endpoint (Optional[str]): the api endpoint to convert.
128
+ Returns:
129
+ str: converted mTLS api endpoint.
130
+ """
131
+ if not api_endpoint:
132
+ return api_endpoint
133
+
134
+ mtls_endpoint_re = re.compile(
135
+ r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
136
+ )
137
+
138
+ m = mtls_endpoint_re.match(api_endpoint)
139
+ name, mtls, sandbox, googledomain = m.groups()
140
+ if mtls or not googledomain:
141
+ return api_endpoint
142
+
143
+ if sandbox:
144
+ return api_endpoint.replace(
145
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
146
+ )
147
+
148
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
149
+
150
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
151
+ DEFAULT_ENDPOINT = "datastream.googleapis.com"
152
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
153
+ DEFAULT_ENDPOINT
154
+ )
155
+
156
+ _DEFAULT_ENDPOINT_TEMPLATE = "datastream.{UNIVERSE_DOMAIN}"
157
+ _DEFAULT_UNIVERSE = "googleapis.com"
158
+
159
+ @classmethod
160
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
161
+ """Creates an instance of this client using the provided credentials
162
+ info.
163
+
164
+ Args:
165
+ info (dict): The service account private key info.
166
+ args: Additional arguments to pass to the constructor.
167
+ kwargs: Additional arguments to pass to the constructor.
168
+
169
+ Returns:
170
+ DatastreamClient: The constructed client.
171
+ """
172
+ credentials = service_account.Credentials.from_service_account_info(info)
173
+ kwargs["credentials"] = credentials
174
+ return cls(*args, **kwargs)
175
+
176
+ @classmethod
177
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
178
+ """Creates an instance of this client using the provided credentials
179
+ file.
180
+
181
+ Args:
182
+ filename (str): The path to the service account private key json
183
+ file.
184
+ args: Additional arguments to pass to the constructor.
185
+ kwargs: Additional arguments to pass to the constructor.
186
+
187
+ Returns:
188
+ DatastreamClient: The constructed client.
189
+ """
190
+ credentials = service_account.Credentials.from_service_account_file(filename)
191
+ kwargs["credentials"] = credentials
192
+ return cls(*args, **kwargs)
193
+
194
+ from_service_account_json = from_service_account_file
195
+
196
+ @property
197
+ def transport(self) -> DatastreamTransport:
198
+ """Returns the transport used by the client instance.
199
+
200
+ Returns:
201
+ DatastreamTransport: The transport used by the client
202
+ instance.
203
+ """
204
+ return self._transport
205
+
206
+ @staticmethod
207
+ def connection_profile_path(
208
+ project: str,
209
+ location: str,
210
+ connection_profile: str,
211
+ ) -> str:
212
+ """Returns a fully-qualified connection_profile string."""
213
+ return "projects/{project}/locations/{location}/connectionProfiles/{connection_profile}".format(
214
+ project=project,
215
+ location=location,
216
+ connection_profile=connection_profile,
217
+ )
218
+
219
+ @staticmethod
220
+ def parse_connection_profile_path(path: str) -> Dict[str, str]:
221
+ """Parses a connection_profile path into its component segments."""
222
+ m = re.match(
223
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/connectionProfiles/(?P<connection_profile>.+?)$",
224
+ path,
225
+ )
226
+ return m.groupdict() if m else {}
227
+
228
+ @staticmethod
229
+ def networks_path(
230
+ project: str,
231
+ network: str,
232
+ ) -> str:
233
+ """Returns a fully-qualified networks string."""
234
+ return "projects/{project}/global/networks/{network}".format(
235
+ project=project,
236
+ network=network,
237
+ )
238
+
239
+ @staticmethod
240
+ def parse_networks_path(path: str) -> Dict[str, str]:
241
+ """Parses a networks path into its component segments."""
242
+ m = re.match(
243
+ r"^projects/(?P<project>.+?)/global/networks/(?P<network>.+?)$", path
244
+ )
245
+ return m.groupdict() if m else {}
246
+
247
+ @staticmethod
248
+ def private_connection_path(
249
+ project: str,
250
+ location: str,
251
+ private_connection: str,
252
+ ) -> str:
253
+ """Returns a fully-qualified private_connection string."""
254
+ return "projects/{project}/locations/{location}/privateConnections/{private_connection}".format(
255
+ project=project,
256
+ location=location,
257
+ private_connection=private_connection,
258
+ )
259
+
260
+ @staticmethod
261
+ def parse_private_connection_path(path: str) -> Dict[str, str]:
262
+ """Parses a private_connection path into its component segments."""
263
+ m = re.match(
264
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/privateConnections/(?P<private_connection>.+?)$",
265
+ path,
266
+ )
267
+ return m.groupdict() if m else {}
268
+
269
+ @staticmethod
270
+ def route_path(
271
+ project: str,
272
+ location: str,
273
+ private_connection: str,
274
+ route: str,
275
+ ) -> str:
276
+ """Returns a fully-qualified route string."""
277
+ return "projects/{project}/locations/{location}/privateConnections/{private_connection}/routes/{route}".format(
278
+ project=project,
279
+ location=location,
280
+ private_connection=private_connection,
281
+ route=route,
282
+ )
283
+
284
+ @staticmethod
285
+ def parse_route_path(path: str) -> Dict[str, str]:
286
+ """Parses a route path into its component segments."""
287
+ m = re.match(
288
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/privateConnections/(?P<private_connection>.+?)/routes/(?P<route>.+?)$",
289
+ path,
290
+ )
291
+ return m.groupdict() if m else {}
292
+
293
+ @staticmethod
294
+ def stream_path(
295
+ project: str,
296
+ location: str,
297
+ stream: str,
298
+ ) -> str:
299
+ """Returns a fully-qualified stream string."""
300
+ return "projects/{project}/locations/{location}/streams/{stream}".format(
301
+ project=project,
302
+ location=location,
303
+ stream=stream,
304
+ )
305
+
306
+ @staticmethod
307
+ def parse_stream_path(path: str) -> Dict[str, str]:
308
+ """Parses a stream path into its component segments."""
309
+ m = re.match(
310
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/streams/(?P<stream>.+?)$",
311
+ path,
312
+ )
313
+ return m.groupdict() if m else {}
314
+
315
+ @staticmethod
316
+ def stream_object_path(
317
+ project: str,
318
+ location: str,
319
+ stream: str,
320
+ object: str,
321
+ ) -> str:
322
+ """Returns a fully-qualified stream_object string."""
323
+ return "projects/{project}/locations/{location}/streams/{stream}/objects/{object}".format(
324
+ project=project,
325
+ location=location,
326
+ stream=stream,
327
+ object=object,
328
+ )
329
+
330
+ @staticmethod
331
+ def parse_stream_object_path(path: str) -> Dict[str, str]:
332
+ """Parses a stream_object path into its component segments."""
333
+ m = re.match(
334
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/streams/(?P<stream>.+?)/objects/(?P<object>.+?)$",
335
+ path,
336
+ )
337
+ return m.groupdict() if m else {}
338
+
339
+ @staticmethod
340
+ def common_billing_account_path(
341
+ billing_account: str,
342
+ ) -> str:
343
+ """Returns a fully-qualified billing_account string."""
344
+ return "billingAccounts/{billing_account}".format(
345
+ billing_account=billing_account,
346
+ )
347
+
348
+ @staticmethod
349
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
350
+ """Parse a billing_account path into its component segments."""
351
+ m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
352
+ return m.groupdict() if m else {}
353
+
354
+ @staticmethod
355
+ def common_folder_path(
356
+ folder: str,
357
+ ) -> str:
358
+ """Returns a fully-qualified folder string."""
359
+ return "folders/{folder}".format(
360
+ folder=folder,
361
+ )
362
+
363
+ @staticmethod
364
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
365
+ """Parse a folder path into its component segments."""
366
+ m = re.match(r"^folders/(?P<folder>.+?)$", path)
367
+ return m.groupdict() if m else {}
368
+
369
+ @staticmethod
370
+ def common_organization_path(
371
+ organization: str,
372
+ ) -> str:
373
+ """Returns a fully-qualified organization string."""
374
+ return "organizations/{organization}".format(
375
+ organization=organization,
376
+ )
377
+
378
+ @staticmethod
379
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
380
+ """Parse a organization path into its component segments."""
381
+ m = re.match(r"^organizations/(?P<organization>.+?)$", path)
382
+ return m.groupdict() if m else {}
383
+
384
+ @staticmethod
385
+ def common_project_path(
386
+ project: str,
387
+ ) -> str:
388
+ """Returns a fully-qualified project string."""
389
+ return "projects/{project}".format(
390
+ project=project,
391
+ )
392
+
393
+ @staticmethod
394
+ def parse_common_project_path(path: str) -> Dict[str, str]:
395
+ """Parse a project path into its component segments."""
396
+ m = re.match(r"^projects/(?P<project>.+?)$", path)
397
+ return m.groupdict() if m else {}
398
+
399
+ @staticmethod
400
+ def common_location_path(
401
+ project: str,
402
+ location: str,
403
+ ) -> str:
404
+ """Returns a fully-qualified location string."""
405
+ return "projects/{project}/locations/{location}".format(
406
+ project=project,
407
+ location=location,
408
+ )
409
+
410
+ @staticmethod
411
+ def parse_common_location_path(path: str) -> Dict[str, str]:
412
+ """Parse a location path into its component segments."""
413
+ m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
414
+ return m.groupdict() if m else {}
415
+
416
+ @classmethod
417
+ def get_mtls_endpoint_and_cert_source(
418
+ cls, client_options: Optional[client_options_lib.ClientOptions] = None
419
+ ):
420
+ """Deprecated. Return the API endpoint and client cert source for mutual TLS.
421
+
422
+ The client cert source is determined in the following order:
423
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
424
+ client cert source is None.
425
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
426
+ default client cert source exists, use the default one; otherwise the client cert
427
+ source is None.
428
+
429
+ The API endpoint is determined in the following order:
430
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
431
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
432
+ default mTLS endpoint; if the environment variable is "never", use the default API
433
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
434
+ use the default API endpoint.
435
+
436
+ More details can be found at https://google.aip.dev/auth/4114.
437
+
438
+ Args:
439
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
440
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
441
+ in this method.
442
+
443
+ Returns:
444
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
445
+ client cert source to use.
446
+
447
+ Raises:
448
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
449
+ """
450
+
451
+ warnings.warn(
452
+ "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
453
+ DeprecationWarning,
454
+ )
455
+ if client_options is None:
456
+ client_options = client_options_lib.ClientOptions()
457
+ use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
458
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
459
+ if use_client_cert not in ("true", "false"):
460
+ raise ValueError(
461
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
462
+ )
463
+ if use_mtls_endpoint not in ("auto", "never", "always"):
464
+ raise MutualTLSChannelError(
465
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
466
+ )
467
+
468
+ # Figure out the client cert source to use.
469
+ client_cert_source = None
470
+ if use_client_cert == "true":
471
+ if client_options.client_cert_source:
472
+ client_cert_source = client_options.client_cert_source
473
+ elif mtls.has_default_client_cert_source():
474
+ client_cert_source = mtls.default_client_cert_source()
475
+
476
+ # Figure out which api endpoint to use.
477
+ if client_options.api_endpoint is not None:
478
+ api_endpoint = client_options.api_endpoint
479
+ elif use_mtls_endpoint == "always" or (
480
+ use_mtls_endpoint == "auto" and client_cert_source
481
+ ):
482
+ api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
483
+ else:
484
+ api_endpoint = cls.DEFAULT_ENDPOINT
485
+
486
+ return api_endpoint, client_cert_source
487
+
488
+ @staticmethod
489
+ def _read_environment_variables():
490
+ """Returns the environment variables used by the client.
491
+
492
+ Returns:
493
+ Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
494
+ GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
495
+
496
+ Raises:
497
+ ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
498
+ any of ["true", "false"].
499
+ google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
500
+ is not any of ["auto", "never", "always"].
501
+ """
502
+ use_client_cert = os.getenv(
503
+ "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
504
+ ).lower()
505
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
506
+ universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
507
+ if use_client_cert not in ("true", "false"):
508
+ raise ValueError(
509
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
510
+ )
511
+ if use_mtls_endpoint not in ("auto", "never", "always"):
512
+ raise MutualTLSChannelError(
513
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
514
+ )
515
+ return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
516
+
517
+ @staticmethod
518
+ def _get_client_cert_source(provided_cert_source, use_cert_flag):
519
+ """Return the client cert source to be used by the client.
520
+
521
+ Args:
522
+ provided_cert_source (bytes): The client certificate source provided.
523
+ use_cert_flag (bool): A flag indicating whether to use the client certificate.
524
+
525
+ Returns:
526
+ bytes or None: The client cert source to be used by the client.
527
+ """
528
+ client_cert_source = None
529
+ if use_cert_flag:
530
+ if provided_cert_source:
531
+ client_cert_source = provided_cert_source
532
+ elif mtls.has_default_client_cert_source():
533
+ client_cert_source = mtls.default_client_cert_source()
534
+ return client_cert_source
535
+
536
+ @staticmethod
537
+ def _get_api_endpoint(
538
+ api_override, client_cert_source, universe_domain, use_mtls_endpoint
539
+ ):
540
+ """Return the API endpoint used by the client.
541
+
542
+ Args:
543
+ api_override (str): The API endpoint override. If specified, this is always
544
+ the return value of this function and the other arguments are not used.
545
+ client_cert_source (bytes): The client certificate source used by the client.
546
+ universe_domain (str): The universe domain used by the client.
547
+ use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
548
+ Possible values are "always", "auto", or "never".
549
+
550
+ Returns:
551
+ str: The API endpoint to be used by the client.
552
+ """
553
+ if api_override is not None:
554
+ api_endpoint = api_override
555
+ elif use_mtls_endpoint == "always" or (
556
+ use_mtls_endpoint == "auto" and client_cert_source
557
+ ):
558
+ _default_universe = DatastreamClient._DEFAULT_UNIVERSE
559
+ if universe_domain != _default_universe:
560
+ raise MutualTLSChannelError(
561
+ f"mTLS is not supported in any universe other than {_default_universe}."
562
+ )
563
+ api_endpoint = DatastreamClient.DEFAULT_MTLS_ENDPOINT
564
+ else:
565
+ api_endpoint = DatastreamClient._DEFAULT_ENDPOINT_TEMPLATE.format(
566
+ UNIVERSE_DOMAIN=universe_domain
567
+ )
568
+ return api_endpoint
569
+
570
+ @staticmethod
571
+ def _get_universe_domain(
572
+ client_universe_domain: Optional[str], universe_domain_env: Optional[str]
573
+ ) -> str:
574
+ """Return the universe domain used by the client.
575
+
576
+ Args:
577
+ client_universe_domain (Optional[str]): The universe domain configured via the client options.
578
+ universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
579
+
580
+ Returns:
581
+ str: The universe domain to be used by the client.
582
+
583
+ Raises:
584
+ ValueError: If the universe domain is an empty string.
585
+ """
586
+ universe_domain = DatastreamClient._DEFAULT_UNIVERSE
587
+ if client_universe_domain is not None:
588
+ universe_domain = client_universe_domain
589
+ elif universe_domain_env is not None:
590
+ universe_domain = universe_domain_env
591
+ if len(universe_domain.strip()) == 0:
592
+ raise ValueError("Universe Domain cannot be an empty string.")
593
+ return universe_domain
594
+
595
+ def _validate_universe_domain(self):
596
+ """Validates client's and credentials' universe domains are consistent.
597
+
598
+ Returns:
599
+ bool: True iff the configured universe domain is valid.
600
+
601
+ Raises:
602
+ ValueError: If the configured universe domain is not valid.
603
+ """
604
+
605
+ # NOTE (b/349488459): universe validation is disabled until further notice.
606
+ return True
607
+
608
+ def _add_cred_info_for_auth_errors(
609
+ self, error: core_exceptions.GoogleAPICallError
610
+ ) -> None:
611
+ """Adds credential info string to error details for 401/403/404 errors.
612
+
613
+ Args:
614
+ error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
615
+ """
616
+ if error.code not in [
617
+ HTTPStatus.UNAUTHORIZED,
618
+ HTTPStatus.FORBIDDEN,
619
+ HTTPStatus.NOT_FOUND,
620
+ ]:
621
+ return
622
+
623
+ cred = self._transport._credentials
624
+
625
+ # get_cred_info is only available in google-auth>=2.35.0
626
+ if not hasattr(cred, "get_cred_info"):
627
+ return
628
+
629
+ # ignore the type check since pypy test fails when get_cred_info
630
+ # is not available
631
+ cred_info = cred.get_cred_info() # type: ignore
632
+ if cred_info and hasattr(error._details, "append"):
633
+ error._details.append(json.dumps(cred_info))
634
+
635
+ @property
636
+ def api_endpoint(self):
637
+ """Return the API endpoint used by the client instance.
638
+
639
+ Returns:
640
+ str: The API endpoint used by the client instance.
641
+ """
642
+ return self._api_endpoint
643
+
644
+ @property
645
+ def universe_domain(self) -> str:
646
+ """Return the universe domain used by the client instance.
647
+
648
+ Returns:
649
+ str: The universe domain used by the client instance.
650
+ """
651
+ return self._universe_domain
652
+
653
+ def __init__(
654
+ self,
655
+ *,
656
+ credentials: Optional[ga_credentials.Credentials] = None,
657
+ transport: Optional[
658
+ Union[str, DatastreamTransport, Callable[..., DatastreamTransport]]
659
+ ] = None,
660
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
661
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
662
+ ) -> None:
663
+ """Instantiates the datastream client.
664
+
665
+ Args:
666
+ credentials (Optional[google.auth.credentials.Credentials]): The
667
+ authorization credentials to attach to requests. These
668
+ credentials identify the application to the service; if none
669
+ are specified, the client will attempt to ascertain the
670
+ credentials from the environment.
671
+ transport (Optional[Union[str,DatastreamTransport,Callable[..., DatastreamTransport]]]):
672
+ The transport to use, or a Callable that constructs and returns a new transport.
673
+ If a Callable is given, it will be called with the same set of initialization
674
+ arguments as used in the DatastreamTransport constructor.
675
+ If set to None, a transport is chosen automatically.
676
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
677
+ Custom options for the client.
678
+
679
+ 1. The ``api_endpoint`` property can be used to override the
680
+ default endpoint provided by the client when ``transport`` is
681
+ not explicitly provided. Only if this property is not set and
682
+ ``transport`` was not explicitly provided, the endpoint is
683
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
684
+ variable, which have one of the following values:
685
+ "always" (always use the default mTLS endpoint), "never" (always
686
+ use the default regular endpoint) and "auto" (auto-switch to the
687
+ default mTLS endpoint if client certificate is present; this is
688
+ the default value).
689
+
690
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
691
+ is "true", then the ``client_cert_source`` property can be used
692
+ to provide a client certificate for mTLS transport. If
693
+ not provided, the default SSL client certificate will be used if
694
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
695
+ set, no client certificate will be used.
696
+
697
+ 3. The ``universe_domain`` property can be used to override the
698
+ default "googleapis.com" universe. Note that the ``api_endpoint``
699
+ property still takes precedence; and ``universe_domain`` is
700
+ currently not supported for mTLS.
701
+
702
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
703
+ The client info used to send a user-agent string along with
704
+ API requests. If ``None``, then default info will be used.
705
+ Generally, you only need to set this if you're developing
706
+ your own client library.
707
+
708
+ Raises:
709
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
710
+ creation failed for any reason.
711
+ """
712
+ self._client_options = client_options
713
+ if isinstance(self._client_options, dict):
714
+ self._client_options = client_options_lib.from_dict(self._client_options)
715
+ if self._client_options is None:
716
+ self._client_options = client_options_lib.ClientOptions()
717
+ self._client_options = cast(
718
+ client_options_lib.ClientOptions, self._client_options
719
+ )
720
+
721
+ universe_domain_opt = getattr(self._client_options, "universe_domain", None)
722
+
723
+ (
724
+ self._use_client_cert,
725
+ self._use_mtls_endpoint,
726
+ self._universe_domain_env,
727
+ ) = DatastreamClient._read_environment_variables()
728
+ self._client_cert_source = DatastreamClient._get_client_cert_source(
729
+ self._client_options.client_cert_source, self._use_client_cert
730
+ )
731
+ self._universe_domain = DatastreamClient._get_universe_domain(
732
+ universe_domain_opt, self._universe_domain_env
733
+ )
734
+ self._api_endpoint = None # updated below, depending on `transport`
735
+
736
+ # Initialize the universe domain validation.
737
+ self._is_universe_domain_valid = False
738
+
739
+ if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
740
+ # Setup logging.
741
+ client_logging.initialize_logging()
742
+
743
+ api_key_value = getattr(self._client_options, "api_key", None)
744
+ if api_key_value and credentials:
745
+ raise ValueError(
746
+ "client_options.api_key and credentials are mutually exclusive"
747
+ )
748
+
749
+ # Save or instantiate the transport.
750
+ # Ordinarily, we provide the transport, but allowing a custom transport
751
+ # instance provides an extensibility point for unusual situations.
752
+ transport_provided = isinstance(transport, DatastreamTransport)
753
+ if transport_provided:
754
+ # transport is a DatastreamTransport instance.
755
+ if credentials or self._client_options.credentials_file or api_key_value:
756
+ raise ValueError(
757
+ "When providing a transport instance, "
758
+ "provide its credentials directly."
759
+ )
760
+ if self._client_options.scopes:
761
+ raise ValueError(
762
+ "When providing a transport instance, provide its scopes "
763
+ "directly."
764
+ )
765
+ self._transport = cast(DatastreamTransport, transport)
766
+ self._api_endpoint = self._transport.host
767
+
768
+ self._api_endpoint = self._api_endpoint or DatastreamClient._get_api_endpoint(
769
+ self._client_options.api_endpoint,
770
+ self._client_cert_source,
771
+ self._universe_domain,
772
+ self._use_mtls_endpoint,
773
+ )
774
+
775
+ if not transport_provided:
776
+ import google.auth._default # type: ignore
777
+
778
+ if api_key_value and hasattr(
779
+ google.auth._default, "get_api_key_credentials"
780
+ ):
781
+ credentials = google.auth._default.get_api_key_credentials(
782
+ api_key_value
783
+ )
784
+
785
+ transport_init: Union[
786
+ Type[DatastreamTransport], Callable[..., DatastreamTransport]
787
+ ] = (
788
+ DatastreamClient.get_transport_class(transport)
789
+ if isinstance(transport, str) or transport is None
790
+ else cast(Callable[..., DatastreamTransport], transport)
791
+ )
792
+ # initialize with the provided callable or the passed in class
793
+ self._transport = transport_init(
794
+ credentials=credentials,
795
+ credentials_file=self._client_options.credentials_file,
796
+ host=self._api_endpoint,
797
+ scopes=self._client_options.scopes,
798
+ client_cert_source_for_mtls=self._client_cert_source,
799
+ quota_project_id=self._client_options.quota_project_id,
800
+ client_info=client_info,
801
+ always_use_jwt_access=True,
802
+ api_audience=self._client_options.api_audience,
803
+ )
804
+
805
+ if "async" not in str(self._transport):
806
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
807
+ std_logging.DEBUG
808
+ ): # pragma: NO COVER
809
+ _LOGGER.debug(
810
+ "Created client `google.cloud.datastream_v1.DatastreamClient`.",
811
+ extra={
812
+ "serviceName": "google.cloud.datastream.v1.Datastream",
813
+ "universeDomain": getattr(
814
+ self._transport._credentials, "universe_domain", ""
815
+ ),
816
+ "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
817
+ "credentialsInfo": getattr(
818
+ self.transport._credentials, "get_cred_info", lambda: None
819
+ )(),
820
+ }
821
+ if hasattr(self._transport, "_credentials")
822
+ else {
823
+ "serviceName": "google.cloud.datastream.v1.Datastream",
824
+ "credentialsType": None,
825
+ },
826
+ )
827
+
828
+ def list_connection_profiles(
829
+ self,
830
+ request: Optional[Union[datastream.ListConnectionProfilesRequest, dict]] = None,
831
+ *,
832
+ parent: Optional[str] = None,
833
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
834
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
835
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
836
+ ) -> pagers.ListConnectionProfilesPager:
837
+ r"""Use this method to list connection profiles created
838
+ in a project and location.
839
+
840
+ .. code-block:: python
841
+
842
+ # This snippet has been automatically generated and should be regarded as a
843
+ # code template only.
844
+ # It will require modifications to work:
845
+ # - It may require correct/in-range values for request initialization.
846
+ # - It may require specifying regional endpoints when creating the service
847
+ # client as shown in:
848
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
849
+ from google.cloud import datastream_v1
850
+
851
+ def sample_list_connection_profiles():
852
+ # Create a client
853
+ client = datastream_v1.DatastreamClient()
854
+
855
+ # Initialize request argument(s)
856
+ request = datastream_v1.ListConnectionProfilesRequest(
857
+ parent="parent_value",
858
+ )
859
+
860
+ # Make the request
861
+ page_result = client.list_connection_profiles(request=request)
862
+
863
+ # Handle the response
864
+ for response in page_result:
865
+ print(response)
866
+
867
+ Args:
868
+ request (Union[google.cloud.datastream_v1.types.ListConnectionProfilesRequest, dict]):
869
+ The request object. Request message for listing
870
+ connection profiles.
871
+ parent (str):
872
+ Required. The parent that owns the
873
+ collection of connection profiles.
874
+
875
+ This corresponds to the ``parent`` field
876
+ on the ``request`` instance; if ``request`` is provided, this
877
+ should not be set.
878
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
879
+ should be retried.
880
+ timeout (float): The timeout for this request.
881
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
882
+ sent along with the request as metadata. Normally, each value must be of type `str`,
883
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
884
+ be of type `bytes`.
885
+
886
+ Returns:
887
+ google.cloud.datastream_v1.services.datastream.pagers.ListConnectionProfilesPager:
888
+ Response message for listing
889
+ connection profiles.
890
+ Iterating over this object will yield
891
+ results and resolve additional pages
892
+ automatically.
893
+
894
+ """
895
+ # Create or coerce a protobuf request object.
896
+ # - Quick check: If we got a request object, we should *not* have
897
+ # gotten any keyword arguments that map to the request.
898
+ flattened_params = [parent]
899
+ has_flattened_params = (
900
+ len([param for param in flattened_params if param is not None]) > 0
901
+ )
902
+ if request is not None and has_flattened_params:
903
+ raise ValueError(
904
+ "If the `request` argument is set, then none of "
905
+ "the individual field arguments should be set."
906
+ )
907
+
908
+ # - Use the request object if provided (there's no risk of modifying the input as
909
+ # there are no flattened fields), or create one.
910
+ if not isinstance(request, datastream.ListConnectionProfilesRequest):
911
+ request = datastream.ListConnectionProfilesRequest(request)
912
+ # If we have keyword arguments corresponding to fields on the
913
+ # request, apply these.
914
+ if parent is not None:
915
+ request.parent = parent
916
+
917
+ # Wrap the RPC method; this adds retry and timeout information,
918
+ # and friendly error handling.
919
+ rpc = self._transport._wrapped_methods[self._transport.list_connection_profiles]
920
+
921
+ # Certain fields should be provided within the metadata header;
922
+ # add these here.
923
+ metadata = tuple(metadata) + (
924
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
925
+ )
926
+
927
+ # Validate the universe domain.
928
+ self._validate_universe_domain()
929
+
930
+ # Send the request.
931
+ response = rpc(
932
+ request,
933
+ retry=retry,
934
+ timeout=timeout,
935
+ metadata=metadata,
936
+ )
937
+
938
+ # This method is paged; wrap the response in a pager, which provides
939
+ # an `__iter__` convenience method.
940
+ response = pagers.ListConnectionProfilesPager(
941
+ method=rpc,
942
+ request=request,
943
+ response=response,
944
+ retry=retry,
945
+ timeout=timeout,
946
+ metadata=metadata,
947
+ )
948
+
949
+ # Done; return the response.
950
+ return response
951
+
952
+ def get_connection_profile(
953
+ self,
954
+ request: Optional[Union[datastream.GetConnectionProfileRequest, dict]] = None,
955
+ *,
956
+ name: Optional[str] = None,
957
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
958
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
959
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
960
+ ) -> datastream_resources.ConnectionProfile:
961
+ r"""Use this method to get details about a connection
962
+ profile.
963
+
964
+ .. code-block:: python
965
+
966
+ # This snippet has been automatically generated and should be regarded as a
967
+ # code template only.
968
+ # It will require modifications to work:
969
+ # - It may require correct/in-range values for request initialization.
970
+ # - It may require specifying regional endpoints when creating the service
971
+ # client as shown in:
972
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
973
+ from google.cloud import datastream_v1
974
+
975
+ def sample_get_connection_profile():
976
+ # Create a client
977
+ client = datastream_v1.DatastreamClient()
978
+
979
+ # Initialize request argument(s)
980
+ request = datastream_v1.GetConnectionProfileRequest(
981
+ name="name_value",
982
+ )
983
+
984
+ # Make the request
985
+ response = client.get_connection_profile(request=request)
986
+
987
+ # Handle the response
988
+ print(response)
989
+
990
+ Args:
991
+ request (Union[google.cloud.datastream_v1.types.GetConnectionProfileRequest, dict]):
992
+ The request object. Request message for getting a
993
+ connection profile.
994
+ name (str):
995
+ Required. The name of the connection
996
+ profile resource to get.
997
+
998
+ This corresponds to the ``name`` field
999
+ on the ``request`` instance; if ``request`` is provided, this
1000
+ should not be set.
1001
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1002
+ should be retried.
1003
+ timeout (float): The timeout for this request.
1004
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1005
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1006
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1007
+ be of type `bytes`.
1008
+
1009
+ Returns:
1010
+ google.cloud.datastream_v1.types.ConnectionProfile:
1011
+ A set of reusable connection
1012
+ configurations to be used as a source or
1013
+ destination for a stream.
1014
+
1015
+ """
1016
+ # Create or coerce a protobuf request object.
1017
+ # - Quick check: If we got a request object, we should *not* have
1018
+ # gotten any keyword arguments that map to the request.
1019
+ flattened_params = [name]
1020
+ has_flattened_params = (
1021
+ len([param for param in flattened_params if param is not None]) > 0
1022
+ )
1023
+ if request is not None and has_flattened_params:
1024
+ raise ValueError(
1025
+ "If the `request` argument is set, then none of "
1026
+ "the individual field arguments should be set."
1027
+ )
1028
+
1029
+ # - Use the request object if provided (there's no risk of modifying the input as
1030
+ # there are no flattened fields), or create one.
1031
+ if not isinstance(request, datastream.GetConnectionProfileRequest):
1032
+ request = datastream.GetConnectionProfileRequest(request)
1033
+ # If we have keyword arguments corresponding to fields on the
1034
+ # request, apply these.
1035
+ if name is not None:
1036
+ request.name = name
1037
+
1038
+ # Wrap the RPC method; this adds retry and timeout information,
1039
+ # and friendly error handling.
1040
+ rpc = self._transport._wrapped_methods[self._transport.get_connection_profile]
1041
+
1042
+ # Certain fields should be provided within the metadata header;
1043
+ # add these here.
1044
+ metadata = tuple(metadata) + (
1045
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1046
+ )
1047
+
1048
+ # Validate the universe domain.
1049
+ self._validate_universe_domain()
1050
+
1051
+ # Send the request.
1052
+ response = rpc(
1053
+ request,
1054
+ retry=retry,
1055
+ timeout=timeout,
1056
+ metadata=metadata,
1057
+ )
1058
+
1059
+ # Done; return the response.
1060
+ return response
1061
+
1062
+ def create_connection_profile(
1063
+ self,
1064
+ request: Optional[
1065
+ Union[datastream.CreateConnectionProfileRequest, dict]
1066
+ ] = None,
1067
+ *,
1068
+ parent: Optional[str] = None,
1069
+ connection_profile: Optional[datastream_resources.ConnectionProfile] = None,
1070
+ connection_profile_id: Optional[str] = None,
1071
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1072
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1073
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1074
+ ) -> operation.Operation:
1075
+ r"""Use this method to create a connection profile in a
1076
+ project and location.
1077
+
1078
+ .. code-block:: python
1079
+
1080
+ # This snippet has been automatically generated and should be regarded as a
1081
+ # code template only.
1082
+ # It will require modifications to work:
1083
+ # - It may require correct/in-range values for request initialization.
1084
+ # - It may require specifying regional endpoints when creating the service
1085
+ # client as shown in:
1086
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1087
+ from google.cloud import datastream_v1
1088
+
1089
+ def sample_create_connection_profile():
1090
+ # Create a client
1091
+ client = datastream_v1.DatastreamClient()
1092
+
1093
+ # Initialize request argument(s)
1094
+ connection_profile = datastream_v1.ConnectionProfile()
1095
+ connection_profile.oracle_profile.hostname = "hostname_value"
1096
+ connection_profile.oracle_profile.username = "username_value"
1097
+ connection_profile.oracle_profile.database_service = "database_service_value"
1098
+ connection_profile.display_name = "display_name_value"
1099
+
1100
+ request = datastream_v1.CreateConnectionProfileRequest(
1101
+ parent="parent_value",
1102
+ connection_profile_id="connection_profile_id_value",
1103
+ connection_profile=connection_profile,
1104
+ )
1105
+
1106
+ # Make the request
1107
+ operation = client.create_connection_profile(request=request)
1108
+
1109
+ print("Waiting for operation to complete...")
1110
+
1111
+ response = operation.result()
1112
+
1113
+ # Handle the response
1114
+ print(response)
1115
+
1116
+ Args:
1117
+ request (Union[google.cloud.datastream_v1.types.CreateConnectionProfileRequest, dict]):
1118
+ The request object. Request message for creating a
1119
+ connection profile.
1120
+ parent (str):
1121
+ Required. The parent that owns the
1122
+ collection of ConnectionProfiles.
1123
+
1124
+ This corresponds to the ``parent`` field
1125
+ on the ``request`` instance; if ``request`` is provided, this
1126
+ should not be set.
1127
+ connection_profile (google.cloud.datastream_v1.types.ConnectionProfile):
1128
+ Required. The connection profile
1129
+ resource to create.
1130
+
1131
+ This corresponds to the ``connection_profile`` field
1132
+ on the ``request`` instance; if ``request`` is provided, this
1133
+ should not be set.
1134
+ connection_profile_id (str):
1135
+ Required. The connection profile
1136
+ identifier.
1137
+
1138
+ This corresponds to the ``connection_profile_id`` field
1139
+ on the ``request`` instance; if ``request`` is provided, this
1140
+ should not be set.
1141
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1142
+ should be retried.
1143
+ timeout (float): The timeout for this request.
1144
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1145
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1146
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1147
+ be of type `bytes`.
1148
+
1149
+ Returns:
1150
+ google.api_core.operation.Operation:
1151
+ An object representing a long-running operation.
1152
+
1153
+ The result type for the operation will be :class:`google.cloud.datastream_v1.types.ConnectionProfile` A set of reusable connection configurations to be used as a source or
1154
+ destination for a stream.
1155
+
1156
+ """
1157
+ # Create or coerce a protobuf request object.
1158
+ # - Quick check: If we got a request object, we should *not* have
1159
+ # gotten any keyword arguments that map to the request.
1160
+ flattened_params = [parent, connection_profile, connection_profile_id]
1161
+ has_flattened_params = (
1162
+ len([param for param in flattened_params if param is not None]) > 0
1163
+ )
1164
+ if request is not None and has_flattened_params:
1165
+ raise ValueError(
1166
+ "If the `request` argument is set, then none of "
1167
+ "the individual field arguments should be set."
1168
+ )
1169
+
1170
+ # - Use the request object if provided (there's no risk of modifying the input as
1171
+ # there are no flattened fields), or create one.
1172
+ if not isinstance(request, datastream.CreateConnectionProfileRequest):
1173
+ request = datastream.CreateConnectionProfileRequest(request)
1174
+ # If we have keyword arguments corresponding to fields on the
1175
+ # request, apply these.
1176
+ if parent is not None:
1177
+ request.parent = parent
1178
+ if connection_profile is not None:
1179
+ request.connection_profile = connection_profile
1180
+ if connection_profile_id is not None:
1181
+ request.connection_profile_id = connection_profile_id
1182
+
1183
+ # Wrap the RPC method; this adds retry and timeout information,
1184
+ # and friendly error handling.
1185
+ rpc = self._transport._wrapped_methods[
1186
+ self._transport.create_connection_profile
1187
+ ]
1188
+
1189
+ # Certain fields should be provided within the metadata header;
1190
+ # add these here.
1191
+ metadata = tuple(metadata) + (
1192
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1193
+ )
1194
+
1195
+ # Validate the universe domain.
1196
+ self._validate_universe_domain()
1197
+
1198
+ # Send the request.
1199
+ response = rpc(
1200
+ request,
1201
+ retry=retry,
1202
+ timeout=timeout,
1203
+ metadata=metadata,
1204
+ )
1205
+
1206
+ # Wrap the response in an operation future.
1207
+ response = operation.from_gapic(
1208
+ response,
1209
+ self._transport.operations_client,
1210
+ datastream_resources.ConnectionProfile,
1211
+ metadata_type=datastream.OperationMetadata,
1212
+ )
1213
+
1214
+ # Done; return the response.
1215
+ return response
1216
+
1217
+ def update_connection_profile(
1218
+ self,
1219
+ request: Optional[
1220
+ Union[datastream.UpdateConnectionProfileRequest, dict]
1221
+ ] = None,
1222
+ *,
1223
+ connection_profile: Optional[datastream_resources.ConnectionProfile] = None,
1224
+ update_mask: Optional[field_mask_pb2.FieldMask] = None,
1225
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1226
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1227
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1228
+ ) -> operation.Operation:
1229
+ r"""Use this method to update the parameters of a
1230
+ connection profile.
1231
+
1232
+ .. code-block:: python
1233
+
1234
+ # This snippet has been automatically generated and should be regarded as a
1235
+ # code template only.
1236
+ # It will require modifications to work:
1237
+ # - It may require correct/in-range values for request initialization.
1238
+ # - It may require specifying regional endpoints when creating the service
1239
+ # client as shown in:
1240
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1241
+ from google.cloud import datastream_v1
1242
+
1243
+ def sample_update_connection_profile():
1244
+ # Create a client
1245
+ client = datastream_v1.DatastreamClient()
1246
+
1247
+ # Initialize request argument(s)
1248
+ connection_profile = datastream_v1.ConnectionProfile()
1249
+ connection_profile.oracle_profile.hostname = "hostname_value"
1250
+ connection_profile.oracle_profile.username = "username_value"
1251
+ connection_profile.oracle_profile.database_service = "database_service_value"
1252
+ connection_profile.display_name = "display_name_value"
1253
+
1254
+ request = datastream_v1.UpdateConnectionProfileRequest(
1255
+ connection_profile=connection_profile,
1256
+ )
1257
+
1258
+ # Make the request
1259
+ operation = client.update_connection_profile(request=request)
1260
+
1261
+ print("Waiting for operation to complete...")
1262
+
1263
+ response = operation.result()
1264
+
1265
+ # Handle the response
1266
+ print(response)
1267
+
1268
+ Args:
1269
+ request (Union[google.cloud.datastream_v1.types.UpdateConnectionProfileRequest, dict]):
1270
+ The request object. Connection profile update message.
1271
+ connection_profile (google.cloud.datastream_v1.types.ConnectionProfile):
1272
+ Required. The connection profile to
1273
+ update.
1274
+
1275
+ This corresponds to the ``connection_profile`` field
1276
+ on the ``request`` instance; if ``request`` is provided, this
1277
+ should not be set.
1278
+ update_mask (google.protobuf.field_mask_pb2.FieldMask):
1279
+ Optional. Field mask is used to specify the fields to be
1280
+ overwritten in the ConnectionProfile resource by the
1281
+ update. The fields specified in the update_mask are
1282
+ relative to the resource, not the full request. A field
1283
+ will be overwritten if it is in the mask. If the user
1284
+ does not provide a mask then all fields will be
1285
+ overwritten.
1286
+
1287
+ This corresponds to the ``update_mask`` field
1288
+ on the ``request`` instance; if ``request`` is provided, this
1289
+ should not be set.
1290
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1291
+ should be retried.
1292
+ timeout (float): The timeout for this request.
1293
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1294
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1295
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1296
+ be of type `bytes`.
1297
+
1298
+ Returns:
1299
+ google.api_core.operation.Operation:
1300
+ An object representing a long-running operation.
1301
+
1302
+ The result type for the operation will be :class:`google.cloud.datastream_v1.types.ConnectionProfile` A set of reusable connection configurations to be used as a source or
1303
+ destination for a stream.
1304
+
1305
+ """
1306
+ # Create or coerce a protobuf request object.
1307
+ # - Quick check: If we got a request object, we should *not* have
1308
+ # gotten any keyword arguments that map to the request.
1309
+ flattened_params = [connection_profile, update_mask]
1310
+ has_flattened_params = (
1311
+ len([param for param in flattened_params if param is not None]) > 0
1312
+ )
1313
+ if request is not None and has_flattened_params:
1314
+ raise ValueError(
1315
+ "If the `request` argument is set, then none of "
1316
+ "the individual field arguments should be set."
1317
+ )
1318
+
1319
+ # - Use the request object if provided (there's no risk of modifying the input as
1320
+ # there are no flattened fields), or create one.
1321
+ if not isinstance(request, datastream.UpdateConnectionProfileRequest):
1322
+ request = datastream.UpdateConnectionProfileRequest(request)
1323
+ # If we have keyword arguments corresponding to fields on the
1324
+ # request, apply these.
1325
+ if connection_profile is not None:
1326
+ request.connection_profile = connection_profile
1327
+ if update_mask is not None:
1328
+ request.update_mask = update_mask
1329
+
1330
+ # Wrap the RPC method; this adds retry and timeout information,
1331
+ # and friendly error handling.
1332
+ rpc = self._transport._wrapped_methods[
1333
+ self._transport.update_connection_profile
1334
+ ]
1335
+
1336
+ # Certain fields should be provided within the metadata header;
1337
+ # add these here.
1338
+ metadata = tuple(metadata) + (
1339
+ gapic_v1.routing_header.to_grpc_metadata(
1340
+ (("connection_profile.name", request.connection_profile.name),)
1341
+ ),
1342
+ )
1343
+
1344
+ # Validate the universe domain.
1345
+ self._validate_universe_domain()
1346
+
1347
+ # Send the request.
1348
+ response = rpc(
1349
+ request,
1350
+ retry=retry,
1351
+ timeout=timeout,
1352
+ metadata=metadata,
1353
+ )
1354
+
1355
+ # Wrap the response in an operation future.
1356
+ response = operation.from_gapic(
1357
+ response,
1358
+ self._transport.operations_client,
1359
+ datastream_resources.ConnectionProfile,
1360
+ metadata_type=datastream.OperationMetadata,
1361
+ )
1362
+
1363
+ # Done; return the response.
1364
+ return response
1365
+
1366
+ def delete_connection_profile(
1367
+ self,
1368
+ request: Optional[
1369
+ Union[datastream.DeleteConnectionProfileRequest, dict]
1370
+ ] = None,
1371
+ *,
1372
+ name: Optional[str] = None,
1373
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1374
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1375
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1376
+ ) -> operation.Operation:
1377
+ r"""Use this method to delete a connection profile.
1378
+
1379
+ .. code-block:: python
1380
+
1381
+ # This snippet has been automatically generated and should be regarded as a
1382
+ # code template only.
1383
+ # It will require modifications to work:
1384
+ # - It may require correct/in-range values for request initialization.
1385
+ # - It may require specifying regional endpoints when creating the service
1386
+ # client as shown in:
1387
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1388
+ from google.cloud import datastream_v1
1389
+
1390
+ def sample_delete_connection_profile():
1391
+ # Create a client
1392
+ client = datastream_v1.DatastreamClient()
1393
+
1394
+ # Initialize request argument(s)
1395
+ request = datastream_v1.DeleteConnectionProfileRequest(
1396
+ name="name_value",
1397
+ )
1398
+
1399
+ # Make the request
1400
+ operation = client.delete_connection_profile(request=request)
1401
+
1402
+ print("Waiting for operation to complete...")
1403
+
1404
+ response = operation.result()
1405
+
1406
+ # Handle the response
1407
+ print(response)
1408
+
1409
+ Args:
1410
+ request (Union[google.cloud.datastream_v1.types.DeleteConnectionProfileRequest, dict]):
1411
+ The request object. Request message for deleting a
1412
+ connection profile.
1413
+ name (str):
1414
+ Required. The name of the connection
1415
+ profile resource to delete.
1416
+
1417
+ This corresponds to the ``name`` field
1418
+ on the ``request`` instance; if ``request`` is provided, this
1419
+ should not be set.
1420
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1421
+ should be retried.
1422
+ timeout (float): The timeout for this request.
1423
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1424
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1425
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1426
+ be of type `bytes`.
1427
+
1428
+ Returns:
1429
+ google.api_core.operation.Operation:
1430
+ An object representing a long-running operation.
1431
+
1432
+ 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
1433
+ empty messages in your APIs. A typical example is to
1434
+ use it as the request or the response type of an API
1435
+ method. For instance:
1436
+
1437
+ service Foo {
1438
+ rpc Bar(google.protobuf.Empty) returns
1439
+ (google.protobuf.Empty);
1440
+
1441
+ }
1442
+
1443
+ """
1444
+ # Create or coerce a protobuf request object.
1445
+ # - Quick check: If we got a request object, we should *not* have
1446
+ # gotten any keyword arguments that map to the request.
1447
+ flattened_params = [name]
1448
+ has_flattened_params = (
1449
+ len([param for param in flattened_params if param is not None]) > 0
1450
+ )
1451
+ if request is not None and has_flattened_params:
1452
+ raise ValueError(
1453
+ "If the `request` argument is set, then none of "
1454
+ "the individual field arguments should be set."
1455
+ )
1456
+
1457
+ # - Use the request object if provided (there's no risk of modifying the input as
1458
+ # there are no flattened fields), or create one.
1459
+ if not isinstance(request, datastream.DeleteConnectionProfileRequest):
1460
+ request = datastream.DeleteConnectionProfileRequest(request)
1461
+ # If we have keyword arguments corresponding to fields on the
1462
+ # request, apply these.
1463
+ if name is not None:
1464
+ request.name = name
1465
+
1466
+ # Wrap the RPC method; this adds retry and timeout information,
1467
+ # and friendly error handling.
1468
+ rpc = self._transport._wrapped_methods[
1469
+ self._transport.delete_connection_profile
1470
+ ]
1471
+
1472
+ # Certain fields should be provided within the metadata header;
1473
+ # add these here.
1474
+ metadata = tuple(metadata) + (
1475
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1476
+ )
1477
+
1478
+ # Validate the universe domain.
1479
+ self._validate_universe_domain()
1480
+
1481
+ # Send the request.
1482
+ response = rpc(
1483
+ request,
1484
+ retry=retry,
1485
+ timeout=timeout,
1486
+ metadata=metadata,
1487
+ )
1488
+
1489
+ # Wrap the response in an operation future.
1490
+ response = operation.from_gapic(
1491
+ response,
1492
+ self._transport.operations_client,
1493
+ empty_pb2.Empty,
1494
+ metadata_type=datastream.OperationMetadata,
1495
+ )
1496
+
1497
+ # Done; return the response.
1498
+ return response
1499
+
1500
+ def discover_connection_profile(
1501
+ self,
1502
+ request: Optional[
1503
+ Union[datastream.DiscoverConnectionProfileRequest, dict]
1504
+ ] = None,
1505
+ *,
1506
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1507
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1508
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1509
+ ) -> datastream.DiscoverConnectionProfileResponse:
1510
+ r"""Use this method to discover a connection profile.
1511
+ The discover API call exposes the data objects and
1512
+ metadata belonging to the profile. Typically, a request
1513
+ returns children data objects of a parent data object
1514
+ that's optionally supplied in the request.
1515
+
1516
+ .. code-block:: python
1517
+
1518
+ # This snippet has been automatically generated and should be regarded as a
1519
+ # code template only.
1520
+ # It will require modifications to work:
1521
+ # - It may require correct/in-range values for request initialization.
1522
+ # - It may require specifying regional endpoints when creating the service
1523
+ # client as shown in:
1524
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1525
+ from google.cloud import datastream_v1
1526
+
1527
+ def sample_discover_connection_profile():
1528
+ # Create a client
1529
+ client = datastream_v1.DatastreamClient()
1530
+
1531
+ # Initialize request argument(s)
1532
+ connection_profile = datastream_v1.ConnectionProfile()
1533
+ connection_profile.oracle_profile.hostname = "hostname_value"
1534
+ connection_profile.oracle_profile.username = "username_value"
1535
+ connection_profile.oracle_profile.database_service = "database_service_value"
1536
+ connection_profile.display_name = "display_name_value"
1537
+
1538
+ request = datastream_v1.DiscoverConnectionProfileRequest(
1539
+ connection_profile=connection_profile,
1540
+ full_hierarchy=True,
1541
+ parent="parent_value",
1542
+ )
1543
+
1544
+ # Make the request
1545
+ response = client.discover_connection_profile(request=request)
1546
+
1547
+ # Handle the response
1548
+ print(response)
1549
+
1550
+ Args:
1551
+ request (Union[google.cloud.datastream_v1.types.DiscoverConnectionProfileRequest, dict]):
1552
+ The request object. Request message for 'discover'
1553
+ ConnectionProfile request.
1554
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1555
+ should be retried.
1556
+ timeout (float): The timeout for this request.
1557
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1558
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1559
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1560
+ be of type `bytes`.
1561
+
1562
+ Returns:
1563
+ google.cloud.datastream_v1.types.DiscoverConnectionProfileResponse:
1564
+ Response from a discover request.
1565
+ """
1566
+ # Create or coerce a protobuf request object.
1567
+ # - Use the request object if provided (there's no risk of modifying the input as
1568
+ # there are no flattened fields), or create one.
1569
+ if not isinstance(request, datastream.DiscoverConnectionProfileRequest):
1570
+ request = datastream.DiscoverConnectionProfileRequest(request)
1571
+
1572
+ # Wrap the RPC method; this adds retry and timeout information,
1573
+ # and friendly error handling.
1574
+ rpc = self._transport._wrapped_methods[
1575
+ self._transport.discover_connection_profile
1576
+ ]
1577
+
1578
+ # Certain fields should be provided within the metadata header;
1579
+ # add these here.
1580
+ metadata = tuple(metadata) + (
1581
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1582
+ )
1583
+
1584
+ # Validate the universe domain.
1585
+ self._validate_universe_domain()
1586
+
1587
+ # Send the request.
1588
+ response = rpc(
1589
+ request,
1590
+ retry=retry,
1591
+ timeout=timeout,
1592
+ metadata=metadata,
1593
+ )
1594
+
1595
+ # Done; return the response.
1596
+ return response
1597
+
1598
+ def list_streams(
1599
+ self,
1600
+ request: Optional[Union[datastream.ListStreamsRequest, dict]] = None,
1601
+ *,
1602
+ parent: Optional[str] = None,
1603
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1604
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1605
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1606
+ ) -> pagers.ListStreamsPager:
1607
+ r"""Use this method to list streams in a project and
1608
+ location.
1609
+
1610
+ .. code-block:: python
1611
+
1612
+ # This snippet has been automatically generated and should be regarded as a
1613
+ # code template only.
1614
+ # It will require modifications to work:
1615
+ # - It may require correct/in-range values for request initialization.
1616
+ # - It may require specifying regional endpoints when creating the service
1617
+ # client as shown in:
1618
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1619
+ from google.cloud import datastream_v1
1620
+
1621
+ def sample_list_streams():
1622
+ # Create a client
1623
+ client = datastream_v1.DatastreamClient()
1624
+
1625
+ # Initialize request argument(s)
1626
+ request = datastream_v1.ListStreamsRequest(
1627
+ parent="parent_value",
1628
+ )
1629
+
1630
+ # Make the request
1631
+ page_result = client.list_streams(request=request)
1632
+
1633
+ # Handle the response
1634
+ for response in page_result:
1635
+ print(response)
1636
+
1637
+ Args:
1638
+ request (Union[google.cloud.datastream_v1.types.ListStreamsRequest, dict]):
1639
+ The request object. Request message for listing streams.
1640
+ parent (str):
1641
+ Required. The parent that owns the
1642
+ collection of streams.
1643
+
1644
+ This corresponds to the ``parent`` field
1645
+ on the ``request`` instance; if ``request`` is provided, this
1646
+ should not be set.
1647
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1648
+ should be retried.
1649
+ timeout (float): The timeout for this request.
1650
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1651
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1652
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1653
+ be of type `bytes`.
1654
+
1655
+ Returns:
1656
+ google.cloud.datastream_v1.services.datastream.pagers.ListStreamsPager:
1657
+ Response message for listing streams.
1658
+
1659
+ Iterating over this object will yield
1660
+ results and resolve additional pages
1661
+ automatically.
1662
+
1663
+ """
1664
+ # Create or coerce a protobuf request object.
1665
+ # - Quick check: If we got a request object, we should *not* have
1666
+ # gotten any keyword arguments that map to the request.
1667
+ flattened_params = [parent]
1668
+ has_flattened_params = (
1669
+ len([param for param in flattened_params if param is not None]) > 0
1670
+ )
1671
+ if request is not None and has_flattened_params:
1672
+ raise ValueError(
1673
+ "If the `request` argument is set, then none of "
1674
+ "the individual field arguments should be set."
1675
+ )
1676
+
1677
+ # - Use the request object if provided (there's no risk of modifying the input as
1678
+ # there are no flattened fields), or create one.
1679
+ if not isinstance(request, datastream.ListStreamsRequest):
1680
+ request = datastream.ListStreamsRequest(request)
1681
+ # If we have keyword arguments corresponding to fields on the
1682
+ # request, apply these.
1683
+ if parent is not None:
1684
+ request.parent = parent
1685
+
1686
+ # Wrap the RPC method; this adds retry and timeout information,
1687
+ # and friendly error handling.
1688
+ rpc = self._transport._wrapped_methods[self._transport.list_streams]
1689
+
1690
+ # Certain fields should be provided within the metadata header;
1691
+ # add these here.
1692
+ metadata = tuple(metadata) + (
1693
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1694
+ )
1695
+
1696
+ # Validate the universe domain.
1697
+ self._validate_universe_domain()
1698
+
1699
+ # Send the request.
1700
+ response = rpc(
1701
+ request,
1702
+ retry=retry,
1703
+ timeout=timeout,
1704
+ metadata=metadata,
1705
+ )
1706
+
1707
+ # This method is paged; wrap the response in a pager, which provides
1708
+ # an `__iter__` convenience method.
1709
+ response = pagers.ListStreamsPager(
1710
+ method=rpc,
1711
+ request=request,
1712
+ response=response,
1713
+ retry=retry,
1714
+ timeout=timeout,
1715
+ metadata=metadata,
1716
+ )
1717
+
1718
+ # Done; return the response.
1719
+ return response
1720
+
1721
+ def get_stream(
1722
+ self,
1723
+ request: Optional[Union[datastream.GetStreamRequest, dict]] = None,
1724
+ *,
1725
+ name: Optional[str] = None,
1726
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1727
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1728
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1729
+ ) -> datastream_resources.Stream:
1730
+ r"""Use this method to get details about a stream.
1731
+
1732
+ .. code-block:: python
1733
+
1734
+ # This snippet has been automatically generated and should be regarded as a
1735
+ # code template only.
1736
+ # It will require modifications to work:
1737
+ # - It may require correct/in-range values for request initialization.
1738
+ # - It may require specifying regional endpoints when creating the service
1739
+ # client as shown in:
1740
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1741
+ from google.cloud import datastream_v1
1742
+
1743
+ def sample_get_stream():
1744
+ # Create a client
1745
+ client = datastream_v1.DatastreamClient()
1746
+
1747
+ # Initialize request argument(s)
1748
+ request = datastream_v1.GetStreamRequest(
1749
+ name="name_value",
1750
+ )
1751
+
1752
+ # Make the request
1753
+ response = client.get_stream(request=request)
1754
+
1755
+ # Handle the response
1756
+ print(response)
1757
+
1758
+ Args:
1759
+ request (Union[google.cloud.datastream_v1.types.GetStreamRequest, dict]):
1760
+ The request object. Request message for getting a stream.
1761
+ name (str):
1762
+ Required. The name of the stream
1763
+ resource to get.
1764
+
1765
+ This corresponds to the ``name`` field
1766
+ on the ``request`` instance; if ``request`` is provided, this
1767
+ should not be set.
1768
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1769
+ should be retried.
1770
+ timeout (float): The timeout for this request.
1771
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1772
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1773
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1774
+ be of type `bytes`.
1775
+
1776
+ Returns:
1777
+ google.cloud.datastream_v1.types.Stream:
1778
+ A resource representing streaming
1779
+ data from a source to a destination.
1780
+
1781
+ """
1782
+ # Create or coerce a protobuf request object.
1783
+ # - Quick check: If we got a request object, we should *not* have
1784
+ # gotten any keyword arguments that map to the request.
1785
+ flattened_params = [name]
1786
+ has_flattened_params = (
1787
+ len([param for param in flattened_params if param is not None]) > 0
1788
+ )
1789
+ if request is not None and has_flattened_params:
1790
+ raise ValueError(
1791
+ "If the `request` argument is set, then none of "
1792
+ "the individual field arguments should be set."
1793
+ )
1794
+
1795
+ # - Use the request object if provided (there's no risk of modifying the input as
1796
+ # there are no flattened fields), or create one.
1797
+ if not isinstance(request, datastream.GetStreamRequest):
1798
+ request = datastream.GetStreamRequest(request)
1799
+ # If we have keyword arguments corresponding to fields on the
1800
+ # request, apply these.
1801
+ if name is not None:
1802
+ request.name = name
1803
+
1804
+ # Wrap the RPC method; this adds retry and timeout information,
1805
+ # and friendly error handling.
1806
+ rpc = self._transport._wrapped_methods[self._transport.get_stream]
1807
+
1808
+ # Certain fields should be provided within the metadata header;
1809
+ # add these here.
1810
+ metadata = tuple(metadata) + (
1811
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1812
+ )
1813
+
1814
+ # Validate the universe domain.
1815
+ self._validate_universe_domain()
1816
+
1817
+ # Send the request.
1818
+ response = rpc(
1819
+ request,
1820
+ retry=retry,
1821
+ timeout=timeout,
1822
+ metadata=metadata,
1823
+ )
1824
+
1825
+ # Done; return the response.
1826
+ return response
1827
+
1828
+ def create_stream(
1829
+ self,
1830
+ request: Optional[Union[datastream.CreateStreamRequest, dict]] = None,
1831
+ *,
1832
+ parent: Optional[str] = None,
1833
+ stream: Optional[datastream_resources.Stream] = None,
1834
+ stream_id: Optional[str] = None,
1835
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1836
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1837
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1838
+ ) -> operation.Operation:
1839
+ r"""Use this method to create a stream.
1840
+
1841
+ .. code-block:: python
1842
+
1843
+ # This snippet has been automatically generated and should be regarded as a
1844
+ # code template only.
1845
+ # It will require modifications to work:
1846
+ # - It may require correct/in-range values for request initialization.
1847
+ # - It may require specifying regional endpoints when creating the service
1848
+ # client as shown in:
1849
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1850
+ from google.cloud import datastream_v1
1851
+
1852
+ def sample_create_stream():
1853
+ # Create a client
1854
+ client = datastream_v1.DatastreamClient()
1855
+
1856
+ # Initialize request argument(s)
1857
+ stream = datastream_v1.Stream()
1858
+ stream.display_name = "display_name_value"
1859
+ stream.source_config.source_connection_profile = "source_connection_profile_value"
1860
+ stream.destination_config.destination_connection_profile = "destination_connection_profile_value"
1861
+
1862
+ request = datastream_v1.CreateStreamRequest(
1863
+ parent="parent_value",
1864
+ stream_id="stream_id_value",
1865
+ stream=stream,
1866
+ )
1867
+
1868
+ # Make the request
1869
+ operation = client.create_stream(request=request)
1870
+
1871
+ print("Waiting for operation to complete...")
1872
+
1873
+ response = operation.result()
1874
+
1875
+ # Handle the response
1876
+ print(response)
1877
+
1878
+ Args:
1879
+ request (Union[google.cloud.datastream_v1.types.CreateStreamRequest, dict]):
1880
+ The request object. Request message for creating a
1881
+ stream.
1882
+ parent (str):
1883
+ Required. The parent that owns the
1884
+ collection of streams.
1885
+
1886
+ This corresponds to the ``parent`` field
1887
+ on the ``request`` instance; if ``request`` is provided, this
1888
+ should not be set.
1889
+ stream (google.cloud.datastream_v1.types.Stream):
1890
+ Required. The stream resource to
1891
+ create.
1892
+
1893
+ This corresponds to the ``stream`` field
1894
+ on the ``request`` instance; if ``request`` is provided, this
1895
+ should not be set.
1896
+ stream_id (str):
1897
+ Required. The stream identifier.
1898
+ This corresponds to the ``stream_id`` field
1899
+ on the ``request`` instance; if ``request`` is provided, this
1900
+ should not be set.
1901
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1902
+ should be retried.
1903
+ timeout (float): The timeout for this request.
1904
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1905
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1906
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1907
+ be of type `bytes`.
1908
+
1909
+ Returns:
1910
+ google.api_core.operation.Operation:
1911
+ An object representing a long-running operation.
1912
+
1913
+ The result type for the operation will be
1914
+ :class:`google.cloud.datastream_v1.types.Stream` A
1915
+ resource representing streaming data from a source to a
1916
+ destination.
1917
+
1918
+ """
1919
+ # Create or coerce a protobuf request object.
1920
+ # - Quick check: If we got a request object, we should *not* have
1921
+ # gotten any keyword arguments that map to the request.
1922
+ flattened_params = [parent, stream, stream_id]
1923
+ has_flattened_params = (
1924
+ len([param for param in flattened_params if param is not None]) > 0
1925
+ )
1926
+ if request is not None and has_flattened_params:
1927
+ raise ValueError(
1928
+ "If the `request` argument is set, then none of "
1929
+ "the individual field arguments should be set."
1930
+ )
1931
+
1932
+ # - Use the request object if provided (there's no risk of modifying the input as
1933
+ # there are no flattened fields), or create one.
1934
+ if not isinstance(request, datastream.CreateStreamRequest):
1935
+ request = datastream.CreateStreamRequest(request)
1936
+ # If we have keyword arguments corresponding to fields on the
1937
+ # request, apply these.
1938
+ if parent is not None:
1939
+ request.parent = parent
1940
+ if stream is not None:
1941
+ request.stream = stream
1942
+ if stream_id is not None:
1943
+ request.stream_id = stream_id
1944
+
1945
+ # Wrap the RPC method; this adds retry and timeout information,
1946
+ # and friendly error handling.
1947
+ rpc = self._transport._wrapped_methods[self._transport.create_stream]
1948
+
1949
+ # Certain fields should be provided within the metadata header;
1950
+ # add these here.
1951
+ metadata = tuple(metadata) + (
1952
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1953
+ )
1954
+
1955
+ # Validate the universe domain.
1956
+ self._validate_universe_domain()
1957
+
1958
+ # Send the request.
1959
+ response = rpc(
1960
+ request,
1961
+ retry=retry,
1962
+ timeout=timeout,
1963
+ metadata=metadata,
1964
+ )
1965
+
1966
+ # Wrap the response in an operation future.
1967
+ response = operation.from_gapic(
1968
+ response,
1969
+ self._transport.operations_client,
1970
+ datastream_resources.Stream,
1971
+ metadata_type=datastream.OperationMetadata,
1972
+ )
1973
+
1974
+ # Done; return the response.
1975
+ return response
1976
+
1977
+ def update_stream(
1978
+ self,
1979
+ request: Optional[Union[datastream.UpdateStreamRequest, dict]] = None,
1980
+ *,
1981
+ stream: Optional[datastream_resources.Stream] = None,
1982
+ update_mask: Optional[field_mask_pb2.FieldMask] = None,
1983
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1984
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1985
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1986
+ ) -> operation.Operation:
1987
+ r"""Use this method to update the configuration of a
1988
+ stream.
1989
+
1990
+ .. code-block:: python
1991
+
1992
+ # This snippet has been automatically generated and should be regarded as a
1993
+ # code template only.
1994
+ # It will require modifications to work:
1995
+ # - It may require correct/in-range values for request initialization.
1996
+ # - It may require specifying regional endpoints when creating the service
1997
+ # client as shown in:
1998
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1999
+ from google.cloud import datastream_v1
2000
+
2001
+ def sample_update_stream():
2002
+ # Create a client
2003
+ client = datastream_v1.DatastreamClient()
2004
+
2005
+ # Initialize request argument(s)
2006
+ stream = datastream_v1.Stream()
2007
+ stream.display_name = "display_name_value"
2008
+ stream.source_config.source_connection_profile = "source_connection_profile_value"
2009
+ stream.destination_config.destination_connection_profile = "destination_connection_profile_value"
2010
+
2011
+ request = datastream_v1.UpdateStreamRequest(
2012
+ stream=stream,
2013
+ )
2014
+
2015
+ # Make the request
2016
+ operation = client.update_stream(request=request)
2017
+
2018
+ print("Waiting for operation to complete...")
2019
+
2020
+ response = operation.result()
2021
+
2022
+ # Handle the response
2023
+ print(response)
2024
+
2025
+ Args:
2026
+ request (Union[google.cloud.datastream_v1.types.UpdateStreamRequest, dict]):
2027
+ The request object. Request message for updating a
2028
+ stream.
2029
+ stream (google.cloud.datastream_v1.types.Stream):
2030
+ Required. The stream resource to
2031
+ update.
2032
+
2033
+ This corresponds to the ``stream`` field
2034
+ on the ``request`` instance; if ``request`` is provided, this
2035
+ should not be set.
2036
+ update_mask (google.protobuf.field_mask_pb2.FieldMask):
2037
+ Optional. Field mask is used to specify the fields to be
2038
+ overwritten in the stream resource by the update. The
2039
+ fields specified in the update_mask are relative to the
2040
+ resource, not the full request. A field will be
2041
+ overwritten if it is in the mask. If the user does not
2042
+ provide a mask then all fields will be overwritten.
2043
+
2044
+ This corresponds to the ``update_mask`` field
2045
+ on the ``request`` instance; if ``request`` is provided, this
2046
+ should not be set.
2047
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2048
+ should be retried.
2049
+ timeout (float): The timeout for this request.
2050
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2051
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2052
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2053
+ be of type `bytes`.
2054
+
2055
+ Returns:
2056
+ google.api_core.operation.Operation:
2057
+ An object representing a long-running operation.
2058
+
2059
+ The result type for the operation will be
2060
+ :class:`google.cloud.datastream_v1.types.Stream` A
2061
+ resource representing streaming data from a source to a
2062
+ destination.
2063
+
2064
+ """
2065
+ # Create or coerce a protobuf request object.
2066
+ # - Quick check: If we got a request object, we should *not* have
2067
+ # gotten any keyword arguments that map to the request.
2068
+ flattened_params = [stream, update_mask]
2069
+ has_flattened_params = (
2070
+ len([param for param in flattened_params if param is not None]) > 0
2071
+ )
2072
+ if request is not None and has_flattened_params:
2073
+ raise ValueError(
2074
+ "If the `request` argument is set, then none of "
2075
+ "the individual field arguments should be set."
2076
+ )
2077
+
2078
+ # - Use the request object if provided (there's no risk of modifying the input as
2079
+ # there are no flattened fields), or create one.
2080
+ if not isinstance(request, datastream.UpdateStreamRequest):
2081
+ request = datastream.UpdateStreamRequest(request)
2082
+ # If we have keyword arguments corresponding to fields on the
2083
+ # request, apply these.
2084
+ if stream is not None:
2085
+ request.stream = stream
2086
+ if update_mask is not None:
2087
+ request.update_mask = update_mask
2088
+
2089
+ # Wrap the RPC method; this adds retry and timeout information,
2090
+ # and friendly error handling.
2091
+ rpc = self._transport._wrapped_methods[self._transport.update_stream]
2092
+
2093
+ # Certain fields should be provided within the metadata header;
2094
+ # add these here.
2095
+ metadata = tuple(metadata) + (
2096
+ gapic_v1.routing_header.to_grpc_metadata(
2097
+ (("stream.name", request.stream.name),)
2098
+ ),
2099
+ )
2100
+
2101
+ # Validate the universe domain.
2102
+ self._validate_universe_domain()
2103
+
2104
+ # Send the request.
2105
+ response = rpc(
2106
+ request,
2107
+ retry=retry,
2108
+ timeout=timeout,
2109
+ metadata=metadata,
2110
+ )
2111
+
2112
+ # Wrap the response in an operation future.
2113
+ response = operation.from_gapic(
2114
+ response,
2115
+ self._transport.operations_client,
2116
+ datastream_resources.Stream,
2117
+ metadata_type=datastream.OperationMetadata,
2118
+ )
2119
+
2120
+ # Done; return the response.
2121
+ return response
2122
+
2123
+ def delete_stream(
2124
+ self,
2125
+ request: Optional[Union[datastream.DeleteStreamRequest, dict]] = None,
2126
+ *,
2127
+ name: Optional[str] = None,
2128
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2129
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2130
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2131
+ ) -> operation.Operation:
2132
+ r"""Use this method to delete a stream.
2133
+
2134
+ .. code-block:: python
2135
+
2136
+ # This snippet has been automatically generated and should be regarded as a
2137
+ # code template only.
2138
+ # It will require modifications to work:
2139
+ # - It may require correct/in-range values for request initialization.
2140
+ # - It may require specifying regional endpoints when creating the service
2141
+ # client as shown in:
2142
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2143
+ from google.cloud import datastream_v1
2144
+
2145
+ def sample_delete_stream():
2146
+ # Create a client
2147
+ client = datastream_v1.DatastreamClient()
2148
+
2149
+ # Initialize request argument(s)
2150
+ request = datastream_v1.DeleteStreamRequest(
2151
+ name="name_value",
2152
+ )
2153
+
2154
+ # Make the request
2155
+ operation = client.delete_stream(request=request)
2156
+
2157
+ print("Waiting for operation to complete...")
2158
+
2159
+ response = operation.result()
2160
+
2161
+ # Handle the response
2162
+ print(response)
2163
+
2164
+ Args:
2165
+ request (Union[google.cloud.datastream_v1.types.DeleteStreamRequest, dict]):
2166
+ The request object. Request message for deleting a
2167
+ stream.
2168
+ name (str):
2169
+ Required. The name of the stream
2170
+ resource to delete.
2171
+
2172
+ This corresponds to the ``name`` field
2173
+ on the ``request`` instance; if ``request`` is provided, this
2174
+ should not be set.
2175
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2176
+ should be retried.
2177
+ timeout (float): The timeout for this request.
2178
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2179
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2180
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2181
+ be of type `bytes`.
2182
+
2183
+ Returns:
2184
+ google.api_core.operation.Operation:
2185
+ An object representing a long-running operation.
2186
+
2187
+ 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
2188
+ empty messages in your APIs. A typical example is to
2189
+ use it as the request or the response type of an API
2190
+ method. For instance:
2191
+
2192
+ service Foo {
2193
+ rpc Bar(google.protobuf.Empty) returns
2194
+ (google.protobuf.Empty);
2195
+
2196
+ }
2197
+
2198
+ """
2199
+ # Create or coerce a protobuf request object.
2200
+ # - Quick check: If we got a request object, we should *not* have
2201
+ # gotten any keyword arguments that map to the request.
2202
+ flattened_params = [name]
2203
+ has_flattened_params = (
2204
+ len([param for param in flattened_params if param is not None]) > 0
2205
+ )
2206
+ if request is not None and has_flattened_params:
2207
+ raise ValueError(
2208
+ "If the `request` argument is set, then none of "
2209
+ "the individual field arguments should be set."
2210
+ )
2211
+
2212
+ # - Use the request object if provided (there's no risk of modifying the input as
2213
+ # there are no flattened fields), or create one.
2214
+ if not isinstance(request, datastream.DeleteStreamRequest):
2215
+ request = datastream.DeleteStreamRequest(request)
2216
+ # If we have keyword arguments corresponding to fields on the
2217
+ # request, apply these.
2218
+ if name is not None:
2219
+ request.name = name
2220
+
2221
+ # Wrap the RPC method; this adds retry and timeout information,
2222
+ # and friendly error handling.
2223
+ rpc = self._transport._wrapped_methods[self._transport.delete_stream]
2224
+
2225
+ # Certain fields should be provided within the metadata header;
2226
+ # add these here.
2227
+ metadata = tuple(metadata) + (
2228
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2229
+ )
2230
+
2231
+ # Validate the universe domain.
2232
+ self._validate_universe_domain()
2233
+
2234
+ # Send the request.
2235
+ response = rpc(
2236
+ request,
2237
+ retry=retry,
2238
+ timeout=timeout,
2239
+ metadata=metadata,
2240
+ )
2241
+
2242
+ # Wrap the response in an operation future.
2243
+ response = operation.from_gapic(
2244
+ response,
2245
+ self._transport.operations_client,
2246
+ empty_pb2.Empty,
2247
+ metadata_type=datastream.OperationMetadata,
2248
+ )
2249
+
2250
+ # Done; return the response.
2251
+ return response
2252
+
2253
+ def run_stream(
2254
+ self,
2255
+ request: Optional[Union[datastream.RunStreamRequest, dict]] = None,
2256
+ *,
2257
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2258
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2259
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2260
+ ) -> operation.Operation:
2261
+ r"""Use this method to start, resume or recover a stream
2262
+ with a non default CDC strategy.
2263
+
2264
+ .. code-block:: python
2265
+
2266
+ # This snippet has been automatically generated and should be regarded as a
2267
+ # code template only.
2268
+ # It will require modifications to work:
2269
+ # - It may require correct/in-range values for request initialization.
2270
+ # - It may require specifying regional endpoints when creating the service
2271
+ # client as shown in:
2272
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2273
+ from google.cloud import datastream_v1
2274
+
2275
+ def sample_run_stream():
2276
+ # Create a client
2277
+ client = datastream_v1.DatastreamClient()
2278
+
2279
+ # Initialize request argument(s)
2280
+ request = datastream_v1.RunStreamRequest(
2281
+ name="name_value",
2282
+ )
2283
+
2284
+ # Make the request
2285
+ operation = client.run_stream(request=request)
2286
+
2287
+ print("Waiting for operation to complete...")
2288
+
2289
+ response = operation.result()
2290
+
2291
+ # Handle the response
2292
+ print(response)
2293
+
2294
+ Args:
2295
+ request (Union[google.cloud.datastream_v1.types.RunStreamRequest, dict]):
2296
+ The request object. Request message for running a stream.
2297
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2298
+ should be retried.
2299
+ timeout (float): The timeout for this request.
2300
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2301
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2302
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2303
+ be of type `bytes`.
2304
+
2305
+ Returns:
2306
+ google.api_core.operation.Operation:
2307
+ An object representing a long-running operation.
2308
+
2309
+ The result type for the operation will be
2310
+ :class:`google.cloud.datastream_v1.types.Stream` A
2311
+ resource representing streaming data from a source to a
2312
+ destination.
2313
+
2314
+ """
2315
+ # Create or coerce a protobuf request object.
2316
+ # - Use the request object if provided (there's no risk of modifying the input as
2317
+ # there are no flattened fields), or create one.
2318
+ if not isinstance(request, datastream.RunStreamRequest):
2319
+ request = datastream.RunStreamRequest(request)
2320
+
2321
+ # Wrap the RPC method; this adds retry and timeout information,
2322
+ # and friendly error handling.
2323
+ rpc = self._transport._wrapped_methods[self._transport.run_stream]
2324
+
2325
+ # Certain fields should be provided within the metadata header;
2326
+ # add these here.
2327
+ metadata = tuple(metadata) + (
2328
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2329
+ )
2330
+
2331
+ # Validate the universe domain.
2332
+ self._validate_universe_domain()
2333
+
2334
+ # Send the request.
2335
+ response = rpc(
2336
+ request,
2337
+ retry=retry,
2338
+ timeout=timeout,
2339
+ metadata=metadata,
2340
+ )
2341
+
2342
+ # Wrap the response in an operation future.
2343
+ response = operation.from_gapic(
2344
+ response,
2345
+ self._transport.operations_client,
2346
+ datastream_resources.Stream,
2347
+ metadata_type=datastream.OperationMetadata,
2348
+ )
2349
+
2350
+ # Done; return the response.
2351
+ return response
2352
+
2353
+ def get_stream_object(
2354
+ self,
2355
+ request: Optional[Union[datastream.GetStreamObjectRequest, dict]] = None,
2356
+ *,
2357
+ name: Optional[str] = None,
2358
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2359
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2360
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2361
+ ) -> datastream_resources.StreamObject:
2362
+ r"""Use this method to get details about a stream object.
2363
+
2364
+ .. code-block:: python
2365
+
2366
+ # This snippet has been automatically generated and should be regarded as a
2367
+ # code template only.
2368
+ # It will require modifications to work:
2369
+ # - It may require correct/in-range values for request initialization.
2370
+ # - It may require specifying regional endpoints when creating the service
2371
+ # client as shown in:
2372
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2373
+ from google.cloud import datastream_v1
2374
+
2375
+ def sample_get_stream_object():
2376
+ # Create a client
2377
+ client = datastream_v1.DatastreamClient()
2378
+
2379
+ # Initialize request argument(s)
2380
+ request = datastream_v1.GetStreamObjectRequest(
2381
+ name="name_value",
2382
+ )
2383
+
2384
+ # Make the request
2385
+ response = client.get_stream_object(request=request)
2386
+
2387
+ # Handle the response
2388
+ print(response)
2389
+
2390
+ Args:
2391
+ request (Union[google.cloud.datastream_v1.types.GetStreamObjectRequest, dict]):
2392
+ The request object. Request for fetching a specific
2393
+ stream object.
2394
+ name (str):
2395
+ Required. The name of the stream
2396
+ object resource to get.
2397
+
2398
+ This corresponds to the ``name`` field
2399
+ on the ``request`` instance; if ``request`` is provided, this
2400
+ should not be set.
2401
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2402
+ should be retried.
2403
+ timeout (float): The timeout for this request.
2404
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2405
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2406
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2407
+ be of type `bytes`.
2408
+
2409
+ Returns:
2410
+ google.cloud.datastream_v1.types.StreamObject:
2411
+ A specific stream object (e.g a
2412
+ specific DB table).
2413
+
2414
+ """
2415
+ # Create or coerce a protobuf request object.
2416
+ # - Quick check: If we got a request object, we should *not* have
2417
+ # gotten any keyword arguments that map to the request.
2418
+ flattened_params = [name]
2419
+ has_flattened_params = (
2420
+ len([param for param in flattened_params if param is not None]) > 0
2421
+ )
2422
+ if request is not None and has_flattened_params:
2423
+ raise ValueError(
2424
+ "If the `request` argument is set, then none of "
2425
+ "the individual field arguments should be set."
2426
+ )
2427
+
2428
+ # - Use the request object if provided (there's no risk of modifying the input as
2429
+ # there are no flattened fields), or create one.
2430
+ if not isinstance(request, datastream.GetStreamObjectRequest):
2431
+ request = datastream.GetStreamObjectRequest(request)
2432
+ # If we have keyword arguments corresponding to fields on the
2433
+ # request, apply these.
2434
+ if name is not None:
2435
+ request.name = name
2436
+
2437
+ # Wrap the RPC method; this adds retry and timeout information,
2438
+ # and friendly error handling.
2439
+ rpc = self._transport._wrapped_methods[self._transport.get_stream_object]
2440
+
2441
+ # Certain fields should be provided within the metadata header;
2442
+ # add these here.
2443
+ metadata = tuple(metadata) + (
2444
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2445
+ )
2446
+
2447
+ # Validate the universe domain.
2448
+ self._validate_universe_domain()
2449
+
2450
+ # Send the request.
2451
+ response = rpc(
2452
+ request,
2453
+ retry=retry,
2454
+ timeout=timeout,
2455
+ metadata=metadata,
2456
+ )
2457
+
2458
+ # Done; return the response.
2459
+ return response
2460
+
2461
+ def lookup_stream_object(
2462
+ self,
2463
+ request: Optional[Union[datastream.LookupStreamObjectRequest, dict]] = None,
2464
+ *,
2465
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2466
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2467
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2468
+ ) -> datastream_resources.StreamObject:
2469
+ r"""Use this method to look up a stream object by its
2470
+ source object identifier.
2471
+
2472
+ .. code-block:: python
2473
+
2474
+ # This snippet has been automatically generated and should be regarded as a
2475
+ # code template only.
2476
+ # It will require modifications to work:
2477
+ # - It may require correct/in-range values for request initialization.
2478
+ # - It may require specifying regional endpoints when creating the service
2479
+ # client as shown in:
2480
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2481
+ from google.cloud import datastream_v1
2482
+
2483
+ def sample_lookup_stream_object():
2484
+ # Create a client
2485
+ client = datastream_v1.DatastreamClient()
2486
+
2487
+ # Initialize request argument(s)
2488
+ source_object_identifier = datastream_v1.SourceObjectIdentifier()
2489
+ source_object_identifier.oracle_identifier.schema = "schema_value"
2490
+ source_object_identifier.oracle_identifier.table = "table_value"
2491
+
2492
+ request = datastream_v1.LookupStreamObjectRequest(
2493
+ parent="parent_value",
2494
+ source_object_identifier=source_object_identifier,
2495
+ )
2496
+
2497
+ # Make the request
2498
+ response = client.lookup_stream_object(request=request)
2499
+
2500
+ # Handle the response
2501
+ print(response)
2502
+
2503
+ Args:
2504
+ request (Union[google.cloud.datastream_v1.types.LookupStreamObjectRequest, dict]):
2505
+ The request object. Request for looking up a specific
2506
+ stream object by its source object
2507
+ identifier.
2508
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2509
+ should be retried.
2510
+ timeout (float): The timeout for this request.
2511
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2512
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2513
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2514
+ be of type `bytes`.
2515
+
2516
+ Returns:
2517
+ google.cloud.datastream_v1.types.StreamObject:
2518
+ A specific stream object (e.g a
2519
+ specific DB table).
2520
+
2521
+ """
2522
+ # Create or coerce a protobuf request object.
2523
+ # - Use the request object if provided (there's no risk of modifying the input as
2524
+ # there are no flattened fields), or create one.
2525
+ if not isinstance(request, datastream.LookupStreamObjectRequest):
2526
+ request = datastream.LookupStreamObjectRequest(request)
2527
+
2528
+ # Wrap the RPC method; this adds retry and timeout information,
2529
+ # and friendly error handling.
2530
+ rpc = self._transport._wrapped_methods[self._transport.lookup_stream_object]
2531
+
2532
+ # Certain fields should be provided within the metadata header;
2533
+ # add these here.
2534
+ metadata = tuple(metadata) + (
2535
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2536
+ )
2537
+
2538
+ # Validate the universe domain.
2539
+ self._validate_universe_domain()
2540
+
2541
+ # Send the request.
2542
+ response = rpc(
2543
+ request,
2544
+ retry=retry,
2545
+ timeout=timeout,
2546
+ metadata=metadata,
2547
+ )
2548
+
2549
+ # Done; return the response.
2550
+ return response
2551
+
2552
+ def list_stream_objects(
2553
+ self,
2554
+ request: Optional[Union[datastream.ListStreamObjectsRequest, dict]] = None,
2555
+ *,
2556
+ parent: Optional[str] = None,
2557
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2558
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2559
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2560
+ ) -> pagers.ListStreamObjectsPager:
2561
+ r"""Use this method to list the objects of a specific
2562
+ stream.
2563
+
2564
+ .. code-block:: python
2565
+
2566
+ # This snippet has been automatically generated and should be regarded as a
2567
+ # code template only.
2568
+ # It will require modifications to work:
2569
+ # - It may require correct/in-range values for request initialization.
2570
+ # - It may require specifying regional endpoints when creating the service
2571
+ # client as shown in:
2572
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2573
+ from google.cloud import datastream_v1
2574
+
2575
+ def sample_list_stream_objects():
2576
+ # Create a client
2577
+ client = datastream_v1.DatastreamClient()
2578
+
2579
+ # Initialize request argument(s)
2580
+ request = datastream_v1.ListStreamObjectsRequest(
2581
+ parent="parent_value",
2582
+ )
2583
+
2584
+ # Make the request
2585
+ page_result = client.list_stream_objects(request=request)
2586
+
2587
+ # Handle the response
2588
+ for response in page_result:
2589
+ print(response)
2590
+
2591
+ Args:
2592
+ request (Union[google.cloud.datastream_v1.types.ListStreamObjectsRequest, dict]):
2593
+ The request object. Request for listing all objects for a
2594
+ specific stream.
2595
+ parent (str):
2596
+ Required. The parent stream that owns
2597
+ the collection of objects.
2598
+
2599
+ This corresponds to the ``parent`` field
2600
+ on the ``request`` instance; if ``request`` is provided, this
2601
+ should not be set.
2602
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2603
+ should be retried.
2604
+ timeout (float): The timeout for this request.
2605
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2606
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2607
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2608
+ be of type `bytes`.
2609
+
2610
+ Returns:
2611
+ google.cloud.datastream_v1.services.datastream.pagers.ListStreamObjectsPager:
2612
+ Response containing the objects for a
2613
+ stream.
2614
+ Iterating over this object will yield
2615
+ results and resolve additional pages
2616
+ automatically.
2617
+
2618
+ """
2619
+ # Create or coerce a protobuf request object.
2620
+ # - Quick check: If we got a request object, we should *not* have
2621
+ # gotten any keyword arguments that map to the request.
2622
+ flattened_params = [parent]
2623
+ has_flattened_params = (
2624
+ len([param for param in flattened_params if param is not None]) > 0
2625
+ )
2626
+ if request is not None and has_flattened_params:
2627
+ raise ValueError(
2628
+ "If the `request` argument is set, then none of "
2629
+ "the individual field arguments should be set."
2630
+ )
2631
+
2632
+ # - Use the request object if provided (there's no risk of modifying the input as
2633
+ # there are no flattened fields), or create one.
2634
+ if not isinstance(request, datastream.ListStreamObjectsRequest):
2635
+ request = datastream.ListStreamObjectsRequest(request)
2636
+ # If we have keyword arguments corresponding to fields on the
2637
+ # request, apply these.
2638
+ if parent is not None:
2639
+ request.parent = parent
2640
+
2641
+ # Wrap the RPC method; this adds retry and timeout information,
2642
+ # and friendly error handling.
2643
+ rpc = self._transport._wrapped_methods[self._transport.list_stream_objects]
2644
+
2645
+ # Certain fields should be provided within the metadata header;
2646
+ # add these here.
2647
+ metadata = tuple(metadata) + (
2648
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2649
+ )
2650
+
2651
+ # Validate the universe domain.
2652
+ self._validate_universe_domain()
2653
+
2654
+ # Send the request.
2655
+ response = rpc(
2656
+ request,
2657
+ retry=retry,
2658
+ timeout=timeout,
2659
+ metadata=metadata,
2660
+ )
2661
+
2662
+ # This method is paged; wrap the response in a pager, which provides
2663
+ # an `__iter__` convenience method.
2664
+ response = pagers.ListStreamObjectsPager(
2665
+ method=rpc,
2666
+ request=request,
2667
+ response=response,
2668
+ retry=retry,
2669
+ timeout=timeout,
2670
+ metadata=metadata,
2671
+ )
2672
+
2673
+ # Done; return the response.
2674
+ return response
2675
+
2676
+ def start_backfill_job(
2677
+ self,
2678
+ request: Optional[Union[datastream.StartBackfillJobRequest, dict]] = None,
2679
+ *,
2680
+ object_: Optional[str] = None,
2681
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2682
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2683
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2684
+ ) -> datastream.StartBackfillJobResponse:
2685
+ r"""Use this method to start a backfill job for the
2686
+ specified stream object.
2687
+
2688
+ .. code-block:: python
2689
+
2690
+ # This snippet has been automatically generated and should be regarded as a
2691
+ # code template only.
2692
+ # It will require modifications to work:
2693
+ # - It may require correct/in-range values for request initialization.
2694
+ # - It may require specifying regional endpoints when creating the service
2695
+ # client as shown in:
2696
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2697
+ from google.cloud import datastream_v1
2698
+
2699
+ def sample_start_backfill_job():
2700
+ # Create a client
2701
+ client = datastream_v1.DatastreamClient()
2702
+
2703
+ # Initialize request argument(s)
2704
+ request = datastream_v1.StartBackfillJobRequest(
2705
+ object_="object__value",
2706
+ )
2707
+
2708
+ # Make the request
2709
+ response = client.start_backfill_job(request=request)
2710
+
2711
+ # Handle the response
2712
+ print(response)
2713
+
2714
+ Args:
2715
+ request (Union[google.cloud.datastream_v1.types.StartBackfillJobRequest, dict]):
2716
+ The request object. Request for manually initiating a
2717
+ backfill job for a specific stream
2718
+ object.
2719
+ object_ (str):
2720
+ Required. The name of the stream
2721
+ object resource to start a backfill job
2722
+ for.
2723
+
2724
+ This corresponds to the ``object_`` field
2725
+ on the ``request`` instance; if ``request`` is provided, this
2726
+ should not be set.
2727
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2728
+ should be retried.
2729
+ timeout (float): The timeout for this request.
2730
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2731
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2732
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2733
+ be of type `bytes`.
2734
+
2735
+ Returns:
2736
+ google.cloud.datastream_v1.types.StartBackfillJobResponse:
2737
+ Response for manually initiating a
2738
+ backfill job for a specific stream
2739
+ object.
2740
+
2741
+ """
2742
+ # Create or coerce a protobuf request object.
2743
+ # - Quick check: If we got a request object, we should *not* have
2744
+ # gotten any keyword arguments that map to the request.
2745
+ flattened_params = [object_]
2746
+ has_flattened_params = (
2747
+ len([param for param in flattened_params if param is not None]) > 0
2748
+ )
2749
+ if request is not None and has_flattened_params:
2750
+ raise ValueError(
2751
+ "If the `request` argument is set, then none of "
2752
+ "the individual field arguments should be set."
2753
+ )
2754
+
2755
+ # - Use the request object if provided (there's no risk of modifying the input as
2756
+ # there are no flattened fields), or create one.
2757
+ if not isinstance(request, datastream.StartBackfillJobRequest):
2758
+ request = datastream.StartBackfillJobRequest(request)
2759
+ # If we have keyword arguments corresponding to fields on the
2760
+ # request, apply these.
2761
+ if object_ is not None:
2762
+ request.object_ = object_
2763
+
2764
+ # Wrap the RPC method; this adds retry and timeout information,
2765
+ # and friendly error handling.
2766
+ rpc = self._transport._wrapped_methods[self._transport.start_backfill_job]
2767
+
2768
+ # Certain fields should be provided within the metadata header;
2769
+ # add these here.
2770
+ metadata = tuple(metadata) + (
2771
+ gapic_v1.routing_header.to_grpc_metadata((("object", request.object_),)),
2772
+ )
2773
+
2774
+ # Validate the universe domain.
2775
+ self._validate_universe_domain()
2776
+
2777
+ # Send the request.
2778
+ response = rpc(
2779
+ request,
2780
+ retry=retry,
2781
+ timeout=timeout,
2782
+ metadata=metadata,
2783
+ )
2784
+
2785
+ # Done; return the response.
2786
+ return response
2787
+
2788
+ def stop_backfill_job(
2789
+ self,
2790
+ request: Optional[Union[datastream.StopBackfillJobRequest, dict]] = None,
2791
+ *,
2792
+ object_: Optional[str] = None,
2793
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2794
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2795
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2796
+ ) -> datastream.StopBackfillJobResponse:
2797
+ r"""Use this method to stop a backfill job for the
2798
+ specified stream object.
2799
+
2800
+ .. code-block:: python
2801
+
2802
+ # This snippet has been automatically generated and should be regarded as a
2803
+ # code template only.
2804
+ # It will require modifications to work:
2805
+ # - It may require correct/in-range values for request initialization.
2806
+ # - It may require specifying regional endpoints when creating the service
2807
+ # client as shown in:
2808
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2809
+ from google.cloud import datastream_v1
2810
+
2811
+ def sample_stop_backfill_job():
2812
+ # Create a client
2813
+ client = datastream_v1.DatastreamClient()
2814
+
2815
+ # Initialize request argument(s)
2816
+ request = datastream_v1.StopBackfillJobRequest(
2817
+ object_="object__value",
2818
+ )
2819
+
2820
+ # Make the request
2821
+ response = client.stop_backfill_job(request=request)
2822
+
2823
+ # Handle the response
2824
+ print(response)
2825
+
2826
+ Args:
2827
+ request (Union[google.cloud.datastream_v1.types.StopBackfillJobRequest, dict]):
2828
+ The request object. Request for manually stopping a
2829
+ running backfill job for a specific
2830
+ stream object.
2831
+ object_ (str):
2832
+ Required. The name of the stream
2833
+ object resource to stop the backfill job
2834
+ for.
2835
+
2836
+ This corresponds to the ``object_`` field
2837
+ on the ``request`` instance; if ``request`` is provided, this
2838
+ should not be set.
2839
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2840
+ should be retried.
2841
+ timeout (float): The timeout for this request.
2842
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2843
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2844
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2845
+ be of type `bytes`.
2846
+
2847
+ Returns:
2848
+ google.cloud.datastream_v1.types.StopBackfillJobResponse:
2849
+ Response for manually stop a backfill
2850
+ job for a specific stream object.
2851
+
2852
+ """
2853
+ # Create or coerce a protobuf request object.
2854
+ # - Quick check: If we got a request object, we should *not* have
2855
+ # gotten any keyword arguments that map to the request.
2856
+ flattened_params = [object_]
2857
+ has_flattened_params = (
2858
+ len([param for param in flattened_params if param is not None]) > 0
2859
+ )
2860
+ if request is not None and has_flattened_params:
2861
+ raise ValueError(
2862
+ "If the `request` argument is set, then none of "
2863
+ "the individual field arguments should be set."
2864
+ )
2865
+
2866
+ # - Use the request object if provided (there's no risk of modifying the input as
2867
+ # there are no flattened fields), or create one.
2868
+ if not isinstance(request, datastream.StopBackfillJobRequest):
2869
+ request = datastream.StopBackfillJobRequest(request)
2870
+ # If we have keyword arguments corresponding to fields on the
2871
+ # request, apply these.
2872
+ if object_ is not None:
2873
+ request.object_ = object_
2874
+
2875
+ # Wrap the RPC method; this adds retry and timeout information,
2876
+ # and friendly error handling.
2877
+ rpc = self._transport._wrapped_methods[self._transport.stop_backfill_job]
2878
+
2879
+ # Certain fields should be provided within the metadata header;
2880
+ # add these here.
2881
+ metadata = tuple(metadata) + (
2882
+ gapic_v1.routing_header.to_grpc_metadata((("object", request.object_),)),
2883
+ )
2884
+
2885
+ # Validate the universe domain.
2886
+ self._validate_universe_domain()
2887
+
2888
+ # Send the request.
2889
+ response = rpc(
2890
+ request,
2891
+ retry=retry,
2892
+ timeout=timeout,
2893
+ metadata=metadata,
2894
+ )
2895
+
2896
+ # Done; return the response.
2897
+ return response
2898
+
2899
+ def fetch_static_ips(
2900
+ self,
2901
+ request: Optional[Union[datastream.FetchStaticIpsRequest, dict]] = None,
2902
+ *,
2903
+ name: Optional[str] = None,
2904
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2905
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2906
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2907
+ ) -> pagers.FetchStaticIpsPager:
2908
+ r"""The FetchStaticIps API call exposes the static IP
2909
+ addresses used by Datastream.
2910
+
2911
+ .. code-block:: python
2912
+
2913
+ # This snippet has been automatically generated and should be regarded as a
2914
+ # code template only.
2915
+ # It will require modifications to work:
2916
+ # - It may require correct/in-range values for request initialization.
2917
+ # - It may require specifying regional endpoints when creating the service
2918
+ # client as shown in:
2919
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2920
+ from google.cloud import datastream_v1
2921
+
2922
+ def sample_fetch_static_ips():
2923
+ # Create a client
2924
+ client = datastream_v1.DatastreamClient()
2925
+
2926
+ # Initialize request argument(s)
2927
+ request = datastream_v1.FetchStaticIpsRequest(
2928
+ name="name_value",
2929
+ )
2930
+
2931
+ # Make the request
2932
+ page_result = client.fetch_static_ips(request=request)
2933
+
2934
+ # Handle the response
2935
+ for response in page_result:
2936
+ print(response)
2937
+
2938
+ Args:
2939
+ request (Union[google.cloud.datastream_v1.types.FetchStaticIpsRequest, dict]):
2940
+ The request object. Request message for 'FetchStaticIps'
2941
+ request.
2942
+ name (str):
2943
+ Required. The resource name for the location for which
2944
+ static IPs should be returned. Must be in the format
2945
+ ``projects/*/locations/*``.
2946
+
2947
+ This corresponds to the ``name`` field
2948
+ on the ``request`` instance; if ``request`` is provided, this
2949
+ should not be set.
2950
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2951
+ should be retried.
2952
+ timeout (float): The timeout for this request.
2953
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2954
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2955
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2956
+ be of type `bytes`.
2957
+
2958
+ Returns:
2959
+ google.cloud.datastream_v1.services.datastream.pagers.FetchStaticIpsPager:
2960
+ Response message for a
2961
+ 'FetchStaticIps' response.
2962
+ Iterating over this object will yield
2963
+ results and resolve additional pages
2964
+ automatically.
2965
+
2966
+ """
2967
+ # Create or coerce a protobuf request object.
2968
+ # - Quick check: If we got a request object, we should *not* have
2969
+ # gotten any keyword arguments that map to the request.
2970
+ flattened_params = [name]
2971
+ has_flattened_params = (
2972
+ len([param for param in flattened_params if param is not None]) > 0
2973
+ )
2974
+ if request is not None and has_flattened_params:
2975
+ raise ValueError(
2976
+ "If the `request` argument is set, then none of "
2977
+ "the individual field arguments should be set."
2978
+ )
2979
+
2980
+ # - Use the request object if provided (there's no risk of modifying the input as
2981
+ # there are no flattened fields), or create one.
2982
+ if not isinstance(request, datastream.FetchStaticIpsRequest):
2983
+ request = datastream.FetchStaticIpsRequest(request)
2984
+ # If we have keyword arguments corresponding to fields on the
2985
+ # request, apply these.
2986
+ if name is not None:
2987
+ request.name = name
2988
+
2989
+ # Wrap the RPC method; this adds retry and timeout information,
2990
+ # and friendly error handling.
2991
+ rpc = self._transport._wrapped_methods[self._transport.fetch_static_ips]
2992
+
2993
+ # Certain fields should be provided within the metadata header;
2994
+ # add these here.
2995
+ metadata = tuple(metadata) + (
2996
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2997
+ )
2998
+
2999
+ # Validate the universe domain.
3000
+ self._validate_universe_domain()
3001
+
3002
+ # Send the request.
3003
+ response = rpc(
3004
+ request,
3005
+ retry=retry,
3006
+ timeout=timeout,
3007
+ metadata=metadata,
3008
+ )
3009
+
3010
+ # This method is paged; wrap the response in a pager, which provides
3011
+ # an `__iter__` convenience method.
3012
+ response = pagers.FetchStaticIpsPager(
3013
+ method=rpc,
3014
+ request=request,
3015
+ response=response,
3016
+ retry=retry,
3017
+ timeout=timeout,
3018
+ metadata=metadata,
3019
+ )
3020
+
3021
+ # Done; return the response.
3022
+ return response
3023
+
3024
+ def create_private_connection(
3025
+ self,
3026
+ request: Optional[
3027
+ Union[datastream.CreatePrivateConnectionRequest, dict]
3028
+ ] = None,
3029
+ *,
3030
+ parent: Optional[str] = None,
3031
+ private_connection: Optional[datastream_resources.PrivateConnection] = None,
3032
+ private_connection_id: Optional[str] = None,
3033
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3034
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3035
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3036
+ ) -> operation.Operation:
3037
+ r"""Use this method to create a private connectivity
3038
+ configuration.
3039
+
3040
+ .. code-block:: python
3041
+
3042
+ # This snippet has been automatically generated and should be regarded as a
3043
+ # code template only.
3044
+ # It will require modifications to work:
3045
+ # - It may require correct/in-range values for request initialization.
3046
+ # - It may require specifying regional endpoints when creating the service
3047
+ # client as shown in:
3048
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3049
+ from google.cloud import datastream_v1
3050
+
3051
+ def sample_create_private_connection():
3052
+ # Create a client
3053
+ client = datastream_v1.DatastreamClient()
3054
+
3055
+ # Initialize request argument(s)
3056
+ private_connection = datastream_v1.PrivateConnection()
3057
+ private_connection.display_name = "display_name_value"
3058
+
3059
+ request = datastream_v1.CreatePrivateConnectionRequest(
3060
+ parent="parent_value",
3061
+ private_connection_id="private_connection_id_value",
3062
+ private_connection=private_connection,
3063
+ )
3064
+
3065
+ # Make the request
3066
+ operation = client.create_private_connection(request=request)
3067
+
3068
+ print("Waiting for operation to complete...")
3069
+
3070
+ response = operation.result()
3071
+
3072
+ # Handle the response
3073
+ print(response)
3074
+
3075
+ Args:
3076
+ request (Union[google.cloud.datastream_v1.types.CreatePrivateConnectionRequest, dict]):
3077
+ The request object. Request for creating a private
3078
+ connection.
3079
+ parent (str):
3080
+ Required. The parent that owns the
3081
+ collection of PrivateConnections.
3082
+
3083
+ This corresponds to the ``parent`` field
3084
+ on the ``request`` instance; if ``request`` is provided, this
3085
+ should not be set.
3086
+ private_connection (google.cloud.datastream_v1.types.PrivateConnection):
3087
+ Required. The Private Connectivity
3088
+ resource to create.
3089
+
3090
+ This corresponds to the ``private_connection`` field
3091
+ on the ``request`` instance; if ``request`` is provided, this
3092
+ should not be set.
3093
+ private_connection_id (str):
3094
+ Required. The private connectivity
3095
+ identifier.
3096
+
3097
+ This corresponds to the ``private_connection_id`` field
3098
+ on the ``request`` instance; if ``request`` is provided, this
3099
+ should not be set.
3100
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3101
+ should be retried.
3102
+ timeout (float): The timeout for this request.
3103
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3104
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3105
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3106
+ be of type `bytes`.
3107
+
3108
+ Returns:
3109
+ google.api_core.operation.Operation:
3110
+ An object representing a long-running operation.
3111
+
3112
+ The result type for the operation will be :class:`google.cloud.datastream_v1.types.PrivateConnection` The PrivateConnection resource is used to establish private connectivity
3113
+ between Datastream and a customer's network.
3114
+
3115
+ """
3116
+ # Create or coerce a protobuf request object.
3117
+ # - Quick check: If we got a request object, we should *not* have
3118
+ # gotten any keyword arguments that map to the request.
3119
+ flattened_params = [parent, private_connection, private_connection_id]
3120
+ has_flattened_params = (
3121
+ len([param for param in flattened_params if param is not None]) > 0
3122
+ )
3123
+ if request is not None and has_flattened_params:
3124
+ raise ValueError(
3125
+ "If the `request` argument is set, then none of "
3126
+ "the individual field arguments should be set."
3127
+ )
3128
+
3129
+ # - Use the request object if provided (there's no risk of modifying the input as
3130
+ # there are no flattened fields), or create one.
3131
+ if not isinstance(request, datastream.CreatePrivateConnectionRequest):
3132
+ request = datastream.CreatePrivateConnectionRequest(request)
3133
+ # If we have keyword arguments corresponding to fields on the
3134
+ # request, apply these.
3135
+ if parent is not None:
3136
+ request.parent = parent
3137
+ if private_connection is not None:
3138
+ request.private_connection = private_connection
3139
+ if private_connection_id is not None:
3140
+ request.private_connection_id = private_connection_id
3141
+
3142
+ # Wrap the RPC method; this adds retry and timeout information,
3143
+ # and friendly error handling.
3144
+ rpc = self._transport._wrapped_methods[
3145
+ self._transport.create_private_connection
3146
+ ]
3147
+
3148
+ # Certain fields should be provided within the metadata header;
3149
+ # add these here.
3150
+ metadata = tuple(metadata) + (
3151
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
3152
+ )
3153
+
3154
+ # Validate the universe domain.
3155
+ self._validate_universe_domain()
3156
+
3157
+ # Send the request.
3158
+ response = rpc(
3159
+ request,
3160
+ retry=retry,
3161
+ timeout=timeout,
3162
+ metadata=metadata,
3163
+ )
3164
+
3165
+ # Wrap the response in an operation future.
3166
+ response = operation.from_gapic(
3167
+ response,
3168
+ self._transport.operations_client,
3169
+ datastream_resources.PrivateConnection,
3170
+ metadata_type=datastream.OperationMetadata,
3171
+ )
3172
+
3173
+ # Done; return the response.
3174
+ return response
3175
+
3176
+ def get_private_connection(
3177
+ self,
3178
+ request: Optional[Union[datastream.GetPrivateConnectionRequest, dict]] = None,
3179
+ *,
3180
+ name: Optional[str] = None,
3181
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3182
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3183
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3184
+ ) -> datastream_resources.PrivateConnection:
3185
+ r"""Use this method to get details about a private
3186
+ connectivity configuration.
3187
+
3188
+ .. code-block:: python
3189
+
3190
+ # This snippet has been automatically generated and should be regarded as a
3191
+ # code template only.
3192
+ # It will require modifications to work:
3193
+ # - It may require correct/in-range values for request initialization.
3194
+ # - It may require specifying regional endpoints when creating the service
3195
+ # client as shown in:
3196
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3197
+ from google.cloud import datastream_v1
3198
+
3199
+ def sample_get_private_connection():
3200
+ # Create a client
3201
+ client = datastream_v1.DatastreamClient()
3202
+
3203
+ # Initialize request argument(s)
3204
+ request = datastream_v1.GetPrivateConnectionRequest(
3205
+ name="name_value",
3206
+ )
3207
+
3208
+ # Make the request
3209
+ response = client.get_private_connection(request=request)
3210
+
3211
+ # Handle the response
3212
+ print(response)
3213
+
3214
+ Args:
3215
+ request (Union[google.cloud.datastream_v1.types.GetPrivateConnectionRequest, dict]):
3216
+ The request object. Request to get a private connection
3217
+ configuration.
3218
+ name (str):
3219
+ Required. The name of the private
3220
+ connectivity configuration to get.
3221
+
3222
+ This corresponds to the ``name`` field
3223
+ on the ``request`` instance; if ``request`` is provided, this
3224
+ should not be set.
3225
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3226
+ should be retried.
3227
+ timeout (float): The timeout for this request.
3228
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3229
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3230
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3231
+ be of type `bytes`.
3232
+
3233
+ Returns:
3234
+ google.cloud.datastream_v1.types.PrivateConnection:
3235
+ The PrivateConnection resource is
3236
+ used to establish private connectivity
3237
+ between Datastream and a customer's
3238
+ network.
3239
+
3240
+ """
3241
+ # Create or coerce a protobuf request object.
3242
+ # - Quick check: If we got a request object, we should *not* have
3243
+ # gotten any keyword arguments that map to the request.
3244
+ flattened_params = [name]
3245
+ has_flattened_params = (
3246
+ len([param for param in flattened_params if param is not None]) > 0
3247
+ )
3248
+ if request is not None and has_flattened_params:
3249
+ raise ValueError(
3250
+ "If the `request` argument is set, then none of "
3251
+ "the individual field arguments should be set."
3252
+ )
3253
+
3254
+ # - Use the request object if provided (there's no risk of modifying the input as
3255
+ # there are no flattened fields), or create one.
3256
+ if not isinstance(request, datastream.GetPrivateConnectionRequest):
3257
+ request = datastream.GetPrivateConnectionRequest(request)
3258
+ # If we have keyword arguments corresponding to fields on the
3259
+ # request, apply these.
3260
+ if name is not None:
3261
+ request.name = name
3262
+
3263
+ # Wrap the RPC method; this adds retry and timeout information,
3264
+ # and friendly error handling.
3265
+ rpc = self._transport._wrapped_methods[self._transport.get_private_connection]
3266
+
3267
+ # Certain fields should be provided within the metadata header;
3268
+ # add these here.
3269
+ metadata = tuple(metadata) + (
3270
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3271
+ )
3272
+
3273
+ # Validate the universe domain.
3274
+ self._validate_universe_domain()
3275
+
3276
+ # Send the request.
3277
+ response = rpc(
3278
+ request,
3279
+ retry=retry,
3280
+ timeout=timeout,
3281
+ metadata=metadata,
3282
+ )
3283
+
3284
+ # Done; return the response.
3285
+ return response
3286
+
3287
+ def list_private_connections(
3288
+ self,
3289
+ request: Optional[Union[datastream.ListPrivateConnectionsRequest, dict]] = None,
3290
+ *,
3291
+ parent: Optional[str] = None,
3292
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3293
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3294
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3295
+ ) -> pagers.ListPrivateConnectionsPager:
3296
+ r"""Use this method to list private connectivity
3297
+ configurations in a project and location.
3298
+
3299
+ .. code-block:: python
3300
+
3301
+ # This snippet has been automatically generated and should be regarded as a
3302
+ # code template only.
3303
+ # It will require modifications to work:
3304
+ # - It may require correct/in-range values for request initialization.
3305
+ # - It may require specifying regional endpoints when creating the service
3306
+ # client as shown in:
3307
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3308
+ from google.cloud import datastream_v1
3309
+
3310
+ def sample_list_private_connections():
3311
+ # Create a client
3312
+ client = datastream_v1.DatastreamClient()
3313
+
3314
+ # Initialize request argument(s)
3315
+ request = datastream_v1.ListPrivateConnectionsRequest(
3316
+ parent="parent_value",
3317
+ )
3318
+
3319
+ # Make the request
3320
+ page_result = client.list_private_connections(request=request)
3321
+
3322
+ # Handle the response
3323
+ for response in page_result:
3324
+ print(response)
3325
+
3326
+ Args:
3327
+ request (Union[google.cloud.datastream_v1.types.ListPrivateConnectionsRequest, dict]):
3328
+ The request object. Request for listing private
3329
+ connections.
3330
+ parent (str):
3331
+ Required. The parent that owns the
3332
+ collection of private connectivity
3333
+ configurations.
3334
+
3335
+ This corresponds to the ``parent`` field
3336
+ on the ``request`` instance; if ``request`` is provided, this
3337
+ should not be set.
3338
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3339
+ should be retried.
3340
+ timeout (float): The timeout for this request.
3341
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3342
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3343
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3344
+ be of type `bytes`.
3345
+
3346
+ Returns:
3347
+ google.cloud.datastream_v1.services.datastream.pagers.ListPrivateConnectionsPager:
3348
+ Response containing a list of private
3349
+ connection configurations.
3350
+ Iterating over this object will yield
3351
+ results and resolve additional pages
3352
+ automatically.
3353
+
3354
+ """
3355
+ # Create or coerce a protobuf request object.
3356
+ # - Quick check: If we got a request object, we should *not* have
3357
+ # gotten any keyword arguments that map to the request.
3358
+ flattened_params = [parent]
3359
+ has_flattened_params = (
3360
+ len([param for param in flattened_params if param is not None]) > 0
3361
+ )
3362
+ if request is not None and has_flattened_params:
3363
+ raise ValueError(
3364
+ "If the `request` argument is set, then none of "
3365
+ "the individual field arguments should be set."
3366
+ )
3367
+
3368
+ # - Use the request object if provided (there's no risk of modifying the input as
3369
+ # there are no flattened fields), or create one.
3370
+ if not isinstance(request, datastream.ListPrivateConnectionsRequest):
3371
+ request = datastream.ListPrivateConnectionsRequest(request)
3372
+ # If we have keyword arguments corresponding to fields on the
3373
+ # request, apply these.
3374
+ if parent is not None:
3375
+ request.parent = parent
3376
+
3377
+ # Wrap the RPC method; this adds retry and timeout information,
3378
+ # and friendly error handling.
3379
+ rpc = self._transport._wrapped_methods[self._transport.list_private_connections]
3380
+
3381
+ # Certain fields should be provided within the metadata header;
3382
+ # add these here.
3383
+ metadata = tuple(metadata) + (
3384
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
3385
+ )
3386
+
3387
+ # Validate the universe domain.
3388
+ self._validate_universe_domain()
3389
+
3390
+ # Send the request.
3391
+ response = rpc(
3392
+ request,
3393
+ retry=retry,
3394
+ timeout=timeout,
3395
+ metadata=metadata,
3396
+ )
3397
+
3398
+ # This method is paged; wrap the response in a pager, which provides
3399
+ # an `__iter__` convenience method.
3400
+ response = pagers.ListPrivateConnectionsPager(
3401
+ method=rpc,
3402
+ request=request,
3403
+ response=response,
3404
+ retry=retry,
3405
+ timeout=timeout,
3406
+ metadata=metadata,
3407
+ )
3408
+
3409
+ # Done; return the response.
3410
+ return response
3411
+
3412
+ def delete_private_connection(
3413
+ self,
3414
+ request: Optional[
3415
+ Union[datastream.DeletePrivateConnectionRequest, dict]
3416
+ ] = None,
3417
+ *,
3418
+ name: Optional[str] = None,
3419
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3420
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3421
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3422
+ ) -> operation.Operation:
3423
+ r"""Use this method to delete a private connectivity
3424
+ configuration.
3425
+
3426
+ .. code-block:: python
3427
+
3428
+ # This snippet has been automatically generated and should be regarded as a
3429
+ # code template only.
3430
+ # It will require modifications to work:
3431
+ # - It may require correct/in-range values for request initialization.
3432
+ # - It may require specifying regional endpoints when creating the service
3433
+ # client as shown in:
3434
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3435
+ from google.cloud import datastream_v1
3436
+
3437
+ def sample_delete_private_connection():
3438
+ # Create a client
3439
+ client = datastream_v1.DatastreamClient()
3440
+
3441
+ # Initialize request argument(s)
3442
+ request = datastream_v1.DeletePrivateConnectionRequest(
3443
+ name="name_value",
3444
+ )
3445
+
3446
+ # Make the request
3447
+ operation = client.delete_private_connection(request=request)
3448
+
3449
+ print("Waiting for operation to complete...")
3450
+
3451
+ response = operation.result()
3452
+
3453
+ # Handle the response
3454
+ print(response)
3455
+
3456
+ Args:
3457
+ request (Union[google.cloud.datastream_v1.types.DeletePrivateConnectionRequest, dict]):
3458
+ The request object. Request to delete a private
3459
+ connection.
3460
+ name (str):
3461
+ Required. The name of the private
3462
+ connectivity configuration to delete.
3463
+
3464
+ This corresponds to the ``name`` field
3465
+ on the ``request`` instance; if ``request`` is provided, this
3466
+ should not be set.
3467
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3468
+ should be retried.
3469
+ timeout (float): The timeout for this request.
3470
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3471
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3472
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3473
+ be of type `bytes`.
3474
+
3475
+ Returns:
3476
+ google.api_core.operation.Operation:
3477
+ An object representing a long-running operation.
3478
+
3479
+ 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
3480
+ empty messages in your APIs. A typical example is to
3481
+ use it as the request or the response type of an API
3482
+ method. For instance:
3483
+
3484
+ service Foo {
3485
+ rpc Bar(google.protobuf.Empty) returns
3486
+ (google.protobuf.Empty);
3487
+
3488
+ }
3489
+
3490
+ """
3491
+ # Create or coerce a protobuf request object.
3492
+ # - Quick check: If we got a request object, we should *not* have
3493
+ # gotten any keyword arguments that map to the request.
3494
+ flattened_params = [name]
3495
+ has_flattened_params = (
3496
+ len([param for param in flattened_params if param is not None]) > 0
3497
+ )
3498
+ if request is not None and has_flattened_params:
3499
+ raise ValueError(
3500
+ "If the `request` argument is set, then none of "
3501
+ "the individual field arguments should be set."
3502
+ )
3503
+
3504
+ # - Use the request object if provided (there's no risk of modifying the input as
3505
+ # there are no flattened fields), or create one.
3506
+ if not isinstance(request, datastream.DeletePrivateConnectionRequest):
3507
+ request = datastream.DeletePrivateConnectionRequest(request)
3508
+ # If we have keyword arguments corresponding to fields on the
3509
+ # request, apply these.
3510
+ if name is not None:
3511
+ request.name = name
3512
+
3513
+ # Wrap the RPC method; this adds retry and timeout information,
3514
+ # and friendly error handling.
3515
+ rpc = self._transport._wrapped_methods[
3516
+ self._transport.delete_private_connection
3517
+ ]
3518
+
3519
+ # Certain fields should be provided within the metadata header;
3520
+ # add these here.
3521
+ metadata = tuple(metadata) + (
3522
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3523
+ )
3524
+
3525
+ # Validate the universe domain.
3526
+ self._validate_universe_domain()
3527
+
3528
+ # Send the request.
3529
+ response = rpc(
3530
+ request,
3531
+ retry=retry,
3532
+ timeout=timeout,
3533
+ metadata=metadata,
3534
+ )
3535
+
3536
+ # Wrap the response in an operation future.
3537
+ response = operation.from_gapic(
3538
+ response,
3539
+ self._transport.operations_client,
3540
+ empty_pb2.Empty,
3541
+ metadata_type=datastream.OperationMetadata,
3542
+ )
3543
+
3544
+ # Done; return the response.
3545
+ return response
3546
+
3547
+ def create_route(
3548
+ self,
3549
+ request: Optional[Union[datastream.CreateRouteRequest, dict]] = None,
3550
+ *,
3551
+ parent: Optional[str] = None,
3552
+ route: Optional[datastream_resources.Route] = None,
3553
+ route_id: Optional[str] = None,
3554
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3555
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3556
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3557
+ ) -> operation.Operation:
3558
+ r"""Use this method to create a route for a private
3559
+ connectivity configuration in a project and location.
3560
+
3561
+ .. code-block:: python
3562
+
3563
+ # This snippet has been automatically generated and should be regarded as a
3564
+ # code template only.
3565
+ # It will require modifications to work:
3566
+ # - It may require correct/in-range values for request initialization.
3567
+ # - It may require specifying regional endpoints when creating the service
3568
+ # client as shown in:
3569
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3570
+ from google.cloud import datastream_v1
3571
+
3572
+ def sample_create_route():
3573
+ # Create a client
3574
+ client = datastream_v1.DatastreamClient()
3575
+
3576
+ # Initialize request argument(s)
3577
+ route = datastream_v1.Route()
3578
+ route.display_name = "display_name_value"
3579
+ route.destination_address = "destination_address_value"
3580
+
3581
+ request = datastream_v1.CreateRouteRequest(
3582
+ parent="parent_value",
3583
+ route_id="route_id_value",
3584
+ route=route,
3585
+ )
3586
+
3587
+ # Make the request
3588
+ operation = client.create_route(request=request)
3589
+
3590
+ print("Waiting for operation to complete...")
3591
+
3592
+ response = operation.result()
3593
+
3594
+ # Handle the response
3595
+ print(response)
3596
+
3597
+ Args:
3598
+ request (Union[google.cloud.datastream_v1.types.CreateRouteRequest, dict]):
3599
+ The request object. Route creation request.
3600
+ parent (str):
3601
+ Required. The parent that owns the
3602
+ collection of Routes.
3603
+
3604
+ This corresponds to the ``parent`` field
3605
+ on the ``request`` instance; if ``request`` is provided, this
3606
+ should not be set.
3607
+ route (google.cloud.datastream_v1.types.Route):
3608
+ Required. The Route resource to
3609
+ create.
3610
+
3611
+ This corresponds to the ``route`` field
3612
+ on the ``request`` instance; if ``request`` is provided, this
3613
+ should not be set.
3614
+ route_id (str):
3615
+ Required. The Route identifier.
3616
+ This corresponds to the ``route_id`` field
3617
+ on the ``request`` instance; if ``request`` is provided, this
3618
+ should not be set.
3619
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3620
+ should be retried.
3621
+ timeout (float): The timeout for this request.
3622
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3623
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3624
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3625
+ be of type `bytes`.
3626
+
3627
+ Returns:
3628
+ google.api_core.operation.Operation:
3629
+ An object representing a long-running operation.
3630
+
3631
+ The result type for the operation will be :class:`google.cloud.datastream_v1.types.Route` The route resource is the child of the private connection resource,
3632
+ used for defining a route for a private connection.
3633
+
3634
+ """
3635
+ # Create or coerce a protobuf request object.
3636
+ # - Quick check: If we got a request object, we should *not* have
3637
+ # gotten any keyword arguments that map to the request.
3638
+ flattened_params = [parent, route, route_id]
3639
+ has_flattened_params = (
3640
+ len([param for param in flattened_params if param is not None]) > 0
3641
+ )
3642
+ if request is not None and has_flattened_params:
3643
+ raise ValueError(
3644
+ "If the `request` argument is set, then none of "
3645
+ "the individual field arguments should be set."
3646
+ )
3647
+
3648
+ # - Use the request object if provided (there's no risk of modifying the input as
3649
+ # there are no flattened fields), or create one.
3650
+ if not isinstance(request, datastream.CreateRouteRequest):
3651
+ request = datastream.CreateRouteRequest(request)
3652
+ # If we have keyword arguments corresponding to fields on the
3653
+ # request, apply these.
3654
+ if parent is not None:
3655
+ request.parent = parent
3656
+ if route is not None:
3657
+ request.route = route
3658
+ if route_id is not None:
3659
+ request.route_id = route_id
3660
+
3661
+ # Wrap the RPC method; this adds retry and timeout information,
3662
+ # and friendly error handling.
3663
+ rpc = self._transport._wrapped_methods[self._transport.create_route]
3664
+
3665
+ # Certain fields should be provided within the metadata header;
3666
+ # add these here.
3667
+ metadata = tuple(metadata) + (
3668
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
3669
+ )
3670
+
3671
+ # Validate the universe domain.
3672
+ self._validate_universe_domain()
3673
+
3674
+ # Send the request.
3675
+ response = rpc(
3676
+ request,
3677
+ retry=retry,
3678
+ timeout=timeout,
3679
+ metadata=metadata,
3680
+ )
3681
+
3682
+ # Wrap the response in an operation future.
3683
+ response = operation.from_gapic(
3684
+ response,
3685
+ self._transport.operations_client,
3686
+ datastream_resources.Route,
3687
+ metadata_type=datastream.OperationMetadata,
3688
+ )
3689
+
3690
+ # Done; return the response.
3691
+ return response
3692
+
3693
+ def get_route(
3694
+ self,
3695
+ request: Optional[Union[datastream.GetRouteRequest, dict]] = None,
3696
+ *,
3697
+ name: Optional[str] = None,
3698
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3699
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3700
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3701
+ ) -> datastream_resources.Route:
3702
+ r"""Use this method to get details about a route.
3703
+
3704
+ .. code-block:: python
3705
+
3706
+ # This snippet has been automatically generated and should be regarded as a
3707
+ # code template only.
3708
+ # It will require modifications to work:
3709
+ # - It may require correct/in-range values for request initialization.
3710
+ # - It may require specifying regional endpoints when creating the service
3711
+ # client as shown in:
3712
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3713
+ from google.cloud import datastream_v1
3714
+
3715
+ def sample_get_route():
3716
+ # Create a client
3717
+ client = datastream_v1.DatastreamClient()
3718
+
3719
+ # Initialize request argument(s)
3720
+ request = datastream_v1.GetRouteRequest(
3721
+ name="name_value",
3722
+ )
3723
+
3724
+ # Make the request
3725
+ response = client.get_route(request=request)
3726
+
3727
+ # Handle the response
3728
+ print(response)
3729
+
3730
+ Args:
3731
+ request (Union[google.cloud.datastream_v1.types.GetRouteRequest, dict]):
3732
+ The request object. Route get request.
3733
+ name (str):
3734
+ Required. The name of the Route
3735
+ resource to get.
3736
+
3737
+ This corresponds to the ``name`` field
3738
+ on the ``request`` instance; if ``request`` is provided, this
3739
+ should not be set.
3740
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3741
+ should be retried.
3742
+ timeout (float): The timeout for this request.
3743
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3744
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3745
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3746
+ be of type `bytes`.
3747
+
3748
+ Returns:
3749
+ google.cloud.datastream_v1.types.Route:
3750
+ The route resource is the child of
3751
+ the private connection resource, used
3752
+ for defining a route for a private
3753
+ connection.
3754
+
3755
+ """
3756
+ # Create or coerce a protobuf request object.
3757
+ # - Quick check: If we got a request object, we should *not* have
3758
+ # gotten any keyword arguments that map to the request.
3759
+ flattened_params = [name]
3760
+ has_flattened_params = (
3761
+ len([param for param in flattened_params if param is not None]) > 0
3762
+ )
3763
+ if request is not None and has_flattened_params:
3764
+ raise ValueError(
3765
+ "If the `request` argument is set, then none of "
3766
+ "the individual field arguments should be set."
3767
+ )
3768
+
3769
+ # - Use the request object if provided (there's no risk of modifying the input as
3770
+ # there are no flattened fields), or create one.
3771
+ if not isinstance(request, datastream.GetRouteRequest):
3772
+ request = datastream.GetRouteRequest(request)
3773
+ # If we have keyword arguments corresponding to fields on the
3774
+ # request, apply these.
3775
+ if name is not None:
3776
+ request.name = name
3777
+
3778
+ # Wrap the RPC method; this adds retry and timeout information,
3779
+ # and friendly error handling.
3780
+ rpc = self._transport._wrapped_methods[self._transport.get_route]
3781
+
3782
+ # Certain fields should be provided within the metadata header;
3783
+ # add these here.
3784
+ metadata = tuple(metadata) + (
3785
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3786
+ )
3787
+
3788
+ # Validate the universe domain.
3789
+ self._validate_universe_domain()
3790
+
3791
+ # Send the request.
3792
+ response = rpc(
3793
+ request,
3794
+ retry=retry,
3795
+ timeout=timeout,
3796
+ metadata=metadata,
3797
+ )
3798
+
3799
+ # Done; return the response.
3800
+ return response
3801
+
3802
+ def list_routes(
3803
+ self,
3804
+ request: Optional[Union[datastream.ListRoutesRequest, dict]] = None,
3805
+ *,
3806
+ parent: Optional[str] = None,
3807
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3808
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3809
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3810
+ ) -> pagers.ListRoutesPager:
3811
+ r"""Use this method to list routes created for a private
3812
+ connectivity configuration in a project and location.
3813
+
3814
+ .. code-block:: python
3815
+
3816
+ # This snippet has been automatically generated and should be regarded as a
3817
+ # code template only.
3818
+ # It will require modifications to work:
3819
+ # - It may require correct/in-range values for request initialization.
3820
+ # - It may require specifying regional endpoints when creating the service
3821
+ # client as shown in:
3822
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3823
+ from google.cloud import datastream_v1
3824
+
3825
+ def sample_list_routes():
3826
+ # Create a client
3827
+ client = datastream_v1.DatastreamClient()
3828
+
3829
+ # Initialize request argument(s)
3830
+ request = datastream_v1.ListRoutesRequest(
3831
+ parent="parent_value",
3832
+ )
3833
+
3834
+ # Make the request
3835
+ page_result = client.list_routes(request=request)
3836
+
3837
+ # Handle the response
3838
+ for response in page_result:
3839
+ print(response)
3840
+
3841
+ Args:
3842
+ request (Union[google.cloud.datastream_v1.types.ListRoutesRequest, dict]):
3843
+ The request object. Route list request.
3844
+ parent (str):
3845
+ Required. The parent that owns the
3846
+ collection of Routess.
3847
+
3848
+ This corresponds to the ``parent`` field
3849
+ on the ``request`` instance; if ``request`` is provided, this
3850
+ should not be set.
3851
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3852
+ should be retried.
3853
+ timeout (float): The timeout for this request.
3854
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3855
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3856
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3857
+ be of type `bytes`.
3858
+
3859
+ Returns:
3860
+ google.cloud.datastream_v1.services.datastream.pagers.ListRoutesPager:
3861
+ Route list response.
3862
+
3863
+ Iterating over this object will yield
3864
+ results and resolve additional pages
3865
+ automatically.
3866
+
3867
+ """
3868
+ # Create or coerce a protobuf request object.
3869
+ # - Quick check: If we got a request object, we should *not* have
3870
+ # gotten any keyword arguments that map to the request.
3871
+ flattened_params = [parent]
3872
+ has_flattened_params = (
3873
+ len([param for param in flattened_params if param is not None]) > 0
3874
+ )
3875
+ if request is not None and has_flattened_params:
3876
+ raise ValueError(
3877
+ "If the `request` argument is set, then none of "
3878
+ "the individual field arguments should be set."
3879
+ )
3880
+
3881
+ # - Use the request object if provided (there's no risk of modifying the input as
3882
+ # there are no flattened fields), or create one.
3883
+ if not isinstance(request, datastream.ListRoutesRequest):
3884
+ request = datastream.ListRoutesRequest(request)
3885
+ # If we have keyword arguments corresponding to fields on the
3886
+ # request, apply these.
3887
+ if parent is not None:
3888
+ request.parent = parent
3889
+
3890
+ # Wrap the RPC method; this adds retry and timeout information,
3891
+ # and friendly error handling.
3892
+ rpc = self._transport._wrapped_methods[self._transport.list_routes]
3893
+
3894
+ # Certain fields should be provided within the metadata header;
3895
+ # add these here.
3896
+ metadata = tuple(metadata) + (
3897
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
3898
+ )
3899
+
3900
+ # Validate the universe domain.
3901
+ self._validate_universe_domain()
3902
+
3903
+ # Send the request.
3904
+ response = rpc(
3905
+ request,
3906
+ retry=retry,
3907
+ timeout=timeout,
3908
+ metadata=metadata,
3909
+ )
3910
+
3911
+ # This method is paged; wrap the response in a pager, which provides
3912
+ # an `__iter__` convenience method.
3913
+ response = pagers.ListRoutesPager(
3914
+ method=rpc,
3915
+ request=request,
3916
+ response=response,
3917
+ retry=retry,
3918
+ timeout=timeout,
3919
+ metadata=metadata,
3920
+ )
3921
+
3922
+ # Done; return the response.
3923
+ return response
3924
+
3925
+ def delete_route(
3926
+ self,
3927
+ request: Optional[Union[datastream.DeleteRouteRequest, dict]] = None,
3928
+ *,
3929
+ name: Optional[str] = None,
3930
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3931
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3932
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3933
+ ) -> operation.Operation:
3934
+ r"""Use this method to delete a route.
3935
+
3936
+ .. code-block:: python
3937
+
3938
+ # This snippet has been automatically generated and should be regarded as a
3939
+ # code template only.
3940
+ # It will require modifications to work:
3941
+ # - It may require correct/in-range values for request initialization.
3942
+ # - It may require specifying regional endpoints when creating the service
3943
+ # client as shown in:
3944
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3945
+ from google.cloud import datastream_v1
3946
+
3947
+ def sample_delete_route():
3948
+ # Create a client
3949
+ client = datastream_v1.DatastreamClient()
3950
+
3951
+ # Initialize request argument(s)
3952
+ request = datastream_v1.DeleteRouteRequest(
3953
+ name="name_value",
3954
+ )
3955
+
3956
+ # Make the request
3957
+ operation = client.delete_route(request=request)
3958
+
3959
+ print("Waiting for operation to complete...")
3960
+
3961
+ response = operation.result()
3962
+
3963
+ # Handle the response
3964
+ print(response)
3965
+
3966
+ Args:
3967
+ request (Union[google.cloud.datastream_v1.types.DeleteRouteRequest, dict]):
3968
+ The request object. Route deletion request.
3969
+ name (str):
3970
+ Required. The name of the Route
3971
+ resource to delete.
3972
+
3973
+ This corresponds to the ``name`` field
3974
+ on the ``request`` instance; if ``request`` is provided, this
3975
+ should not be set.
3976
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3977
+ should be retried.
3978
+ timeout (float): The timeout for this request.
3979
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3980
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3981
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3982
+ be of type `bytes`.
3983
+
3984
+ Returns:
3985
+ google.api_core.operation.Operation:
3986
+ An object representing a long-running operation.
3987
+
3988
+ 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
3989
+ empty messages in your APIs. A typical example is to
3990
+ use it as the request or the response type of an API
3991
+ method. For instance:
3992
+
3993
+ service Foo {
3994
+ rpc Bar(google.protobuf.Empty) returns
3995
+ (google.protobuf.Empty);
3996
+
3997
+ }
3998
+
3999
+ """
4000
+ # Create or coerce a protobuf request object.
4001
+ # - Quick check: If we got a request object, we should *not* have
4002
+ # gotten any keyword arguments that map to the request.
4003
+ flattened_params = [name]
4004
+ has_flattened_params = (
4005
+ len([param for param in flattened_params if param is not None]) > 0
4006
+ )
4007
+ if request is not None and has_flattened_params:
4008
+ raise ValueError(
4009
+ "If the `request` argument is set, then none of "
4010
+ "the individual field arguments should be set."
4011
+ )
4012
+
4013
+ # - Use the request object if provided (there's no risk of modifying the input as
4014
+ # there are no flattened fields), or create one.
4015
+ if not isinstance(request, datastream.DeleteRouteRequest):
4016
+ request = datastream.DeleteRouteRequest(request)
4017
+ # If we have keyword arguments corresponding to fields on the
4018
+ # request, apply these.
4019
+ if name is not None:
4020
+ request.name = name
4021
+
4022
+ # Wrap the RPC method; this adds retry and timeout information,
4023
+ # and friendly error handling.
4024
+ rpc = self._transport._wrapped_methods[self._transport.delete_route]
4025
+
4026
+ # Certain fields should be provided within the metadata header;
4027
+ # add these here.
4028
+ metadata = tuple(metadata) + (
4029
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
4030
+ )
4031
+
4032
+ # Validate the universe domain.
4033
+ self._validate_universe_domain()
4034
+
4035
+ # Send the request.
4036
+ response = rpc(
4037
+ request,
4038
+ retry=retry,
4039
+ timeout=timeout,
4040
+ metadata=metadata,
4041
+ )
4042
+
4043
+ # Wrap the response in an operation future.
4044
+ response = operation.from_gapic(
4045
+ response,
4046
+ self._transport.operations_client,
4047
+ empty_pb2.Empty,
4048
+ metadata_type=datastream.OperationMetadata,
4049
+ )
4050
+
4051
+ # Done; return the response.
4052
+ return response
4053
+
4054
+ def __enter__(self) -> "DatastreamClient":
4055
+ return self
4056
+
4057
+ def __exit__(self, type, value, traceback):
4058
+ """Releases underlying transport's resources.
4059
+
4060
+ .. warning::
4061
+ ONLY use as a context manager if the transport is NOT shared
4062
+ with other clients! Exiting the with block will CLOSE the transport
4063
+ and may cause errors in other clients!
4064
+ """
4065
+ self.transport.close()
4066
+
4067
+ def list_operations(
4068
+ self,
4069
+ request: Optional[operations_pb2.ListOperationsRequest] = None,
4070
+ *,
4071
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
4072
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
4073
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
4074
+ ) -> operations_pb2.ListOperationsResponse:
4075
+ r"""Lists operations that match the specified filter in the request.
4076
+
4077
+ Args:
4078
+ request (:class:`~.operations_pb2.ListOperationsRequest`):
4079
+ The request object. Request message for
4080
+ `ListOperations` method.
4081
+ retry (google.api_core.retry.Retry): Designation of what errors,
4082
+ if any, should be retried.
4083
+ timeout (float): The timeout for this request.
4084
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
4085
+ sent along with the request as metadata. Normally, each value must be of type `str`,
4086
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
4087
+ be of type `bytes`.
4088
+ Returns:
4089
+ ~.operations_pb2.ListOperationsResponse:
4090
+ Response message for ``ListOperations`` method.
4091
+ """
4092
+ # Create or coerce a protobuf request object.
4093
+ # The request isn't a proto-plus wrapped type,
4094
+ # so it must be constructed via keyword expansion.
4095
+ if isinstance(request, dict):
4096
+ request = operations_pb2.ListOperationsRequest(**request)
4097
+
4098
+ # Wrap the RPC method; this adds retry and timeout information,
4099
+ # and friendly error handling.
4100
+ rpc = self._transport._wrapped_methods[self._transport.list_operations]
4101
+
4102
+ # Certain fields should be provided within the metadata header;
4103
+ # add these here.
4104
+ metadata = tuple(metadata) + (
4105
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
4106
+ )
4107
+
4108
+ # Validate the universe domain.
4109
+ self._validate_universe_domain()
4110
+
4111
+ try:
4112
+ # Send the request.
4113
+ response = rpc(
4114
+ request,
4115
+ retry=retry,
4116
+ timeout=timeout,
4117
+ metadata=metadata,
4118
+ )
4119
+
4120
+ # Done; return the response.
4121
+ return response
4122
+ except core_exceptions.GoogleAPICallError as e:
4123
+ self._add_cred_info_for_auth_errors(e)
4124
+ raise e
4125
+
4126
+ def get_operation(
4127
+ self,
4128
+ request: Optional[operations_pb2.GetOperationRequest] = None,
4129
+ *,
4130
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
4131
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
4132
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
4133
+ ) -> operations_pb2.Operation:
4134
+ r"""Gets the latest state of a long-running operation.
4135
+
4136
+ Args:
4137
+ request (:class:`~.operations_pb2.GetOperationRequest`):
4138
+ The request object. Request message for
4139
+ `GetOperation` method.
4140
+ retry (google.api_core.retry.Retry): Designation of what errors,
4141
+ if any, should be retried.
4142
+ timeout (float): The timeout for this request.
4143
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
4144
+ sent along with the request as metadata. Normally, each value must be of type `str`,
4145
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
4146
+ be of type `bytes`.
4147
+ Returns:
4148
+ ~.operations_pb2.Operation:
4149
+ An ``Operation`` object.
4150
+ """
4151
+ # Create or coerce a protobuf request object.
4152
+ # The request isn't a proto-plus wrapped type,
4153
+ # so it must be constructed via keyword expansion.
4154
+ if isinstance(request, dict):
4155
+ request = operations_pb2.GetOperationRequest(**request)
4156
+
4157
+ # Wrap the RPC method; this adds retry and timeout information,
4158
+ # and friendly error handling.
4159
+ rpc = self._transport._wrapped_methods[self._transport.get_operation]
4160
+
4161
+ # Certain fields should be provided within the metadata header;
4162
+ # add these here.
4163
+ metadata = tuple(metadata) + (
4164
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
4165
+ )
4166
+
4167
+ # Validate the universe domain.
4168
+ self._validate_universe_domain()
4169
+
4170
+ try:
4171
+ # Send the request.
4172
+ response = rpc(
4173
+ request,
4174
+ retry=retry,
4175
+ timeout=timeout,
4176
+ metadata=metadata,
4177
+ )
4178
+
4179
+ # Done; return the response.
4180
+ return response
4181
+ except core_exceptions.GoogleAPICallError as e:
4182
+ self._add_cred_info_for_auth_errors(e)
4183
+ raise e
4184
+
4185
+ def delete_operation(
4186
+ self,
4187
+ request: Optional[operations_pb2.DeleteOperationRequest] = None,
4188
+ *,
4189
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
4190
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
4191
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
4192
+ ) -> None:
4193
+ r"""Deletes a long-running operation.
4194
+
4195
+ This method indicates that the client is no longer interested
4196
+ in the operation result. It does not cancel the operation.
4197
+ If the server doesn't support this method, it returns
4198
+ `google.rpc.Code.UNIMPLEMENTED`.
4199
+
4200
+ Args:
4201
+ request (:class:`~.operations_pb2.DeleteOperationRequest`):
4202
+ The request object. Request message for
4203
+ `DeleteOperation` method.
4204
+ retry (google.api_core.retry.Retry): Designation of what errors,
4205
+ if any, should be retried.
4206
+ timeout (float): The timeout for this request.
4207
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
4208
+ sent along with the request as metadata. Normally, each value must be of type `str`,
4209
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
4210
+ be of type `bytes`.
4211
+ Returns:
4212
+ None
4213
+ """
4214
+ # Create or coerce a protobuf request object.
4215
+ # The request isn't a proto-plus wrapped type,
4216
+ # so it must be constructed via keyword expansion.
4217
+ if isinstance(request, dict):
4218
+ request = operations_pb2.DeleteOperationRequest(**request)
4219
+
4220
+ # Wrap the RPC method; this adds retry and timeout information,
4221
+ # and friendly error handling.
4222
+ rpc = self._transport._wrapped_methods[self._transport.delete_operation]
4223
+
4224
+ # Certain fields should be provided within the metadata header;
4225
+ # add these here.
4226
+ metadata = tuple(metadata) + (
4227
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
4228
+ )
4229
+
4230
+ # Validate the universe domain.
4231
+ self._validate_universe_domain()
4232
+
4233
+ # Send the request.
4234
+ rpc(
4235
+ request,
4236
+ retry=retry,
4237
+ timeout=timeout,
4238
+ metadata=metadata,
4239
+ )
4240
+
4241
+ def cancel_operation(
4242
+ self,
4243
+ request: Optional[operations_pb2.CancelOperationRequest] = None,
4244
+ *,
4245
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
4246
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
4247
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
4248
+ ) -> None:
4249
+ r"""Starts asynchronous cancellation on a long-running operation.
4250
+
4251
+ The server makes a best effort to cancel the operation, but success
4252
+ is not guaranteed. If the server doesn't support this method, it returns
4253
+ `google.rpc.Code.UNIMPLEMENTED`.
4254
+
4255
+ Args:
4256
+ request (:class:`~.operations_pb2.CancelOperationRequest`):
4257
+ The request object. Request message for
4258
+ `CancelOperation` method.
4259
+ retry (google.api_core.retry.Retry): Designation of what errors,
4260
+ if any, should be retried.
4261
+ timeout (float): The timeout for this request.
4262
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
4263
+ sent along with the request as metadata. Normally, each value must be of type `str`,
4264
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
4265
+ be of type `bytes`.
4266
+ Returns:
4267
+ None
4268
+ """
4269
+ # Create or coerce a protobuf request object.
4270
+ # The request isn't a proto-plus wrapped type,
4271
+ # so it must be constructed via keyword expansion.
4272
+ if isinstance(request, dict):
4273
+ request = operations_pb2.CancelOperationRequest(**request)
4274
+
4275
+ # Wrap the RPC method; this adds retry and timeout information,
4276
+ # and friendly error handling.
4277
+ rpc = self._transport._wrapped_methods[self._transport.cancel_operation]
4278
+
4279
+ # Certain fields should be provided within the metadata header;
4280
+ # add these here.
4281
+ metadata = tuple(metadata) + (
4282
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
4283
+ )
4284
+
4285
+ # Validate the universe domain.
4286
+ self._validate_universe_domain()
4287
+
4288
+ # Send the request.
4289
+ rpc(
4290
+ request,
4291
+ retry=retry,
4292
+ timeout=timeout,
4293
+ metadata=metadata,
4294
+ )
4295
+
4296
+ def get_location(
4297
+ self,
4298
+ request: Optional[locations_pb2.GetLocationRequest] = None,
4299
+ *,
4300
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
4301
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
4302
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
4303
+ ) -> locations_pb2.Location:
4304
+ r"""Gets information about a location.
4305
+
4306
+ Args:
4307
+ request (:class:`~.location_pb2.GetLocationRequest`):
4308
+ The request object. Request message for
4309
+ `GetLocation` method.
4310
+ retry (google.api_core.retry.Retry): Designation of what errors,
4311
+ if any, should be retried.
4312
+ timeout (float): The timeout for this request.
4313
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
4314
+ sent along with the request as metadata. Normally, each value must be of type `str`,
4315
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
4316
+ be of type `bytes`.
4317
+ Returns:
4318
+ ~.location_pb2.Location:
4319
+ Location object.
4320
+ """
4321
+ # Create or coerce a protobuf request object.
4322
+ # The request isn't a proto-plus wrapped type,
4323
+ # so it must be constructed via keyword expansion.
4324
+ if isinstance(request, dict):
4325
+ request = locations_pb2.GetLocationRequest(**request)
4326
+
4327
+ # Wrap the RPC method; this adds retry and timeout information,
4328
+ # and friendly error handling.
4329
+ rpc = self._transport._wrapped_methods[self._transport.get_location]
4330
+
4331
+ # Certain fields should be provided within the metadata header;
4332
+ # add these here.
4333
+ metadata = tuple(metadata) + (
4334
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
4335
+ )
4336
+
4337
+ # Validate the universe domain.
4338
+ self._validate_universe_domain()
4339
+
4340
+ try:
4341
+ # Send the request.
4342
+ response = rpc(
4343
+ request,
4344
+ retry=retry,
4345
+ timeout=timeout,
4346
+ metadata=metadata,
4347
+ )
4348
+
4349
+ # Done; return the response.
4350
+ return response
4351
+ except core_exceptions.GoogleAPICallError as e:
4352
+ self._add_cred_info_for_auth_errors(e)
4353
+ raise e
4354
+
4355
+ def list_locations(
4356
+ self,
4357
+ request: Optional[locations_pb2.ListLocationsRequest] = None,
4358
+ *,
4359
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
4360
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
4361
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
4362
+ ) -> locations_pb2.ListLocationsResponse:
4363
+ r"""Lists information about the supported locations for this service.
4364
+
4365
+ Args:
4366
+ request (:class:`~.location_pb2.ListLocationsRequest`):
4367
+ The request object. Request message for
4368
+ `ListLocations` method.
4369
+ retry (google.api_core.retry.Retry): Designation of what errors,
4370
+ if any, should be retried.
4371
+ timeout (float): The timeout for this request.
4372
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
4373
+ sent along with the request as metadata. Normally, each value must be of type `str`,
4374
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
4375
+ be of type `bytes`.
4376
+ Returns:
4377
+ ~.location_pb2.ListLocationsResponse:
4378
+ Response message for ``ListLocations`` method.
4379
+ """
4380
+ # Create or coerce a protobuf request object.
4381
+ # The request isn't a proto-plus wrapped type,
4382
+ # so it must be constructed via keyword expansion.
4383
+ if isinstance(request, dict):
4384
+ request = locations_pb2.ListLocationsRequest(**request)
4385
+
4386
+ # Wrap the RPC method; this adds retry and timeout information,
4387
+ # and friendly error handling.
4388
+ rpc = self._transport._wrapped_methods[self._transport.list_locations]
4389
+
4390
+ # Certain fields should be provided within the metadata header;
4391
+ # add these here.
4392
+ metadata = tuple(metadata) + (
4393
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
4394
+ )
4395
+
4396
+ # Validate the universe domain.
4397
+ self._validate_universe_domain()
4398
+
4399
+ try:
4400
+ # Send the request.
4401
+ response = rpc(
4402
+ request,
4403
+ retry=retry,
4404
+ timeout=timeout,
4405
+ metadata=metadata,
4406
+ )
4407
+
4408
+ # Done; return the response.
4409
+ return response
4410
+ except core_exceptions.GoogleAPICallError as e:
4411
+ self._add_cred_info_for_auth_errors(e)
4412
+ raise e
4413
+
4414
+
4415
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
4416
+ gapic_version=package_version.__version__
4417
+ )
4418
+
4419
+
4420
+ __all__ = ("DatastreamClient",)