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,3458 @@
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_v1alpha1 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.protobuf import empty_pb2 # type: ignore
66
+ from google.protobuf import field_mask_pb2 # type: ignore
67
+ from google.protobuf import timestamp_pb2 # type: ignore
68
+
69
+ from google.cloud.datastream_v1alpha1.services.datastream import pagers
70
+ from google.cloud.datastream_v1alpha1.types import datastream, datastream_resources
71
+
72
+ from .transports.base import DEFAULT_CLIENT_INFO, DatastreamTransport
73
+ from .transports.grpc import DatastreamGrpcTransport
74
+ from .transports.grpc_asyncio import DatastreamGrpcAsyncIOTransport
75
+ from .transports.rest import DatastreamRestTransport
76
+
77
+
78
+ class DatastreamClientMeta(type):
79
+ """Metaclass for the Datastream client.
80
+
81
+ This provides class-level methods for building and retrieving
82
+ support objects (e.g. transport) without polluting the client instance
83
+ objects.
84
+ """
85
+
86
+ _transport_registry = OrderedDict() # type: Dict[str, Type[DatastreamTransport]]
87
+ _transport_registry["grpc"] = DatastreamGrpcTransport
88
+ _transport_registry["grpc_asyncio"] = DatastreamGrpcAsyncIOTransport
89
+ _transport_registry["rest"] = DatastreamRestTransport
90
+
91
+ def get_transport_class(
92
+ cls,
93
+ label: Optional[str] = None,
94
+ ) -> Type[DatastreamTransport]:
95
+ """Returns an appropriate transport class.
96
+
97
+ Args:
98
+ label: The name of the desired transport. If none is
99
+ provided, then the first transport in the registry is used.
100
+
101
+ Returns:
102
+ The transport class to use.
103
+ """
104
+ # If a specific transport is requested, return that one.
105
+ if label:
106
+ return cls._transport_registry[label]
107
+
108
+ # No transport is requested; return the default (that is, the first one
109
+ # in the dictionary).
110
+ return next(iter(cls._transport_registry.values()))
111
+
112
+
113
+ class DatastreamClient(metaclass=DatastreamClientMeta):
114
+ """Datastream service"""
115
+
116
+ @staticmethod
117
+ def _get_default_mtls_endpoint(api_endpoint):
118
+ """Converts api endpoint to mTLS endpoint.
119
+
120
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
121
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
122
+ Args:
123
+ api_endpoint (Optional[str]): the api endpoint to convert.
124
+ Returns:
125
+ str: converted mTLS api endpoint.
126
+ """
127
+ if not api_endpoint:
128
+ return api_endpoint
129
+
130
+ mtls_endpoint_re = re.compile(
131
+ r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
132
+ )
133
+
134
+ m = mtls_endpoint_re.match(api_endpoint)
135
+ name, mtls, sandbox, googledomain = m.groups()
136
+ if mtls or not googledomain:
137
+ return api_endpoint
138
+
139
+ if sandbox:
140
+ return api_endpoint.replace(
141
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
142
+ )
143
+
144
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
145
+
146
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
147
+ DEFAULT_ENDPOINT = "datastream.googleapis.com"
148
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
149
+ DEFAULT_ENDPOINT
150
+ )
151
+
152
+ _DEFAULT_ENDPOINT_TEMPLATE = "datastream.{UNIVERSE_DOMAIN}"
153
+ _DEFAULT_UNIVERSE = "googleapis.com"
154
+
155
+ @classmethod
156
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
157
+ """Creates an instance of this client using the provided credentials
158
+ info.
159
+
160
+ Args:
161
+ info (dict): The service account private key info.
162
+ args: Additional arguments to pass to the constructor.
163
+ kwargs: Additional arguments to pass to the constructor.
164
+
165
+ Returns:
166
+ DatastreamClient: The constructed client.
167
+ """
168
+ credentials = service_account.Credentials.from_service_account_info(info)
169
+ kwargs["credentials"] = credentials
170
+ return cls(*args, **kwargs)
171
+
172
+ @classmethod
173
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
174
+ """Creates an instance of this client using the provided credentials
175
+ file.
176
+
177
+ Args:
178
+ filename (str): The path to the service account private key json
179
+ file.
180
+ args: Additional arguments to pass to the constructor.
181
+ kwargs: Additional arguments to pass to the constructor.
182
+
183
+ Returns:
184
+ DatastreamClient: The constructed client.
185
+ """
186
+ credentials = service_account.Credentials.from_service_account_file(filename)
187
+ kwargs["credentials"] = credentials
188
+ return cls(*args, **kwargs)
189
+
190
+ from_service_account_json = from_service_account_file
191
+
192
+ @property
193
+ def transport(self) -> DatastreamTransport:
194
+ """Returns the transport used by the client instance.
195
+
196
+ Returns:
197
+ DatastreamTransport: The transport used by the client
198
+ instance.
199
+ """
200
+ return self._transport
201
+
202
+ @staticmethod
203
+ def connection_profile_path(
204
+ project: str,
205
+ location: str,
206
+ connection_profile: str,
207
+ ) -> str:
208
+ """Returns a fully-qualified connection_profile string."""
209
+ return "projects/{project}/locations/{location}/connectionProfiles/{connection_profile}".format(
210
+ project=project,
211
+ location=location,
212
+ connection_profile=connection_profile,
213
+ )
214
+
215
+ @staticmethod
216
+ def parse_connection_profile_path(path: str) -> Dict[str, str]:
217
+ """Parses a connection_profile path into its component segments."""
218
+ m = re.match(
219
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/connectionProfiles/(?P<connection_profile>.+?)$",
220
+ path,
221
+ )
222
+ return m.groupdict() if m else {}
223
+
224
+ @staticmethod
225
+ def private_connection_path(
226
+ project: str,
227
+ location: str,
228
+ private_connection: str,
229
+ ) -> str:
230
+ """Returns a fully-qualified private_connection string."""
231
+ return "projects/{project}/locations/{location}/privateConnections/{private_connection}".format(
232
+ project=project,
233
+ location=location,
234
+ private_connection=private_connection,
235
+ )
236
+
237
+ @staticmethod
238
+ def parse_private_connection_path(path: str) -> Dict[str, str]:
239
+ """Parses a private_connection path into its component segments."""
240
+ m = re.match(
241
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/privateConnections/(?P<private_connection>.+?)$",
242
+ path,
243
+ )
244
+ return m.groupdict() if m else {}
245
+
246
+ @staticmethod
247
+ def route_path(
248
+ project: str,
249
+ location: str,
250
+ private_connection: str,
251
+ route: str,
252
+ ) -> str:
253
+ """Returns a fully-qualified route string."""
254
+ return "projects/{project}/locations/{location}/privateConnections/{private_connection}/routes/{route}".format(
255
+ project=project,
256
+ location=location,
257
+ private_connection=private_connection,
258
+ route=route,
259
+ )
260
+
261
+ @staticmethod
262
+ def parse_route_path(path: str) -> Dict[str, str]:
263
+ """Parses a route path into its component segments."""
264
+ m = re.match(
265
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/privateConnections/(?P<private_connection>.+?)/routes/(?P<route>.+?)$",
266
+ path,
267
+ )
268
+ return m.groupdict() if m else {}
269
+
270
+ @staticmethod
271
+ def stream_path(
272
+ project: str,
273
+ location: str,
274
+ stream: str,
275
+ ) -> str:
276
+ """Returns a fully-qualified stream string."""
277
+ return "projects/{project}/locations/{location}/streams/{stream}".format(
278
+ project=project,
279
+ location=location,
280
+ stream=stream,
281
+ )
282
+
283
+ @staticmethod
284
+ def parse_stream_path(path: str) -> Dict[str, str]:
285
+ """Parses a stream path into its component segments."""
286
+ m = re.match(
287
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/streams/(?P<stream>.+?)$",
288
+ path,
289
+ )
290
+ return m.groupdict() if m else {}
291
+
292
+ @staticmethod
293
+ def common_billing_account_path(
294
+ billing_account: str,
295
+ ) -> str:
296
+ """Returns a fully-qualified billing_account string."""
297
+ return "billingAccounts/{billing_account}".format(
298
+ billing_account=billing_account,
299
+ )
300
+
301
+ @staticmethod
302
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
303
+ """Parse a billing_account path into its component segments."""
304
+ m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
305
+ return m.groupdict() if m else {}
306
+
307
+ @staticmethod
308
+ def common_folder_path(
309
+ folder: str,
310
+ ) -> str:
311
+ """Returns a fully-qualified folder string."""
312
+ return "folders/{folder}".format(
313
+ folder=folder,
314
+ )
315
+
316
+ @staticmethod
317
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
318
+ """Parse a folder path into its component segments."""
319
+ m = re.match(r"^folders/(?P<folder>.+?)$", path)
320
+ return m.groupdict() if m else {}
321
+
322
+ @staticmethod
323
+ def common_organization_path(
324
+ organization: str,
325
+ ) -> str:
326
+ """Returns a fully-qualified organization string."""
327
+ return "organizations/{organization}".format(
328
+ organization=organization,
329
+ )
330
+
331
+ @staticmethod
332
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
333
+ """Parse a organization path into its component segments."""
334
+ m = re.match(r"^organizations/(?P<organization>.+?)$", path)
335
+ return m.groupdict() if m else {}
336
+
337
+ @staticmethod
338
+ def common_project_path(
339
+ project: str,
340
+ ) -> str:
341
+ """Returns a fully-qualified project string."""
342
+ return "projects/{project}".format(
343
+ project=project,
344
+ )
345
+
346
+ @staticmethod
347
+ def parse_common_project_path(path: str) -> Dict[str, str]:
348
+ """Parse a project path into its component segments."""
349
+ m = re.match(r"^projects/(?P<project>.+?)$", path)
350
+ return m.groupdict() if m else {}
351
+
352
+ @staticmethod
353
+ def common_location_path(
354
+ project: str,
355
+ location: str,
356
+ ) -> str:
357
+ """Returns a fully-qualified location string."""
358
+ return "projects/{project}/locations/{location}".format(
359
+ project=project,
360
+ location=location,
361
+ )
362
+
363
+ @staticmethod
364
+ def parse_common_location_path(path: str) -> Dict[str, str]:
365
+ """Parse a location path into its component segments."""
366
+ m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
367
+ return m.groupdict() if m else {}
368
+
369
+ @classmethod
370
+ def get_mtls_endpoint_and_cert_source(
371
+ cls, client_options: Optional[client_options_lib.ClientOptions] = None
372
+ ):
373
+ """Deprecated. Return the API endpoint and client cert source for mutual TLS.
374
+
375
+ The client cert source is determined in the following order:
376
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
377
+ client cert source is None.
378
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
379
+ default client cert source exists, use the default one; otherwise the client cert
380
+ source is None.
381
+
382
+ The API endpoint is determined in the following order:
383
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
384
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
385
+ default mTLS endpoint; if the environment variable is "never", use the default API
386
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
387
+ use the default API endpoint.
388
+
389
+ More details can be found at https://google.aip.dev/auth/4114.
390
+
391
+ Args:
392
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
393
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
394
+ in this method.
395
+
396
+ Returns:
397
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
398
+ client cert source to use.
399
+
400
+ Raises:
401
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
402
+ """
403
+
404
+ warnings.warn(
405
+ "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
406
+ DeprecationWarning,
407
+ )
408
+ if client_options is None:
409
+ client_options = client_options_lib.ClientOptions()
410
+ use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
411
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
412
+ if use_client_cert not in ("true", "false"):
413
+ raise ValueError(
414
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
415
+ )
416
+ if use_mtls_endpoint not in ("auto", "never", "always"):
417
+ raise MutualTLSChannelError(
418
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
419
+ )
420
+
421
+ # Figure out the client cert source to use.
422
+ client_cert_source = None
423
+ if use_client_cert == "true":
424
+ if client_options.client_cert_source:
425
+ client_cert_source = client_options.client_cert_source
426
+ elif mtls.has_default_client_cert_source():
427
+ client_cert_source = mtls.default_client_cert_source()
428
+
429
+ # Figure out which api endpoint to use.
430
+ if client_options.api_endpoint is not None:
431
+ api_endpoint = client_options.api_endpoint
432
+ elif use_mtls_endpoint == "always" or (
433
+ use_mtls_endpoint == "auto" and client_cert_source
434
+ ):
435
+ api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
436
+ else:
437
+ api_endpoint = cls.DEFAULT_ENDPOINT
438
+
439
+ return api_endpoint, client_cert_source
440
+
441
+ @staticmethod
442
+ def _read_environment_variables():
443
+ """Returns the environment variables used by the client.
444
+
445
+ Returns:
446
+ Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
447
+ GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
448
+
449
+ Raises:
450
+ ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
451
+ any of ["true", "false"].
452
+ google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
453
+ is not any of ["auto", "never", "always"].
454
+ """
455
+ use_client_cert = os.getenv(
456
+ "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
457
+ ).lower()
458
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
459
+ universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
460
+ if use_client_cert not in ("true", "false"):
461
+ raise ValueError(
462
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
463
+ )
464
+ if use_mtls_endpoint not in ("auto", "never", "always"):
465
+ raise MutualTLSChannelError(
466
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
467
+ )
468
+ return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
469
+
470
+ @staticmethod
471
+ def _get_client_cert_source(provided_cert_source, use_cert_flag):
472
+ """Return the client cert source to be used by the client.
473
+
474
+ Args:
475
+ provided_cert_source (bytes): The client certificate source provided.
476
+ use_cert_flag (bool): A flag indicating whether to use the client certificate.
477
+
478
+ Returns:
479
+ bytes or None: The client cert source to be used by the client.
480
+ """
481
+ client_cert_source = None
482
+ if use_cert_flag:
483
+ if provided_cert_source:
484
+ client_cert_source = provided_cert_source
485
+ elif mtls.has_default_client_cert_source():
486
+ client_cert_source = mtls.default_client_cert_source()
487
+ return client_cert_source
488
+
489
+ @staticmethod
490
+ def _get_api_endpoint(
491
+ api_override, client_cert_source, universe_domain, use_mtls_endpoint
492
+ ):
493
+ """Return the API endpoint used by the client.
494
+
495
+ Args:
496
+ api_override (str): The API endpoint override. If specified, this is always
497
+ the return value of this function and the other arguments are not used.
498
+ client_cert_source (bytes): The client certificate source used by the client.
499
+ universe_domain (str): The universe domain used by the client.
500
+ use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
501
+ Possible values are "always", "auto", or "never".
502
+
503
+ Returns:
504
+ str: The API endpoint to be used by the client.
505
+ """
506
+ if api_override is not None:
507
+ api_endpoint = api_override
508
+ elif use_mtls_endpoint == "always" or (
509
+ use_mtls_endpoint == "auto" and client_cert_source
510
+ ):
511
+ _default_universe = DatastreamClient._DEFAULT_UNIVERSE
512
+ if universe_domain != _default_universe:
513
+ raise MutualTLSChannelError(
514
+ f"mTLS is not supported in any universe other than {_default_universe}."
515
+ )
516
+ api_endpoint = DatastreamClient.DEFAULT_MTLS_ENDPOINT
517
+ else:
518
+ api_endpoint = DatastreamClient._DEFAULT_ENDPOINT_TEMPLATE.format(
519
+ UNIVERSE_DOMAIN=universe_domain
520
+ )
521
+ return api_endpoint
522
+
523
+ @staticmethod
524
+ def _get_universe_domain(
525
+ client_universe_domain: Optional[str], universe_domain_env: Optional[str]
526
+ ) -> str:
527
+ """Return the universe domain used by the client.
528
+
529
+ Args:
530
+ client_universe_domain (Optional[str]): The universe domain configured via the client options.
531
+ universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
532
+
533
+ Returns:
534
+ str: The universe domain to be used by the client.
535
+
536
+ Raises:
537
+ ValueError: If the universe domain is an empty string.
538
+ """
539
+ universe_domain = DatastreamClient._DEFAULT_UNIVERSE
540
+ if client_universe_domain is not None:
541
+ universe_domain = client_universe_domain
542
+ elif universe_domain_env is not None:
543
+ universe_domain = universe_domain_env
544
+ if len(universe_domain.strip()) == 0:
545
+ raise ValueError("Universe Domain cannot be an empty string.")
546
+ return universe_domain
547
+
548
+ def _validate_universe_domain(self):
549
+ """Validates client's and credentials' universe domains are consistent.
550
+
551
+ Returns:
552
+ bool: True iff the configured universe domain is valid.
553
+
554
+ Raises:
555
+ ValueError: If the configured universe domain is not valid.
556
+ """
557
+
558
+ # NOTE (b/349488459): universe validation is disabled until further notice.
559
+ return True
560
+
561
+ def _add_cred_info_for_auth_errors(
562
+ self, error: core_exceptions.GoogleAPICallError
563
+ ) -> None:
564
+ """Adds credential info string to error details for 401/403/404 errors.
565
+
566
+ Args:
567
+ error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
568
+ """
569
+ if error.code not in [
570
+ HTTPStatus.UNAUTHORIZED,
571
+ HTTPStatus.FORBIDDEN,
572
+ HTTPStatus.NOT_FOUND,
573
+ ]:
574
+ return
575
+
576
+ cred = self._transport._credentials
577
+
578
+ # get_cred_info is only available in google-auth>=2.35.0
579
+ if not hasattr(cred, "get_cred_info"):
580
+ return
581
+
582
+ # ignore the type check since pypy test fails when get_cred_info
583
+ # is not available
584
+ cred_info = cred.get_cred_info() # type: ignore
585
+ if cred_info and hasattr(error._details, "append"):
586
+ error._details.append(json.dumps(cred_info))
587
+
588
+ @property
589
+ def api_endpoint(self):
590
+ """Return the API endpoint used by the client instance.
591
+
592
+ Returns:
593
+ str: The API endpoint used by the client instance.
594
+ """
595
+ return self._api_endpoint
596
+
597
+ @property
598
+ def universe_domain(self) -> str:
599
+ """Return the universe domain used by the client instance.
600
+
601
+ Returns:
602
+ str: The universe domain used by the client instance.
603
+ """
604
+ return self._universe_domain
605
+
606
+ def __init__(
607
+ self,
608
+ *,
609
+ credentials: Optional[ga_credentials.Credentials] = None,
610
+ transport: Optional[
611
+ Union[str, DatastreamTransport, Callable[..., DatastreamTransport]]
612
+ ] = None,
613
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
614
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
615
+ ) -> None:
616
+ """Instantiates the datastream client.
617
+
618
+ Args:
619
+ credentials (Optional[google.auth.credentials.Credentials]): The
620
+ authorization credentials to attach to requests. These
621
+ credentials identify the application to the service; if none
622
+ are specified, the client will attempt to ascertain the
623
+ credentials from the environment.
624
+ transport (Optional[Union[str,DatastreamTransport,Callable[..., DatastreamTransport]]]):
625
+ The transport to use, or a Callable that constructs and returns a new transport.
626
+ If a Callable is given, it will be called with the same set of initialization
627
+ arguments as used in the DatastreamTransport constructor.
628
+ If set to None, a transport is chosen automatically.
629
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
630
+ Custom options for the client.
631
+
632
+ 1. The ``api_endpoint`` property can be used to override the
633
+ default endpoint provided by the client when ``transport`` is
634
+ not explicitly provided. Only if this property is not set and
635
+ ``transport`` was not explicitly provided, the endpoint is
636
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
637
+ variable, which have one of the following values:
638
+ "always" (always use the default mTLS endpoint), "never" (always
639
+ use the default regular endpoint) and "auto" (auto-switch to the
640
+ default mTLS endpoint if client certificate is present; this is
641
+ the default value).
642
+
643
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
644
+ is "true", then the ``client_cert_source`` property can be used
645
+ to provide a client certificate for mTLS transport. If
646
+ not provided, the default SSL client certificate will be used if
647
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
648
+ set, no client certificate will be used.
649
+
650
+ 3. The ``universe_domain`` property can be used to override the
651
+ default "googleapis.com" universe. Note that the ``api_endpoint``
652
+ property still takes precedence; and ``universe_domain`` is
653
+ currently not supported for mTLS.
654
+
655
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
656
+ The client info used to send a user-agent string along with
657
+ API requests. If ``None``, then default info will be used.
658
+ Generally, you only need to set this if you're developing
659
+ your own client library.
660
+
661
+ Raises:
662
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
663
+ creation failed for any reason.
664
+ """
665
+ self._client_options = client_options
666
+ if isinstance(self._client_options, dict):
667
+ self._client_options = client_options_lib.from_dict(self._client_options)
668
+ if self._client_options is None:
669
+ self._client_options = client_options_lib.ClientOptions()
670
+ self._client_options = cast(
671
+ client_options_lib.ClientOptions, self._client_options
672
+ )
673
+
674
+ universe_domain_opt = getattr(self._client_options, "universe_domain", None)
675
+
676
+ (
677
+ self._use_client_cert,
678
+ self._use_mtls_endpoint,
679
+ self._universe_domain_env,
680
+ ) = DatastreamClient._read_environment_variables()
681
+ self._client_cert_source = DatastreamClient._get_client_cert_source(
682
+ self._client_options.client_cert_source, self._use_client_cert
683
+ )
684
+ self._universe_domain = DatastreamClient._get_universe_domain(
685
+ universe_domain_opt, self._universe_domain_env
686
+ )
687
+ self._api_endpoint = None # updated below, depending on `transport`
688
+
689
+ # Initialize the universe domain validation.
690
+ self._is_universe_domain_valid = False
691
+
692
+ if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
693
+ # Setup logging.
694
+ client_logging.initialize_logging()
695
+
696
+ api_key_value = getattr(self._client_options, "api_key", None)
697
+ if api_key_value and credentials:
698
+ raise ValueError(
699
+ "client_options.api_key and credentials are mutually exclusive"
700
+ )
701
+
702
+ # Save or instantiate the transport.
703
+ # Ordinarily, we provide the transport, but allowing a custom transport
704
+ # instance provides an extensibility point for unusual situations.
705
+ transport_provided = isinstance(transport, DatastreamTransport)
706
+ if transport_provided:
707
+ # transport is a DatastreamTransport instance.
708
+ if credentials or self._client_options.credentials_file or api_key_value:
709
+ raise ValueError(
710
+ "When providing a transport instance, "
711
+ "provide its credentials directly."
712
+ )
713
+ if self._client_options.scopes:
714
+ raise ValueError(
715
+ "When providing a transport instance, provide its scopes "
716
+ "directly."
717
+ )
718
+ self._transport = cast(DatastreamTransport, transport)
719
+ self._api_endpoint = self._transport.host
720
+
721
+ self._api_endpoint = self._api_endpoint or DatastreamClient._get_api_endpoint(
722
+ self._client_options.api_endpoint,
723
+ self._client_cert_source,
724
+ self._universe_domain,
725
+ self._use_mtls_endpoint,
726
+ )
727
+
728
+ if not transport_provided:
729
+ import google.auth._default # type: ignore
730
+
731
+ if api_key_value and hasattr(
732
+ google.auth._default, "get_api_key_credentials"
733
+ ):
734
+ credentials = google.auth._default.get_api_key_credentials(
735
+ api_key_value
736
+ )
737
+
738
+ transport_init: Union[
739
+ Type[DatastreamTransport], Callable[..., DatastreamTransport]
740
+ ] = (
741
+ DatastreamClient.get_transport_class(transport)
742
+ if isinstance(transport, str) or transport is None
743
+ else cast(Callable[..., DatastreamTransport], transport)
744
+ )
745
+ # initialize with the provided callable or the passed in class
746
+ self._transport = transport_init(
747
+ credentials=credentials,
748
+ credentials_file=self._client_options.credentials_file,
749
+ host=self._api_endpoint,
750
+ scopes=self._client_options.scopes,
751
+ client_cert_source_for_mtls=self._client_cert_source,
752
+ quota_project_id=self._client_options.quota_project_id,
753
+ client_info=client_info,
754
+ always_use_jwt_access=True,
755
+ api_audience=self._client_options.api_audience,
756
+ )
757
+
758
+ if "async" not in str(self._transport):
759
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
760
+ std_logging.DEBUG
761
+ ): # pragma: NO COVER
762
+ _LOGGER.debug(
763
+ "Created client `google.cloud.datastream_v1alpha1.DatastreamClient`.",
764
+ extra={
765
+ "serviceName": "google.cloud.datastream.v1alpha1.Datastream",
766
+ "universeDomain": getattr(
767
+ self._transport._credentials, "universe_domain", ""
768
+ ),
769
+ "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
770
+ "credentialsInfo": getattr(
771
+ self.transport._credentials, "get_cred_info", lambda: None
772
+ )(),
773
+ }
774
+ if hasattr(self._transport, "_credentials")
775
+ else {
776
+ "serviceName": "google.cloud.datastream.v1alpha1.Datastream",
777
+ "credentialsType": None,
778
+ },
779
+ )
780
+
781
+ def list_connection_profiles(
782
+ self,
783
+ request: Optional[Union[datastream.ListConnectionProfilesRequest, dict]] = None,
784
+ *,
785
+ parent: Optional[str] = None,
786
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
787
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
788
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
789
+ ) -> pagers.ListConnectionProfilesPager:
790
+ r"""Use this method to list connection profiles created
791
+ in a project and location.
792
+
793
+ .. code-block:: python
794
+
795
+ # This snippet has been automatically generated and should be regarded as a
796
+ # code template only.
797
+ # It will require modifications to work:
798
+ # - It may require correct/in-range values for request initialization.
799
+ # - It may require specifying regional endpoints when creating the service
800
+ # client as shown in:
801
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
802
+ from google.cloud import datastream_v1alpha1
803
+
804
+ def sample_list_connection_profiles():
805
+ # Create a client
806
+ client = datastream_v1alpha1.DatastreamClient()
807
+
808
+ # Initialize request argument(s)
809
+ request = datastream_v1alpha1.ListConnectionProfilesRequest(
810
+ parent="parent_value",
811
+ )
812
+
813
+ # Make the request
814
+ page_result = client.list_connection_profiles(request=request)
815
+
816
+ # Handle the response
817
+ for response in page_result:
818
+ print(response)
819
+
820
+ Args:
821
+ request (Union[google.cloud.datastream_v1alpha1.types.ListConnectionProfilesRequest, dict]):
822
+ The request object.
823
+ parent (str):
824
+ Required. The parent that owns the
825
+ collection of connection profiles.
826
+
827
+ This corresponds to the ``parent`` field
828
+ on the ``request`` instance; if ``request`` is provided, this
829
+ should not be set.
830
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
831
+ should be retried.
832
+ timeout (float): The timeout for this request.
833
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
834
+ sent along with the request as metadata. Normally, each value must be of type `str`,
835
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
836
+ be of type `bytes`.
837
+
838
+ Returns:
839
+ google.cloud.datastream_v1alpha1.services.datastream.pagers.ListConnectionProfilesPager:
840
+ Iterating over this object will yield
841
+ results and resolve additional pages
842
+ automatically.
843
+
844
+ """
845
+ # Create or coerce a protobuf request object.
846
+ # - Quick check: If we got a request object, we should *not* have
847
+ # gotten any keyword arguments that map to the request.
848
+ flattened_params = [parent]
849
+ has_flattened_params = (
850
+ len([param for param in flattened_params if param is not None]) > 0
851
+ )
852
+ if request is not None and has_flattened_params:
853
+ raise ValueError(
854
+ "If the `request` argument is set, then none of "
855
+ "the individual field arguments should be set."
856
+ )
857
+
858
+ # - Use the request object if provided (there's no risk of modifying the input as
859
+ # there are no flattened fields), or create one.
860
+ if not isinstance(request, datastream.ListConnectionProfilesRequest):
861
+ request = datastream.ListConnectionProfilesRequest(request)
862
+ # If we have keyword arguments corresponding to fields on the
863
+ # request, apply these.
864
+ if parent is not None:
865
+ request.parent = parent
866
+
867
+ # Wrap the RPC method; this adds retry and timeout information,
868
+ # and friendly error handling.
869
+ rpc = self._transport._wrapped_methods[self._transport.list_connection_profiles]
870
+
871
+ # Certain fields should be provided within the metadata header;
872
+ # add these here.
873
+ metadata = tuple(metadata) + (
874
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
875
+ )
876
+
877
+ # Validate the universe domain.
878
+ self._validate_universe_domain()
879
+
880
+ # Send the request.
881
+ response = rpc(
882
+ request,
883
+ retry=retry,
884
+ timeout=timeout,
885
+ metadata=metadata,
886
+ )
887
+
888
+ # This method is paged; wrap the response in a pager, which provides
889
+ # an `__iter__` convenience method.
890
+ response = pagers.ListConnectionProfilesPager(
891
+ method=rpc,
892
+ request=request,
893
+ response=response,
894
+ retry=retry,
895
+ timeout=timeout,
896
+ metadata=metadata,
897
+ )
898
+
899
+ # Done; return the response.
900
+ return response
901
+
902
+ def get_connection_profile(
903
+ self,
904
+ request: Optional[Union[datastream.GetConnectionProfileRequest, dict]] = None,
905
+ *,
906
+ name: Optional[str] = None,
907
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
908
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
909
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
910
+ ) -> datastream_resources.ConnectionProfile:
911
+ r"""Use this method to get details about a connection
912
+ profile.
913
+
914
+ .. code-block:: python
915
+
916
+ # This snippet has been automatically generated and should be regarded as a
917
+ # code template only.
918
+ # It will require modifications to work:
919
+ # - It may require correct/in-range values for request initialization.
920
+ # - It may require specifying regional endpoints when creating the service
921
+ # client as shown in:
922
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
923
+ from google.cloud import datastream_v1alpha1
924
+
925
+ def sample_get_connection_profile():
926
+ # Create a client
927
+ client = datastream_v1alpha1.DatastreamClient()
928
+
929
+ # Initialize request argument(s)
930
+ request = datastream_v1alpha1.GetConnectionProfileRequest(
931
+ name="name_value",
932
+ )
933
+
934
+ # Make the request
935
+ response = client.get_connection_profile(request=request)
936
+
937
+ # Handle the response
938
+ print(response)
939
+
940
+ Args:
941
+ request (Union[google.cloud.datastream_v1alpha1.types.GetConnectionProfileRequest, dict]):
942
+ The request object.
943
+ name (str):
944
+ Required. The name of the connection
945
+ profile resource to get.
946
+
947
+ This corresponds to the ``name`` field
948
+ on the ``request`` instance; if ``request`` is provided, this
949
+ should not be set.
950
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
951
+ should be retried.
952
+ timeout (float): The timeout for this request.
953
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
954
+ sent along with the request as metadata. Normally, each value must be of type `str`,
955
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
956
+ be of type `bytes`.
957
+
958
+ Returns:
959
+ google.cloud.datastream_v1alpha1.types.ConnectionProfile:
960
+
961
+ """
962
+ # Create or coerce a protobuf request object.
963
+ # - Quick check: If we got a request object, we should *not* have
964
+ # gotten any keyword arguments that map to the request.
965
+ flattened_params = [name]
966
+ has_flattened_params = (
967
+ len([param for param in flattened_params if param is not None]) > 0
968
+ )
969
+ if request is not None and has_flattened_params:
970
+ raise ValueError(
971
+ "If the `request` argument is set, then none of "
972
+ "the individual field arguments should be set."
973
+ )
974
+
975
+ # - Use the request object if provided (there's no risk of modifying the input as
976
+ # there are no flattened fields), or create one.
977
+ if not isinstance(request, datastream.GetConnectionProfileRequest):
978
+ request = datastream.GetConnectionProfileRequest(request)
979
+ # If we have keyword arguments corresponding to fields on the
980
+ # request, apply these.
981
+ if name is not None:
982
+ request.name = name
983
+
984
+ # Wrap the RPC method; this adds retry and timeout information,
985
+ # and friendly error handling.
986
+ rpc = self._transport._wrapped_methods[self._transport.get_connection_profile]
987
+
988
+ # Certain fields should be provided within the metadata header;
989
+ # add these here.
990
+ metadata = tuple(metadata) + (
991
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
992
+ )
993
+
994
+ # Validate the universe domain.
995
+ self._validate_universe_domain()
996
+
997
+ # Send the request.
998
+ response = rpc(
999
+ request,
1000
+ retry=retry,
1001
+ timeout=timeout,
1002
+ metadata=metadata,
1003
+ )
1004
+
1005
+ # Done; return the response.
1006
+ return response
1007
+
1008
+ def create_connection_profile(
1009
+ self,
1010
+ request: Optional[
1011
+ Union[datastream.CreateConnectionProfileRequest, dict]
1012
+ ] = None,
1013
+ *,
1014
+ parent: Optional[str] = None,
1015
+ connection_profile: Optional[datastream_resources.ConnectionProfile] = None,
1016
+ connection_profile_id: Optional[str] = None,
1017
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1018
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1019
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1020
+ ) -> operation.Operation:
1021
+ r"""Use this method to create a connection profile in a
1022
+ project and location.
1023
+
1024
+ .. code-block:: python
1025
+
1026
+ # This snippet has been automatically generated and should be regarded as a
1027
+ # code template only.
1028
+ # It will require modifications to work:
1029
+ # - It may require correct/in-range values for request initialization.
1030
+ # - It may require specifying regional endpoints when creating the service
1031
+ # client as shown in:
1032
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1033
+ from google.cloud import datastream_v1alpha1
1034
+
1035
+ def sample_create_connection_profile():
1036
+ # Create a client
1037
+ client = datastream_v1alpha1.DatastreamClient()
1038
+
1039
+ # Initialize request argument(s)
1040
+ connection_profile = datastream_v1alpha1.ConnectionProfile()
1041
+ connection_profile.oracle_profile.hostname = "hostname_value"
1042
+ connection_profile.oracle_profile.username = "username_value"
1043
+ connection_profile.oracle_profile.password = "password_value"
1044
+ connection_profile.oracle_profile.database_service = "database_service_value"
1045
+ connection_profile.display_name = "display_name_value"
1046
+
1047
+ request = datastream_v1alpha1.CreateConnectionProfileRequest(
1048
+ parent="parent_value",
1049
+ connection_profile_id="connection_profile_id_value",
1050
+ connection_profile=connection_profile,
1051
+ )
1052
+
1053
+ # Make the request
1054
+ operation = client.create_connection_profile(request=request)
1055
+
1056
+ print("Waiting for operation to complete...")
1057
+
1058
+ response = operation.result()
1059
+
1060
+ # Handle the response
1061
+ print(response)
1062
+
1063
+ Args:
1064
+ request (Union[google.cloud.datastream_v1alpha1.types.CreateConnectionProfileRequest, dict]):
1065
+ The request object.
1066
+ parent (str):
1067
+ Required. The parent that owns the
1068
+ collection of ConnectionProfiles.
1069
+
1070
+ This corresponds to the ``parent`` field
1071
+ on the ``request`` instance; if ``request`` is provided, this
1072
+ should not be set.
1073
+ connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile):
1074
+ Required. The connection profile
1075
+ resource to create.
1076
+
1077
+ This corresponds to the ``connection_profile`` field
1078
+ on the ``request`` instance; if ``request`` is provided, this
1079
+ should not be set.
1080
+ connection_profile_id (str):
1081
+ Required. The connection profile
1082
+ identifier.
1083
+
1084
+ This corresponds to the ``connection_profile_id`` field
1085
+ on the ``request`` instance; if ``request`` is provided, this
1086
+ should not be set.
1087
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1088
+ should be retried.
1089
+ timeout (float): The timeout for this request.
1090
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1091
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1092
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1093
+ be of type `bytes`.
1094
+
1095
+ Returns:
1096
+ google.api_core.operation.Operation:
1097
+ An object representing a long-running operation.
1098
+
1099
+ The result type for the operation will be
1100
+ :class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile`
1101
+
1102
+ """
1103
+ # Create or coerce a protobuf request object.
1104
+ # - Quick check: If we got a request object, we should *not* have
1105
+ # gotten any keyword arguments that map to the request.
1106
+ flattened_params = [parent, connection_profile, connection_profile_id]
1107
+ has_flattened_params = (
1108
+ len([param for param in flattened_params if param is not None]) > 0
1109
+ )
1110
+ if request is not None and has_flattened_params:
1111
+ raise ValueError(
1112
+ "If the `request` argument is set, then none of "
1113
+ "the individual field arguments should be set."
1114
+ )
1115
+
1116
+ # - Use the request object if provided (there's no risk of modifying the input as
1117
+ # there are no flattened fields), or create one.
1118
+ if not isinstance(request, datastream.CreateConnectionProfileRequest):
1119
+ request = datastream.CreateConnectionProfileRequest(request)
1120
+ # If we have keyword arguments corresponding to fields on the
1121
+ # request, apply these.
1122
+ if parent is not None:
1123
+ request.parent = parent
1124
+ if connection_profile is not None:
1125
+ request.connection_profile = connection_profile
1126
+ if connection_profile_id is not None:
1127
+ request.connection_profile_id = connection_profile_id
1128
+
1129
+ # Wrap the RPC method; this adds retry and timeout information,
1130
+ # and friendly error handling.
1131
+ rpc = self._transport._wrapped_methods[
1132
+ self._transport.create_connection_profile
1133
+ ]
1134
+
1135
+ # Certain fields should be provided within the metadata header;
1136
+ # add these here.
1137
+ metadata = tuple(metadata) + (
1138
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1139
+ )
1140
+
1141
+ # Validate the universe domain.
1142
+ self._validate_universe_domain()
1143
+
1144
+ # Send the request.
1145
+ response = rpc(
1146
+ request,
1147
+ retry=retry,
1148
+ timeout=timeout,
1149
+ metadata=metadata,
1150
+ )
1151
+
1152
+ # Wrap the response in an operation future.
1153
+ response = operation.from_gapic(
1154
+ response,
1155
+ self._transport.operations_client,
1156
+ datastream_resources.ConnectionProfile,
1157
+ metadata_type=datastream.OperationMetadata,
1158
+ )
1159
+
1160
+ # Done; return the response.
1161
+ return response
1162
+
1163
+ def update_connection_profile(
1164
+ self,
1165
+ request: Optional[
1166
+ Union[datastream.UpdateConnectionProfileRequest, dict]
1167
+ ] = None,
1168
+ *,
1169
+ connection_profile: Optional[datastream_resources.ConnectionProfile] = None,
1170
+ update_mask: Optional[field_mask_pb2.FieldMask] = None,
1171
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1172
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1173
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1174
+ ) -> operation.Operation:
1175
+ r"""Use this method to update the parameters of a
1176
+ connection profile.
1177
+
1178
+ .. code-block:: python
1179
+
1180
+ # This snippet has been automatically generated and should be regarded as a
1181
+ # code template only.
1182
+ # It will require modifications to work:
1183
+ # - It may require correct/in-range values for request initialization.
1184
+ # - It may require specifying regional endpoints when creating the service
1185
+ # client as shown in:
1186
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1187
+ from google.cloud import datastream_v1alpha1
1188
+
1189
+ def sample_update_connection_profile():
1190
+ # Create a client
1191
+ client = datastream_v1alpha1.DatastreamClient()
1192
+
1193
+ # Initialize request argument(s)
1194
+ connection_profile = datastream_v1alpha1.ConnectionProfile()
1195
+ connection_profile.oracle_profile.hostname = "hostname_value"
1196
+ connection_profile.oracle_profile.username = "username_value"
1197
+ connection_profile.oracle_profile.password = "password_value"
1198
+ connection_profile.oracle_profile.database_service = "database_service_value"
1199
+ connection_profile.display_name = "display_name_value"
1200
+
1201
+ request = datastream_v1alpha1.UpdateConnectionProfileRequest(
1202
+ connection_profile=connection_profile,
1203
+ )
1204
+
1205
+ # Make the request
1206
+ operation = client.update_connection_profile(request=request)
1207
+
1208
+ print("Waiting for operation to complete...")
1209
+
1210
+ response = operation.result()
1211
+
1212
+ # Handle the response
1213
+ print(response)
1214
+
1215
+ Args:
1216
+ request (Union[google.cloud.datastream_v1alpha1.types.UpdateConnectionProfileRequest, dict]):
1217
+ The request object.
1218
+ connection_profile (google.cloud.datastream_v1alpha1.types.ConnectionProfile):
1219
+ Required. The ConnectionProfile to
1220
+ update.
1221
+
1222
+ This corresponds to the ``connection_profile`` field
1223
+ on the ``request`` instance; if ``request`` is provided, this
1224
+ should not be set.
1225
+ update_mask (google.protobuf.field_mask_pb2.FieldMask):
1226
+ Optional. Field mask is used to specify the fields to be
1227
+ overwritten in the ConnectionProfile resource by the
1228
+ update. The fields specified in the update_mask are
1229
+ relative to the resource, not the full request. A field
1230
+ will be overwritten if it is in the mask. If the user
1231
+ does not provide a mask then all fields will be
1232
+ overwritten.
1233
+
1234
+ This corresponds to the ``update_mask`` field
1235
+ on the ``request`` instance; if ``request`` is provided, this
1236
+ should not be set.
1237
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1238
+ should be retried.
1239
+ timeout (float): The timeout for this request.
1240
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1241
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1242
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1243
+ be of type `bytes`.
1244
+
1245
+ Returns:
1246
+ google.api_core.operation.Operation:
1247
+ An object representing a long-running operation.
1248
+
1249
+ The result type for the operation will be
1250
+ :class:`google.cloud.datastream_v1alpha1.types.ConnectionProfile`
1251
+
1252
+ """
1253
+ # Create or coerce a protobuf request object.
1254
+ # - Quick check: If we got a request object, we should *not* have
1255
+ # gotten any keyword arguments that map to the request.
1256
+ flattened_params = [connection_profile, update_mask]
1257
+ has_flattened_params = (
1258
+ len([param for param in flattened_params if param is not None]) > 0
1259
+ )
1260
+ if request is not None and has_flattened_params:
1261
+ raise ValueError(
1262
+ "If the `request` argument is set, then none of "
1263
+ "the individual field arguments should be set."
1264
+ )
1265
+
1266
+ # - Use the request object if provided (there's no risk of modifying the input as
1267
+ # there are no flattened fields), or create one.
1268
+ if not isinstance(request, datastream.UpdateConnectionProfileRequest):
1269
+ request = datastream.UpdateConnectionProfileRequest(request)
1270
+ # If we have keyword arguments corresponding to fields on the
1271
+ # request, apply these.
1272
+ if connection_profile is not None:
1273
+ request.connection_profile = connection_profile
1274
+ if update_mask is not None:
1275
+ request.update_mask = update_mask
1276
+
1277
+ # Wrap the RPC method; this adds retry and timeout information,
1278
+ # and friendly error handling.
1279
+ rpc = self._transport._wrapped_methods[
1280
+ self._transport.update_connection_profile
1281
+ ]
1282
+
1283
+ # Certain fields should be provided within the metadata header;
1284
+ # add these here.
1285
+ metadata = tuple(metadata) + (
1286
+ gapic_v1.routing_header.to_grpc_metadata(
1287
+ (("connection_profile.name", request.connection_profile.name),)
1288
+ ),
1289
+ )
1290
+
1291
+ # Validate the universe domain.
1292
+ self._validate_universe_domain()
1293
+
1294
+ # Send the request.
1295
+ response = rpc(
1296
+ request,
1297
+ retry=retry,
1298
+ timeout=timeout,
1299
+ metadata=metadata,
1300
+ )
1301
+
1302
+ # Wrap the response in an operation future.
1303
+ response = operation.from_gapic(
1304
+ response,
1305
+ self._transport.operations_client,
1306
+ datastream_resources.ConnectionProfile,
1307
+ metadata_type=datastream.OperationMetadata,
1308
+ )
1309
+
1310
+ # Done; return the response.
1311
+ return response
1312
+
1313
+ def delete_connection_profile(
1314
+ self,
1315
+ request: Optional[
1316
+ Union[datastream.DeleteConnectionProfileRequest, dict]
1317
+ ] = None,
1318
+ *,
1319
+ name: Optional[str] = None,
1320
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1321
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1322
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1323
+ ) -> operation.Operation:
1324
+ r"""Use this method to delete a connection profile..
1325
+
1326
+ .. code-block:: python
1327
+
1328
+ # This snippet has been automatically generated and should be regarded as a
1329
+ # code template only.
1330
+ # It will require modifications to work:
1331
+ # - It may require correct/in-range values for request initialization.
1332
+ # - It may require specifying regional endpoints when creating the service
1333
+ # client as shown in:
1334
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1335
+ from google.cloud import datastream_v1alpha1
1336
+
1337
+ def sample_delete_connection_profile():
1338
+ # Create a client
1339
+ client = datastream_v1alpha1.DatastreamClient()
1340
+
1341
+ # Initialize request argument(s)
1342
+ request = datastream_v1alpha1.DeleteConnectionProfileRequest(
1343
+ name="name_value",
1344
+ )
1345
+
1346
+ # Make the request
1347
+ operation = client.delete_connection_profile(request=request)
1348
+
1349
+ print("Waiting for operation to complete...")
1350
+
1351
+ response = operation.result()
1352
+
1353
+ # Handle the response
1354
+ print(response)
1355
+
1356
+ Args:
1357
+ request (Union[google.cloud.datastream_v1alpha1.types.DeleteConnectionProfileRequest, dict]):
1358
+ The request object.
1359
+ name (str):
1360
+ Required. The name of the connection
1361
+ profile resource to delete.
1362
+
1363
+ This corresponds to the ``name`` field
1364
+ on the ``request`` instance; if ``request`` is provided, this
1365
+ should not be set.
1366
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1367
+ should be retried.
1368
+ timeout (float): The timeout for this request.
1369
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1370
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1371
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1372
+ be of type `bytes`.
1373
+
1374
+ Returns:
1375
+ google.api_core.operation.Operation:
1376
+ An object representing a long-running operation.
1377
+
1378
+ 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
1379
+ empty messages in your APIs. A typical example is to
1380
+ use it as the request or the response type of an API
1381
+ method. For instance:
1382
+
1383
+ service Foo {
1384
+ rpc Bar(google.protobuf.Empty) returns
1385
+ (google.protobuf.Empty);
1386
+
1387
+ }
1388
+
1389
+ """
1390
+ # Create or coerce a protobuf request object.
1391
+ # - Quick check: If we got a request object, we should *not* have
1392
+ # gotten any keyword arguments that map to the request.
1393
+ flattened_params = [name]
1394
+ has_flattened_params = (
1395
+ len([param for param in flattened_params if param is not None]) > 0
1396
+ )
1397
+ if request is not None and has_flattened_params:
1398
+ raise ValueError(
1399
+ "If the `request` argument is set, then none of "
1400
+ "the individual field arguments should be set."
1401
+ )
1402
+
1403
+ # - Use the request object if provided (there's no risk of modifying the input as
1404
+ # there are no flattened fields), or create one.
1405
+ if not isinstance(request, datastream.DeleteConnectionProfileRequest):
1406
+ request = datastream.DeleteConnectionProfileRequest(request)
1407
+ # If we have keyword arguments corresponding to fields on the
1408
+ # request, apply these.
1409
+ if name is not None:
1410
+ request.name = name
1411
+
1412
+ # Wrap the RPC method; this adds retry and timeout information,
1413
+ # and friendly error handling.
1414
+ rpc = self._transport._wrapped_methods[
1415
+ self._transport.delete_connection_profile
1416
+ ]
1417
+
1418
+ # Certain fields should be provided within the metadata header;
1419
+ # add these here.
1420
+ metadata = tuple(metadata) + (
1421
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1422
+ )
1423
+
1424
+ # Validate the universe domain.
1425
+ self._validate_universe_domain()
1426
+
1427
+ # Send the request.
1428
+ response = rpc(
1429
+ request,
1430
+ retry=retry,
1431
+ timeout=timeout,
1432
+ metadata=metadata,
1433
+ )
1434
+
1435
+ # Wrap the response in an operation future.
1436
+ response = operation.from_gapic(
1437
+ response,
1438
+ self._transport.operations_client,
1439
+ empty_pb2.Empty,
1440
+ metadata_type=datastream.OperationMetadata,
1441
+ )
1442
+
1443
+ # Done; return the response.
1444
+ return response
1445
+
1446
+ def discover_connection_profile(
1447
+ self,
1448
+ request: Optional[
1449
+ Union[datastream.DiscoverConnectionProfileRequest, dict]
1450
+ ] = None,
1451
+ *,
1452
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1453
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1454
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1455
+ ) -> datastream.DiscoverConnectionProfileResponse:
1456
+ r"""Use this method to discover a connection profile.
1457
+ The discover API call exposes the data objects and
1458
+ metadata belonging to the profile. Typically, a request
1459
+ returns children data objects under a parent data object
1460
+ that's optionally supplied in the request.
1461
+
1462
+ .. code-block:: python
1463
+
1464
+ # This snippet has been automatically generated and should be regarded as a
1465
+ # code template only.
1466
+ # It will require modifications to work:
1467
+ # - It may require correct/in-range values for request initialization.
1468
+ # - It may require specifying regional endpoints when creating the service
1469
+ # client as shown in:
1470
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1471
+ from google.cloud import datastream_v1alpha1
1472
+
1473
+ def sample_discover_connection_profile():
1474
+ # Create a client
1475
+ client = datastream_v1alpha1.DatastreamClient()
1476
+
1477
+ # Initialize request argument(s)
1478
+ connection_profile = datastream_v1alpha1.ConnectionProfile()
1479
+ connection_profile.oracle_profile.hostname = "hostname_value"
1480
+ connection_profile.oracle_profile.username = "username_value"
1481
+ connection_profile.oracle_profile.password = "password_value"
1482
+ connection_profile.oracle_profile.database_service = "database_service_value"
1483
+ connection_profile.display_name = "display_name_value"
1484
+
1485
+ request = datastream_v1alpha1.DiscoverConnectionProfileRequest(
1486
+ connection_profile=connection_profile,
1487
+ recursive=True,
1488
+ parent="parent_value",
1489
+ )
1490
+
1491
+ # Make the request
1492
+ response = client.discover_connection_profile(request=request)
1493
+
1494
+ # Handle the response
1495
+ print(response)
1496
+
1497
+ Args:
1498
+ request (Union[google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileRequest, dict]):
1499
+ The request object. Request message for 'discover'
1500
+ ConnectionProfile request.
1501
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1502
+ should be retried.
1503
+ timeout (float): The timeout for this request.
1504
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1505
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1506
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1507
+ be of type `bytes`.
1508
+
1509
+ Returns:
1510
+ google.cloud.datastream_v1alpha1.types.DiscoverConnectionProfileResponse:
1511
+
1512
+ """
1513
+ # Create or coerce a protobuf request object.
1514
+ # - Use the request object if provided (there's no risk of modifying the input as
1515
+ # there are no flattened fields), or create one.
1516
+ if not isinstance(request, datastream.DiscoverConnectionProfileRequest):
1517
+ request = datastream.DiscoverConnectionProfileRequest(request)
1518
+
1519
+ # Wrap the RPC method; this adds retry and timeout information,
1520
+ # and friendly error handling.
1521
+ rpc = self._transport._wrapped_methods[
1522
+ self._transport.discover_connection_profile
1523
+ ]
1524
+
1525
+ # Certain fields should be provided within the metadata header;
1526
+ # add these here.
1527
+ metadata = tuple(metadata) + (
1528
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1529
+ )
1530
+
1531
+ # Validate the universe domain.
1532
+ self._validate_universe_domain()
1533
+
1534
+ # Send the request.
1535
+ response = rpc(
1536
+ request,
1537
+ retry=retry,
1538
+ timeout=timeout,
1539
+ metadata=metadata,
1540
+ )
1541
+
1542
+ # Done; return the response.
1543
+ return response
1544
+
1545
+ def list_streams(
1546
+ self,
1547
+ request: Optional[Union[datastream.ListStreamsRequest, dict]] = None,
1548
+ *,
1549
+ parent: Optional[str] = None,
1550
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1551
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1552
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1553
+ ) -> pagers.ListStreamsPager:
1554
+ r"""Use this method to list streams in a project and
1555
+ location.
1556
+
1557
+ .. code-block:: python
1558
+
1559
+ # This snippet has been automatically generated and should be regarded as a
1560
+ # code template only.
1561
+ # It will require modifications to work:
1562
+ # - It may require correct/in-range values for request initialization.
1563
+ # - It may require specifying regional endpoints when creating the service
1564
+ # client as shown in:
1565
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1566
+ from google.cloud import datastream_v1alpha1
1567
+
1568
+ def sample_list_streams():
1569
+ # Create a client
1570
+ client = datastream_v1alpha1.DatastreamClient()
1571
+
1572
+ # Initialize request argument(s)
1573
+ request = datastream_v1alpha1.ListStreamsRequest(
1574
+ parent="parent_value",
1575
+ )
1576
+
1577
+ # Make the request
1578
+ page_result = client.list_streams(request=request)
1579
+
1580
+ # Handle the response
1581
+ for response in page_result:
1582
+ print(response)
1583
+
1584
+ Args:
1585
+ request (Union[google.cloud.datastream_v1alpha1.types.ListStreamsRequest, dict]):
1586
+ The request object.
1587
+ parent (str):
1588
+ Required. The parent that owns the
1589
+ collection of streams.
1590
+
1591
+ This corresponds to the ``parent`` field
1592
+ on the ``request`` instance; if ``request`` is provided, this
1593
+ should not be set.
1594
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1595
+ should be retried.
1596
+ timeout (float): The timeout for this request.
1597
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1598
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1599
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1600
+ be of type `bytes`.
1601
+
1602
+ Returns:
1603
+ google.cloud.datastream_v1alpha1.services.datastream.pagers.ListStreamsPager:
1604
+ Iterating over this object will yield
1605
+ results and resolve additional pages
1606
+ automatically.
1607
+
1608
+ """
1609
+ # Create or coerce a protobuf request object.
1610
+ # - Quick check: If we got a request object, we should *not* have
1611
+ # gotten any keyword arguments that map to the request.
1612
+ flattened_params = [parent]
1613
+ has_flattened_params = (
1614
+ len([param for param in flattened_params if param is not None]) > 0
1615
+ )
1616
+ if request is not None and has_flattened_params:
1617
+ raise ValueError(
1618
+ "If the `request` argument is set, then none of "
1619
+ "the individual field arguments should be set."
1620
+ )
1621
+
1622
+ # - Use the request object if provided (there's no risk of modifying the input as
1623
+ # there are no flattened fields), or create one.
1624
+ if not isinstance(request, datastream.ListStreamsRequest):
1625
+ request = datastream.ListStreamsRequest(request)
1626
+ # If we have keyword arguments corresponding to fields on the
1627
+ # request, apply these.
1628
+ if parent is not None:
1629
+ request.parent = parent
1630
+
1631
+ # Wrap the RPC method; this adds retry and timeout information,
1632
+ # and friendly error handling.
1633
+ rpc = self._transport._wrapped_methods[self._transport.list_streams]
1634
+
1635
+ # Certain fields should be provided within the metadata header;
1636
+ # add these here.
1637
+ metadata = tuple(metadata) + (
1638
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1639
+ )
1640
+
1641
+ # Validate the universe domain.
1642
+ self._validate_universe_domain()
1643
+
1644
+ # Send the request.
1645
+ response = rpc(
1646
+ request,
1647
+ retry=retry,
1648
+ timeout=timeout,
1649
+ metadata=metadata,
1650
+ )
1651
+
1652
+ # This method is paged; wrap the response in a pager, which provides
1653
+ # an `__iter__` convenience method.
1654
+ response = pagers.ListStreamsPager(
1655
+ method=rpc,
1656
+ request=request,
1657
+ response=response,
1658
+ retry=retry,
1659
+ timeout=timeout,
1660
+ metadata=metadata,
1661
+ )
1662
+
1663
+ # Done; return the response.
1664
+ return response
1665
+
1666
+ def get_stream(
1667
+ self,
1668
+ request: Optional[Union[datastream.GetStreamRequest, dict]] = None,
1669
+ *,
1670
+ name: Optional[str] = None,
1671
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1672
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1673
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1674
+ ) -> datastream_resources.Stream:
1675
+ r"""Use this method to get details about a stream.
1676
+
1677
+ .. code-block:: python
1678
+
1679
+ # This snippet has been automatically generated and should be regarded as a
1680
+ # code template only.
1681
+ # It will require modifications to work:
1682
+ # - It may require correct/in-range values for request initialization.
1683
+ # - It may require specifying regional endpoints when creating the service
1684
+ # client as shown in:
1685
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1686
+ from google.cloud import datastream_v1alpha1
1687
+
1688
+ def sample_get_stream():
1689
+ # Create a client
1690
+ client = datastream_v1alpha1.DatastreamClient()
1691
+
1692
+ # Initialize request argument(s)
1693
+ request = datastream_v1alpha1.GetStreamRequest(
1694
+ name="name_value",
1695
+ )
1696
+
1697
+ # Make the request
1698
+ response = client.get_stream(request=request)
1699
+
1700
+ # Handle the response
1701
+ print(response)
1702
+
1703
+ Args:
1704
+ request (Union[google.cloud.datastream_v1alpha1.types.GetStreamRequest, dict]):
1705
+ The request object.
1706
+ name (str):
1707
+ Required. The name of the stream
1708
+ resource to get.
1709
+
1710
+ This corresponds to the ``name`` field
1711
+ on the ``request`` instance; if ``request`` is provided, this
1712
+ should not be set.
1713
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1714
+ should be retried.
1715
+ timeout (float): The timeout for this request.
1716
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1717
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1718
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1719
+ be of type `bytes`.
1720
+
1721
+ Returns:
1722
+ google.cloud.datastream_v1alpha1.types.Stream:
1723
+
1724
+ """
1725
+ # Create or coerce a protobuf request object.
1726
+ # - Quick check: If we got a request object, we should *not* have
1727
+ # gotten any keyword arguments that map to the request.
1728
+ flattened_params = [name]
1729
+ has_flattened_params = (
1730
+ len([param for param in flattened_params if param is not None]) > 0
1731
+ )
1732
+ if request is not None and has_flattened_params:
1733
+ raise ValueError(
1734
+ "If the `request` argument is set, then none of "
1735
+ "the individual field arguments should be set."
1736
+ )
1737
+
1738
+ # - Use the request object if provided (there's no risk of modifying the input as
1739
+ # there are no flattened fields), or create one.
1740
+ if not isinstance(request, datastream.GetStreamRequest):
1741
+ request = datastream.GetStreamRequest(request)
1742
+ # If we have keyword arguments corresponding to fields on the
1743
+ # request, apply these.
1744
+ if name is not None:
1745
+ request.name = name
1746
+
1747
+ # Wrap the RPC method; this adds retry and timeout information,
1748
+ # and friendly error handling.
1749
+ rpc = self._transport._wrapped_methods[self._transport.get_stream]
1750
+
1751
+ # Certain fields should be provided within the metadata header;
1752
+ # add these here.
1753
+ metadata = tuple(metadata) + (
1754
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1755
+ )
1756
+
1757
+ # Validate the universe domain.
1758
+ self._validate_universe_domain()
1759
+
1760
+ # Send the request.
1761
+ response = rpc(
1762
+ request,
1763
+ retry=retry,
1764
+ timeout=timeout,
1765
+ metadata=metadata,
1766
+ )
1767
+
1768
+ # Done; return the response.
1769
+ return response
1770
+
1771
+ def create_stream(
1772
+ self,
1773
+ request: Optional[Union[datastream.CreateStreamRequest, dict]] = None,
1774
+ *,
1775
+ parent: Optional[str] = None,
1776
+ stream: Optional[datastream_resources.Stream] = None,
1777
+ stream_id: Optional[str] = None,
1778
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1779
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1780
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1781
+ ) -> operation.Operation:
1782
+ r"""Use this method to create a stream.
1783
+
1784
+ .. code-block:: python
1785
+
1786
+ # This snippet has been automatically generated and should be regarded as a
1787
+ # code template only.
1788
+ # It will require modifications to work:
1789
+ # - It may require correct/in-range values for request initialization.
1790
+ # - It may require specifying regional endpoints when creating the service
1791
+ # client as shown in:
1792
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1793
+ from google.cloud import datastream_v1alpha1
1794
+
1795
+ def sample_create_stream():
1796
+ # Create a client
1797
+ client = datastream_v1alpha1.DatastreamClient()
1798
+
1799
+ # Initialize request argument(s)
1800
+ stream = datastream_v1alpha1.Stream()
1801
+ stream.display_name = "display_name_value"
1802
+ stream.source_config.source_connection_profile_name = "source_connection_profile_name_value"
1803
+ stream.destination_config.destination_connection_profile_name = "destination_connection_profile_name_value"
1804
+
1805
+ request = datastream_v1alpha1.CreateStreamRequest(
1806
+ parent="parent_value",
1807
+ stream_id="stream_id_value",
1808
+ stream=stream,
1809
+ )
1810
+
1811
+ # Make the request
1812
+ operation = client.create_stream(request=request)
1813
+
1814
+ print("Waiting for operation to complete...")
1815
+
1816
+ response = operation.result()
1817
+
1818
+ # Handle the response
1819
+ print(response)
1820
+
1821
+ Args:
1822
+ request (Union[google.cloud.datastream_v1alpha1.types.CreateStreamRequest, dict]):
1823
+ The request object.
1824
+ parent (str):
1825
+ Required. The parent that owns the
1826
+ collection of streams.
1827
+
1828
+ This corresponds to the ``parent`` field
1829
+ on the ``request`` instance; if ``request`` is provided, this
1830
+ should not be set.
1831
+ stream (google.cloud.datastream_v1alpha1.types.Stream):
1832
+ Required. The stream resource to
1833
+ create.
1834
+
1835
+ This corresponds to the ``stream`` field
1836
+ on the ``request`` instance; if ``request`` is provided, this
1837
+ should not be set.
1838
+ stream_id (str):
1839
+ Required. The stream identifier.
1840
+ This corresponds to the ``stream_id`` field
1841
+ on the ``request`` instance; if ``request`` is provided, this
1842
+ should not be set.
1843
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1844
+ should be retried.
1845
+ timeout (float): The timeout for this request.
1846
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1847
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1848
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1849
+ be of type `bytes`.
1850
+
1851
+ Returns:
1852
+ google.api_core.operation.Operation:
1853
+ An object representing a long-running operation.
1854
+
1855
+ The result type for the operation will be
1856
+ :class:`google.cloud.datastream_v1alpha1.types.Stream`
1857
+
1858
+ """
1859
+ # Create or coerce a protobuf request object.
1860
+ # - Quick check: If we got a request object, we should *not* have
1861
+ # gotten any keyword arguments that map to the request.
1862
+ flattened_params = [parent, stream, stream_id]
1863
+ has_flattened_params = (
1864
+ len([param for param in flattened_params if param is not None]) > 0
1865
+ )
1866
+ if request is not None and has_flattened_params:
1867
+ raise ValueError(
1868
+ "If the `request` argument is set, then none of "
1869
+ "the individual field arguments should be set."
1870
+ )
1871
+
1872
+ # - Use the request object if provided (there's no risk of modifying the input as
1873
+ # there are no flattened fields), or create one.
1874
+ if not isinstance(request, datastream.CreateStreamRequest):
1875
+ request = datastream.CreateStreamRequest(request)
1876
+ # If we have keyword arguments corresponding to fields on the
1877
+ # request, apply these.
1878
+ if parent is not None:
1879
+ request.parent = parent
1880
+ if stream is not None:
1881
+ request.stream = stream
1882
+ if stream_id is not None:
1883
+ request.stream_id = stream_id
1884
+
1885
+ # Wrap the RPC method; this adds retry and timeout information,
1886
+ # and friendly error handling.
1887
+ rpc = self._transport._wrapped_methods[self._transport.create_stream]
1888
+
1889
+ # Certain fields should be provided within the metadata header;
1890
+ # add these here.
1891
+ metadata = tuple(metadata) + (
1892
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1893
+ )
1894
+
1895
+ # Validate the universe domain.
1896
+ self._validate_universe_domain()
1897
+
1898
+ # Send the request.
1899
+ response = rpc(
1900
+ request,
1901
+ retry=retry,
1902
+ timeout=timeout,
1903
+ metadata=metadata,
1904
+ )
1905
+
1906
+ # Wrap the response in an operation future.
1907
+ response = operation.from_gapic(
1908
+ response,
1909
+ self._transport.operations_client,
1910
+ datastream_resources.Stream,
1911
+ metadata_type=datastream.OperationMetadata,
1912
+ )
1913
+
1914
+ # Done; return the response.
1915
+ return response
1916
+
1917
+ def update_stream(
1918
+ self,
1919
+ request: Optional[Union[datastream.UpdateStreamRequest, dict]] = None,
1920
+ *,
1921
+ stream: Optional[datastream_resources.Stream] = None,
1922
+ update_mask: Optional[field_mask_pb2.FieldMask] = None,
1923
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1924
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1925
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1926
+ ) -> operation.Operation:
1927
+ r"""Use this method to update the configuration of a
1928
+ stream.
1929
+
1930
+ .. code-block:: python
1931
+
1932
+ # This snippet has been automatically generated and should be regarded as a
1933
+ # code template only.
1934
+ # It will require modifications to work:
1935
+ # - It may require correct/in-range values for request initialization.
1936
+ # - It may require specifying regional endpoints when creating the service
1937
+ # client as shown in:
1938
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1939
+ from google.cloud import datastream_v1alpha1
1940
+
1941
+ def sample_update_stream():
1942
+ # Create a client
1943
+ client = datastream_v1alpha1.DatastreamClient()
1944
+
1945
+ # Initialize request argument(s)
1946
+ stream = datastream_v1alpha1.Stream()
1947
+ stream.display_name = "display_name_value"
1948
+ stream.source_config.source_connection_profile_name = "source_connection_profile_name_value"
1949
+ stream.destination_config.destination_connection_profile_name = "destination_connection_profile_name_value"
1950
+
1951
+ request = datastream_v1alpha1.UpdateStreamRequest(
1952
+ stream=stream,
1953
+ )
1954
+
1955
+ # Make the request
1956
+ operation = client.update_stream(request=request)
1957
+
1958
+ print("Waiting for operation to complete...")
1959
+
1960
+ response = operation.result()
1961
+
1962
+ # Handle the response
1963
+ print(response)
1964
+
1965
+ Args:
1966
+ request (Union[google.cloud.datastream_v1alpha1.types.UpdateStreamRequest, dict]):
1967
+ The request object.
1968
+ stream (google.cloud.datastream_v1alpha1.types.Stream):
1969
+ Required. The stream resource to
1970
+ update.
1971
+
1972
+ This corresponds to the ``stream`` field
1973
+ on the ``request`` instance; if ``request`` is provided, this
1974
+ should not be set.
1975
+ update_mask (google.protobuf.field_mask_pb2.FieldMask):
1976
+ Optional. Field mask is used to specify the fields to be
1977
+ overwritten in the stream resource by the update. The
1978
+ fields specified in the update_mask are relative to the
1979
+ resource, not the full request. A field will be
1980
+ overwritten if it is in the mask. If the user does not
1981
+ provide a mask then all fields will be overwritten.
1982
+
1983
+ This corresponds to the ``update_mask`` field
1984
+ on the ``request`` instance; if ``request`` is provided, this
1985
+ should not be set.
1986
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1987
+ should be retried.
1988
+ timeout (float): The timeout for this request.
1989
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1990
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1991
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1992
+ be of type `bytes`.
1993
+
1994
+ Returns:
1995
+ google.api_core.operation.Operation:
1996
+ An object representing a long-running operation.
1997
+
1998
+ The result type for the operation will be
1999
+ :class:`google.cloud.datastream_v1alpha1.types.Stream`
2000
+
2001
+ """
2002
+ # Create or coerce a protobuf request object.
2003
+ # - Quick check: If we got a request object, we should *not* have
2004
+ # gotten any keyword arguments that map to the request.
2005
+ flattened_params = [stream, update_mask]
2006
+ has_flattened_params = (
2007
+ len([param for param in flattened_params if param is not None]) > 0
2008
+ )
2009
+ if request is not None and has_flattened_params:
2010
+ raise ValueError(
2011
+ "If the `request` argument is set, then none of "
2012
+ "the individual field arguments should be set."
2013
+ )
2014
+
2015
+ # - Use the request object if provided (there's no risk of modifying the input as
2016
+ # there are no flattened fields), or create one.
2017
+ if not isinstance(request, datastream.UpdateStreamRequest):
2018
+ request = datastream.UpdateStreamRequest(request)
2019
+ # If we have keyword arguments corresponding to fields on the
2020
+ # request, apply these.
2021
+ if stream is not None:
2022
+ request.stream = stream
2023
+ if update_mask is not None:
2024
+ request.update_mask = update_mask
2025
+
2026
+ # Wrap the RPC method; this adds retry and timeout information,
2027
+ # and friendly error handling.
2028
+ rpc = self._transport._wrapped_methods[self._transport.update_stream]
2029
+
2030
+ # Certain fields should be provided within the metadata header;
2031
+ # add these here.
2032
+ metadata = tuple(metadata) + (
2033
+ gapic_v1.routing_header.to_grpc_metadata(
2034
+ (("stream.name", request.stream.name),)
2035
+ ),
2036
+ )
2037
+
2038
+ # Validate the universe domain.
2039
+ self._validate_universe_domain()
2040
+
2041
+ # Send the request.
2042
+ response = rpc(
2043
+ request,
2044
+ retry=retry,
2045
+ timeout=timeout,
2046
+ metadata=metadata,
2047
+ )
2048
+
2049
+ # Wrap the response in an operation future.
2050
+ response = operation.from_gapic(
2051
+ response,
2052
+ self._transport.operations_client,
2053
+ datastream_resources.Stream,
2054
+ metadata_type=datastream.OperationMetadata,
2055
+ )
2056
+
2057
+ # Done; return the response.
2058
+ return response
2059
+
2060
+ def delete_stream(
2061
+ self,
2062
+ request: Optional[Union[datastream.DeleteStreamRequest, dict]] = None,
2063
+ *,
2064
+ name: Optional[str] = None,
2065
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2066
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2067
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2068
+ ) -> operation.Operation:
2069
+ r"""Use this method to delete a stream.
2070
+
2071
+ .. code-block:: python
2072
+
2073
+ # This snippet has been automatically generated and should be regarded as a
2074
+ # code template only.
2075
+ # It will require modifications to work:
2076
+ # - It may require correct/in-range values for request initialization.
2077
+ # - It may require specifying regional endpoints when creating the service
2078
+ # client as shown in:
2079
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2080
+ from google.cloud import datastream_v1alpha1
2081
+
2082
+ def sample_delete_stream():
2083
+ # Create a client
2084
+ client = datastream_v1alpha1.DatastreamClient()
2085
+
2086
+ # Initialize request argument(s)
2087
+ request = datastream_v1alpha1.DeleteStreamRequest(
2088
+ name="name_value",
2089
+ )
2090
+
2091
+ # Make the request
2092
+ operation = client.delete_stream(request=request)
2093
+
2094
+ print("Waiting for operation to complete...")
2095
+
2096
+ response = operation.result()
2097
+
2098
+ # Handle the response
2099
+ print(response)
2100
+
2101
+ Args:
2102
+ request (Union[google.cloud.datastream_v1alpha1.types.DeleteStreamRequest, dict]):
2103
+ The request object.
2104
+ name (str):
2105
+ Required. The name of the stream
2106
+ resource to delete.
2107
+
2108
+ This corresponds to the ``name`` field
2109
+ on the ``request`` instance; if ``request`` is provided, this
2110
+ should not be set.
2111
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2112
+ should be retried.
2113
+ timeout (float): The timeout for this request.
2114
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2115
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2116
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2117
+ be of type `bytes`.
2118
+
2119
+ Returns:
2120
+ google.api_core.operation.Operation:
2121
+ An object representing a long-running operation.
2122
+
2123
+ 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
2124
+ empty messages in your APIs. A typical example is to
2125
+ use it as the request or the response type of an API
2126
+ method. For instance:
2127
+
2128
+ service Foo {
2129
+ rpc Bar(google.protobuf.Empty) returns
2130
+ (google.protobuf.Empty);
2131
+
2132
+ }
2133
+
2134
+ """
2135
+ # Create or coerce a protobuf request object.
2136
+ # - Quick check: If we got a request object, we should *not* have
2137
+ # gotten any keyword arguments that map to the request.
2138
+ flattened_params = [name]
2139
+ has_flattened_params = (
2140
+ len([param for param in flattened_params if param is not None]) > 0
2141
+ )
2142
+ if request is not None and has_flattened_params:
2143
+ raise ValueError(
2144
+ "If the `request` argument is set, then none of "
2145
+ "the individual field arguments should be set."
2146
+ )
2147
+
2148
+ # - Use the request object if provided (there's no risk of modifying the input as
2149
+ # there are no flattened fields), or create one.
2150
+ if not isinstance(request, datastream.DeleteStreamRequest):
2151
+ request = datastream.DeleteStreamRequest(request)
2152
+ # If we have keyword arguments corresponding to fields on the
2153
+ # request, apply these.
2154
+ if name is not None:
2155
+ request.name = name
2156
+
2157
+ # Wrap the RPC method; this adds retry and timeout information,
2158
+ # and friendly error handling.
2159
+ rpc = self._transport._wrapped_methods[self._transport.delete_stream]
2160
+
2161
+ # Certain fields should be provided within the metadata header;
2162
+ # add these here.
2163
+ metadata = tuple(metadata) + (
2164
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2165
+ )
2166
+
2167
+ # Validate the universe domain.
2168
+ self._validate_universe_domain()
2169
+
2170
+ # Send the request.
2171
+ response = rpc(
2172
+ request,
2173
+ retry=retry,
2174
+ timeout=timeout,
2175
+ metadata=metadata,
2176
+ )
2177
+
2178
+ # Wrap the response in an operation future.
2179
+ response = operation.from_gapic(
2180
+ response,
2181
+ self._transport.operations_client,
2182
+ empty_pb2.Empty,
2183
+ metadata_type=datastream.OperationMetadata,
2184
+ )
2185
+
2186
+ # Done; return the response.
2187
+ return response
2188
+
2189
+ def fetch_errors(
2190
+ self,
2191
+ request: Optional[Union[datastream.FetchErrorsRequest, dict]] = None,
2192
+ *,
2193
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2194
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2195
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2196
+ ) -> operation.Operation:
2197
+ r"""Use this method to fetch any errors associated with a
2198
+ stream.
2199
+
2200
+ .. code-block:: python
2201
+
2202
+ # This snippet has been automatically generated and should be regarded as a
2203
+ # code template only.
2204
+ # It will require modifications to work:
2205
+ # - It may require correct/in-range values for request initialization.
2206
+ # - It may require specifying regional endpoints when creating the service
2207
+ # client as shown in:
2208
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2209
+ from google.cloud import datastream_v1alpha1
2210
+
2211
+ def sample_fetch_errors():
2212
+ # Create a client
2213
+ client = datastream_v1alpha1.DatastreamClient()
2214
+
2215
+ # Initialize request argument(s)
2216
+ request = datastream_v1alpha1.FetchErrorsRequest(
2217
+ )
2218
+
2219
+ # Make the request
2220
+ operation = client.fetch_errors(request=request)
2221
+
2222
+ print("Waiting for operation to complete...")
2223
+
2224
+ response = operation.result()
2225
+
2226
+ # Handle the response
2227
+ print(response)
2228
+
2229
+ Args:
2230
+ request (Union[google.cloud.datastream_v1alpha1.types.FetchErrorsRequest, dict]):
2231
+ The request object. Request message for 'FetchErrors'
2232
+ request.
2233
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2234
+ should be retried.
2235
+ timeout (float): The timeout for this request.
2236
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2237
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2238
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2239
+ be of type `bytes`.
2240
+
2241
+ Returns:
2242
+ google.api_core.operation.Operation:
2243
+ An object representing a long-running operation.
2244
+
2245
+ The result type for the operation will be
2246
+ :class:`google.cloud.datastream_v1alpha1.types.FetchErrorsResponse`
2247
+ Response message for a 'FetchErrors' response.
2248
+
2249
+ """
2250
+ # Create or coerce a protobuf request object.
2251
+ # - Use the request object if provided (there's no risk of modifying the input as
2252
+ # there are no flattened fields), or create one.
2253
+ if not isinstance(request, datastream.FetchErrorsRequest):
2254
+ request = datastream.FetchErrorsRequest(request)
2255
+
2256
+ # Wrap the RPC method; this adds retry and timeout information,
2257
+ # and friendly error handling.
2258
+ rpc = self._transport._wrapped_methods[self._transport.fetch_errors]
2259
+
2260
+ # Certain fields should be provided within the metadata header;
2261
+ # add these here.
2262
+ metadata = tuple(metadata) + (
2263
+ gapic_v1.routing_header.to_grpc_metadata((("stream", request.stream),)),
2264
+ )
2265
+
2266
+ # Validate the universe domain.
2267
+ self._validate_universe_domain()
2268
+
2269
+ # Send the request.
2270
+ response = rpc(
2271
+ request,
2272
+ retry=retry,
2273
+ timeout=timeout,
2274
+ metadata=metadata,
2275
+ )
2276
+
2277
+ # Wrap the response in an operation future.
2278
+ response = operation.from_gapic(
2279
+ response,
2280
+ self._transport.operations_client,
2281
+ datastream.FetchErrorsResponse,
2282
+ metadata_type=datastream.OperationMetadata,
2283
+ )
2284
+
2285
+ # Done; return the response.
2286
+ return response
2287
+
2288
+ def fetch_static_ips(
2289
+ self,
2290
+ request: Optional[Union[datastream.FetchStaticIpsRequest, dict]] = None,
2291
+ *,
2292
+ name: Optional[str] = None,
2293
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2294
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2295
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2296
+ ) -> pagers.FetchStaticIpsPager:
2297
+ r"""The FetchStaticIps API call exposes the static ips
2298
+ used by Datastream. Typically, a request returns
2299
+ children data objects under a parent data object that's
2300
+ optionally supplied in the request.
2301
+
2302
+ .. code-block:: python
2303
+
2304
+ # This snippet has been automatically generated and should be regarded as a
2305
+ # code template only.
2306
+ # It will require modifications to work:
2307
+ # - It may require correct/in-range values for request initialization.
2308
+ # - It may require specifying regional endpoints when creating the service
2309
+ # client as shown in:
2310
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2311
+ from google.cloud import datastream_v1alpha1
2312
+
2313
+ def sample_fetch_static_ips():
2314
+ # Create a client
2315
+ client = datastream_v1alpha1.DatastreamClient()
2316
+
2317
+ # Initialize request argument(s)
2318
+ request = datastream_v1alpha1.FetchStaticIpsRequest(
2319
+ name="name_value",
2320
+ )
2321
+
2322
+ # Make the request
2323
+ page_result = client.fetch_static_ips(request=request)
2324
+
2325
+ # Handle the response
2326
+ for response in page_result:
2327
+ print(response)
2328
+
2329
+ Args:
2330
+ request (Union[google.cloud.datastream_v1alpha1.types.FetchStaticIpsRequest, dict]):
2331
+ The request object. Request message for 'FetchStaticIps'
2332
+ request.
2333
+ name (str):
2334
+ Required. The name resource of the Response type. Must
2335
+ be in the format ``projects/*/locations/*``.
2336
+
2337
+ This corresponds to the ``name`` field
2338
+ on the ``request`` instance; if ``request`` is provided, this
2339
+ should not be set.
2340
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2341
+ should be retried.
2342
+ timeout (float): The timeout for this request.
2343
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2344
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2345
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2346
+ be of type `bytes`.
2347
+
2348
+ Returns:
2349
+ google.cloud.datastream_v1alpha1.services.datastream.pagers.FetchStaticIpsPager:
2350
+ Response message for a
2351
+ 'FetchStaticIps' response.
2352
+ Iterating over this object will yield
2353
+ results and resolve additional pages
2354
+ automatically.
2355
+
2356
+ """
2357
+ # Create or coerce a protobuf request object.
2358
+ # - Quick check: If we got a request object, we should *not* have
2359
+ # gotten any keyword arguments that map to the request.
2360
+ flattened_params = [name]
2361
+ has_flattened_params = (
2362
+ len([param for param in flattened_params if param is not None]) > 0
2363
+ )
2364
+ if request is not None and has_flattened_params:
2365
+ raise ValueError(
2366
+ "If the `request` argument is set, then none of "
2367
+ "the individual field arguments should be set."
2368
+ )
2369
+
2370
+ # - Use the request object if provided (there's no risk of modifying the input as
2371
+ # there are no flattened fields), or create one.
2372
+ if not isinstance(request, datastream.FetchStaticIpsRequest):
2373
+ request = datastream.FetchStaticIpsRequest(request)
2374
+ # If we have keyword arguments corresponding to fields on the
2375
+ # request, apply these.
2376
+ if name is not None:
2377
+ request.name = name
2378
+
2379
+ # Wrap the RPC method; this adds retry and timeout information,
2380
+ # and friendly error handling.
2381
+ rpc = self._transport._wrapped_methods[self._transport.fetch_static_ips]
2382
+
2383
+ # Certain fields should be provided within the metadata header;
2384
+ # add these here.
2385
+ metadata = tuple(metadata) + (
2386
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2387
+ )
2388
+
2389
+ # Validate the universe domain.
2390
+ self._validate_universe_domain()
2391
+
2392
+ # Send the request.
2393
+ response = rpc(
2394
+ request,
2395
+ retry=retry,
2396
+ timeout=timeout,
2397
+ metadata=metadata,
2398
+ )
2399
+
2400
+ # This method is paged; wrap the response in a pager, which provides
2401
+ # an `__iter__` convenience method.
2402
+ response = pagers.FetchStaticIpsPager(
2403
+ method=rpc,
2404
+ request=request,
2405
+ response=response,
2406
+ retry=retry,
2407
+ timeout=timeout,
2408
+ metadata=metadata,
2409
+ )
2410
+
2411
+ # Done; return the response.
2412
+ return response
2413
+
2414
+ def create_private_connection(
2415
+ self,
2416
+ request: Optional[
2417
+ Union[datastream.CreatePrivateConnectionRequest, dict]
2418
+ ] = None,
2419
+ *,
2420
+ parent: Optional[str] = None,
2421
+ private_connection: Optional[datastream_resources.PrivateConnection] = None,
2422
+ private_connection_id: Optional[str] = None,
2423
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2424
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2425
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2426
+ ) -> operation.Operation:
2427
+ r"""Use this method to create a private connectivity
2428
+ configuration.
2429
+
2430
+ .. code-block:: python
2431
+
2432
+ # This snippet has been automatically generated and should be regarded as a
2433
+ # code template only.
2434
+ # It will require modifications to work:
2435
+ # - It may require correct/in-range values for request initialization.
2436
+ # - It may require specifying regional endpoints when creating the service
2437
+ # client as shown in:
2438
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2439
+ from google.cloud import datastream_v1alpha1
2440
+
2441
+ def sample_create_private_connection():
2442
+ # Create a client
2443
+ client = datastream_v1alpha1.DatastreamClient()
2444
+
2445
+ # Initialize request argument(s)
2446
+ private_connection = datastream_v1alpha1.PrivateConnection()
2447
+ private_connection.display_name = "display_name_value"
2448
+
2449
+ request = datastream_v1alpha1.CreatePrivateConnectionRequest(
2450
+ parent="parent_value",
2451
+ private_connection_id="private_connection_id_value",
2452
+ private_connection=private_connection,
2453
+ )
2454
+
2455
+ # Make the request
2456
+ operation = client.create_private_connection(request=request)
2457
+
2458
+ print("Waiting for operation to complete...")
2459
+
2460
+ response = operation.result()
2461
+
2462
+ # Handle the response
2463
+ print(response)
2464
+
2465
+ Args:
2466
+ request (Union[google.cloud.datastream_v1alpha1.types.CreatePrivateConnectionRequest, dict]):
2467
+ The request object.
2468
+ parent (str):
2469
+ Required. The parent that owns the
2470
+ collection of PrivateConnections.
2471
+
2472
+ This corresponds to the ``parent`` field
2473
+ on the ``request`` instance; if ``request`` is provided, this
2474
+ should not be set.
2475
+ private_connection (google.cloud.datastream_v1alpha1.types.PrivateConnection):
2476
+ Required. The Private Connectivity
2477
+ resource to create.
2478
+
2479
+ This corresponds to the ``private_connection`` field
2480
+ on the ``request`` instance; if ``request`` is provided, this
2481
+ should not be set.
2482
+ private_connection_id (str):
2483
+ Required. The private connectivity
2484
+ identifier.
2485
+
2486
+ This corresponds to the ``private_connection_id`` field
2487
+ on the ``request`` instance; if ``request`` is provided, this
2488
+ should not be set.
2489
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2490
+ should be retried.
2491
+ timeout (float): The timeout for this request.
2492
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2493
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2494
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2495
+ be of type `bytes`.
2496
+
2497
+ Returns:
2498
+ google.api_core.operation.Operation:
2499
+ An object representing a long-running operation.
2500
+
2501
+ The result type for the operation will be :class:`google.cloud.datastream_v1alpha1.types.PrivateConnection` The PrivateConnection resource is used to establish private connectivity
2502
+ between Datastream and a customer's network.
2503
+
2504
+ """
2505
+ # Create or coerce a protobuf request object.
2506
+ # - Quick check: If we got a request object, we should *not* have
2507
+ # gotten any keyword arguments that map to the request.
2508
+ flattened_params = [parent, private_connection, private_connection_id]
2509
+ has_flattened_params = (
2510
+ len([param for param in flattened_params if param is not None]) > 0
2511
+ )
2512
+ if request is not None and has_flattened_params:
2513
+ raise ValueError(
2514
+ "If the `request` argument is set, then none of "
2515
+ "the individual field arguments should be set."
2516
+ )
2517
+
2518
+ # - Use the request object if provided (there's no risk of modifying the input as
2519
+ # there are no flattened fields), or create one.
2520
+ if not isinstance(request, datastream.CreatePrivateConnectionRequest):
2521
+ request = datastream.CreatePrivateConnectionRequest(request)
2522
+ # If we have keyword arguments corresponding to fields on the
2523
+ # request, apply these.
2524
+ if parent is not None:
2525
+ request.parent = parent
2526
+ if private_connection is not None:
2527
+ request.private_connection = private_connection
2528
+ if private_connection_id is not None:
2529
+ request.private_connection_id = private_connection_id
2530
+
2531
+ # Wrap the RPC method; this adds retry and timeout information,
2532
+ # and friendly error handling.
2533
+ rpc = self._transport._wrapped_methods[
2534
+ self._transport.create_private_connection
2535
+ ]
2536
+
2537
+ # Certain fields should be provided within the metadata header;
2538
+ # add these here.
2539
+ metadata = tuple(metadata) + (
2540
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2541
+ )
2542
+
2543
+ # Validate the universe domain.
2544
+ self._validate_universe_domain()
2545
+
2546
+ # Send the request.
2547
+ response = rpc(
2548
+ request,
2549
+ retry=retry,
2550
+ timeout=timeout,
2551
+ metadata=metadata,
2552
+ )
2553
+
2554
+ # Wrap the response in an operation future.
2555
+ response = operation.from_gapic(
2556
+ response,
2557
+ self._transport.operations_client,
2558
+ datastream_resources.PrivateConnection,
2559
+ metadata_type=datastream.OperationMetadata,
2560
+ )
2561
+
2562
+ # Done; return the response.
2563
+ return response
2564
+
2565
+ def get_private_connection(
2566
+ self,
2567
+ request: Optional[Union[datastream.GetPrivateConnectionRequest, dict]] = None,
2568
+ *,
2569
+ name: Optional[str] = None,
2570
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2571
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2572
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2573
+ ) -> datastream_resources.PrivateConnection:
2574
+ r"""Use this method to get details about a private
2575
+ connectivity configuration.
2576
+
2577
+ .. code-block:: python
2578
+
2579
+ # This snippet has been automatically generated and should be regarded as a
2580
+ # code template only.
2581
+ # It will require modifications to work:
2582
+ # - It may require correct/in-range values for request initialization.
2583
+ # - It may require specifying regional endpoints when creating the service
2584
+ # client as shown in:
2585
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2586
+ from google.cloud import datastream_v1alpha1
2587
+
2588
+ def sample_get_private_connection():
2589
+ # Create a client
2590
+ client = datastream_v1alpha1.DatastreamClient()
2591
+
2592
+ # Initialize request argument(s)
2593
+ request = datastream_v1alpha1.GetPrivateConnectionRequest(
2594
+ name="name_value",
2595
+ )
2596
+
2597
+ # Make the request
2598
+ response = client.get_private_connection(request=request)
2599
+
2600
+ # Handle the response
2601
+ print(response)
2602
+
2603
+ Args:
2604
+ request (Union[google.cloud.datastream_v1alpha1.types.GetPrivateConnectionRequest, dict]):
2605
+ The request object.
2606
+ name (str):
2607
+ Required. The name of the private
2608
+ connectivity configuration to get.
2609
+
2610
+ This corresponds to the ``name`` field
2611
+ on the ``request`` instance; if ``request`` is provided, this
2612
+ should not be set.
2613
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2614
+ should be retried.
2615
+ timeout (float): The timeout for this request.
2616
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2617
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2618
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2619
+ be of type `bytes`.
2620
+
2621
+ Returns:
2622
+ google.cloud.datastream_v1alpha1.types.PrivateConnection:
2623
+ The PrivateConnection resource is
2624
+ used to establish private connectivity
2625
+ between Datastream and a customer's
2626
+ network.
2627
+
2628
+ """
2629
+ # Create or coerce a protobuf request object.
2630
+ # - Quick check: If we got a request object, we should *not* have
2631
+ # gotten any keyword arguments that map to the request.
2632
+ flattened_params = [name]
2633
+ has_flattened_params = (
2634
+ len([param for param in flattened_params if param is not None]) > 0
2635
+ )
2636
+ if request is not None and has_flattened_params:
2637
+ raise ValueError(
2638
+ "If the `request` argument is set, then none of "
2639
+ "the individual field arguments should be set."
2640
+ )
2641
+
2642
+ # - Use the request object if provided (there's no risk of modifying the input as
2643
+ # there are no flattened fields), or create one.
2644
+ if not isinstance(request, datastream.GetPrivateConnectionRequest):
2645
+ request = datastream.GetPrivateConnectionRequest(request)
2646
+ # If we have keyword arguments corresponding to fields on the
2647
+ # request, apply these.
2648
+ if name is not None:
2649
+ request.name = name
2650
+
2651
+ # Wrap the RPC method; this adds retry and timeout information,
2652
+ # and friendly error handling.
2653
+ rpc = self._transport._wrapped_methods[self._transport.get_private_connection]
2654
+
2655
+ # Certain fields should be provided within the metadata header;
2656
+ # add these here.
2657
+ metadata = tuple(metadata) + (
2658
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2659
+ )
2660
+
2661
+ # Validate the universe domain.
2662
+ self._validate_universe_domain()
2663
+
2664
+ # Send the request.
2665
+ response = rpc(
2666
+ request,
2667
+ retry=retry,
2668
+ timeout=timeout,
2669
+ metadata=metadata,
2670
+ )
2671
+
2672
+ # Done; return the response.
2673
+ return response
2674
+
2675
+ def list_private_connections(
2676
+ self,
2677
+ request: Optional[Union[datastream.ListPrivateConnectionsRequest, dict]] = None,
2678
+ *,
2679
+ parent: Optional[str] = None,
2680
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2681
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2682
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2683
+ ) -> pagers.ListPrivateConnectionsPager:
2684
+ r"""Use this method to list private connectivity
2685
+ configurations in a project and location.
2686
+
2687
+ .. code-block:: python
2688
+
2689
+ # This snippet has been automatically generated and should be regarded as a
2690
+ # code template only.
2691
+ # It will require modifications to work:
2692
+ # - It may require correct/in-range values for request initialization.
2693
+ # - It may require specifying regional endpoints when creating the service
2694
+ # client as shown in:
2695
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2696
+ from google.cloud import datastream_v1alpha1
2697
+
2698
+ def sample_list_private_connections():
2699
+ # Create a client
2700
+ client = datastream_v1alpha1.DatastreamClient()
2701
+
2702
+ # Initialize request argument(s)
2703
+ request = datastream_v1alpha1.ListPrivateConnectionsRequest(
2704
+ parent="parent_value",
2705
+ )
2706
+
2707
+ # Make the request
2708
+ page_result = client.list_private_connections(request=request)
2709
+
2710
+ # Handle the response
2711
+ for response in page_result:
2712
+ print(response)
2713
+
2714
+ Args:
2715
+ request (Union[google.cloud.datastream_v1alpha1.types.ListPrivateConnectionsRequest, dict]):
2716
+ The request object.
2717
+ parent (str):
2718
+ Required. The parent that owns the
2719
+ collection of private connectivity
2720
+ configurations.
2721
+
2722
+ This corresponds to the ``parent`` field
2723
+ on the ``request`` instance; if ``request`` is provided, this
2724
+ should not be set.
2725
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2726
+ should be retried.
2727
+ timeout (float): The timeout for this request.
2728
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2729
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2730
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2731
+ be of type `bytes`.
2732
+
2733
+ Returns:
2734
+ google.cloud.datastream_v1alpha1.services.datastream.pagers.ListPrivateConnectionsPager:
2735
+ Iterating over this object will yield
2736
+ results and resolve additional pages
2737
+ automatically.
2738
+
2739
+ """
2740
+ # Create or coerce a protobuf request object.
2741
+ # - Quick check: If we got a request object, we should *not* have
2742
+ # gotten any keyword arguments that map to the request.
2743
+ flattened_params = [parent]
2744
+ has_flattened_params = (
2745
+ len([param for param in flattened_params if param is not None]) > 0
2746
+ )
2747
+ if request is not None and has_flattened_params:
2748
+ raise ValueError(
2749
+ "If the `request` argument is set, then none of "
2750
+ "the individual field arguments should be set."
2751
+ )
2752
+
2753
+ # - Use the request object if provided (there's no risk of modifying the input as
2754
+ # there are no flattened fields), or create one.
2755
+ if not isinstance(request, datastream.ListPrivateConnectionsRequest):
2756
+ request = datastream.ListPrivateConnectionsRequest(request)
2757
+ # If we have keyword arguments corresponding to fields on the
2758
+ # request, apply these.
2759
+ if parent is not None:
2760
+ request.parent = parent
2761
+
2762
+ # Wrap the RPC method; this adds retry and timeout information,
2763
+ # and friendly error handling.
2764
+ rpc = self._transport._wrapped_methods[self._transport.list_private_connections]
2765
+
2766
+ # Certain fields should be provided within the metadata header;
2767
+ # add these here.
2768
+ metadata = tuple(metadata) + (
2769
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2770
+ )
2771
+
2772
+ # Validate the universe domain.
2773
+ self._validate_universe_domain()
2774
+
2775
+ # Send the request.
2776
+ response = rpc(
2777
+ request,
2778
+ retry=retry,
2779
+ timeout=timeout,
2780
+ metadata=metadata,
2781
+ )
2782
+
2783
+ # This method is paged; wrap the response in a pager, which provides
2784
+ # an `__iter__` convenience method.
2785
+ response = pagers.ListPrivateConnectionsPager(
2786
+ method=rpc,
2787
+ request=request,
2788
+ response=response,
2789
+ retry=retry,
2790
+ timeout=timeout,
2791
+ metadata=metadata,
2792
+ )
2793
+
2794
+ # Done; return the response.
2795
+ return response
2796
+
2797
+ def delete_private_connection(
2798
+ self,
2799
+ request: Optional[
2800
+ Union[datastream.DeletePrivateConnectionRequest, dict]
2801
+ ] = None,
2802
+ *,
2803
+ name: Optional[str] = None,
2804
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2805
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2806
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2807
+ ) -> operation.Operation:
2808
+ r"""Use this method to delete a private connectivity
2809
+ configuration.
2810
+
2811
+ .. code-block:: python
2812
+
2813
+ # This snippet has been automatically generated and should be regarded as a
2814
+ # code template only.
2815
+ # It will require modifications to work:
2816
+ # - It may require correct/in-range values for request initialization.
2817
+ # - It may require specifying regional endpoints when creating the service
2818
+ # client as shown in:
2819
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2820
+ from google.cloud import datastream_v1alpha1
2821
+
2822
+ def sample_delete_private_connection():
2823
+ # Create a client
2824
+ client = datastream_v1alpha1.DatastreamClient()
2825
+
2826
+ # Initialize request argument(s)
2827
+ request = datastream_v1alpha1.DeletePrivateConnectionRequest(
2828
+ name="name_value",
2829
+ )
2830
+
2831
+ # Make the request
2832
+ operation = client.delete_private_connection(request=request)
2833
+
2834
+ print("Waiting for operation to complete...")
2835
+
2836
+ response = operation.result()
2837
+
2838
+ # Handle the response
2839
+ print(response)
2840
+
2841
+ Args:
2842
+ request (Union[google.cloud.datastream_v1alpha1.types.DeletePrivateConnectionRequest, dict]):
2843
+ The request object.
2844
+ name (str):
2845
+ Required. The name of the private
2846
+ connectivity configuration to delete.
2847
+
2848
+ This corresponds to the ``name`` field
2849
+ on the ``request`` instance; if ``request`` is provided, this
2850
+ should not be set.
2851
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2852
+ should be retried.
2853
+ timeout (float): The timeout for this request.
2854
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2855
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2856
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2857
+ be of type `bytes`.
2858
+
2859
+ Returns:
2860
+ google.api_core.operation.Operation:
2861
+ An object representing a long-running operation.
2862
+
2863
+ 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
2864
+ empty messages in your APIs. A typical example is to
2865
+ use it as the request or the response type of an API
2866
+ method. For instance:
2867
+
2868
+ service Foo {
2869
+ rpc Bar(google.protobuf.Empty) returns
2870
+ (google.protobuf.Empty);
2871
+
2872
+ }
2873
+
2874
+ """
2875
+ # Create or coerce a protobuf request object.
2876
+ # - Quick check: If we got a request object, we should *not* have
2877
+ # gotten any keyword arguments that map to the request.
2878
+ flattened_params = [name]
2879
+ has_flattened_params = (
2880
+ len([param for param in flattened_params if param is not None]) > 0
2881
+ )
2882
+ if request is not None and has_flattened_params:
2883
+ raise ValueError(
2884
+ "If the `request` argument is set, then none of "
2885
+ "the individual field arguments should be set."
2886
+ )
2887
+
2888
+ # - Use the request object if provided (there's no risk of modifying the input as
2889
+ # there are no flattened fields), or create one.
2890
+ if not isinstance(request, datastream.DeletePrivateConnectionRequest):
2891
+ request = datastream.DeletePrivateConnectionRequest(request)
2892
+ # If we have keyword arguments corresponding to fields on the
2893
+ # request, apply these.
2894
+ if name is not None:
2895
+ request.name = name
2896
+
2897
+ # Wrap the RPC method; this adds retry and timeout information,
2898
+ # and friendly error handling.
2899
+ rpc = self._transport._wrapped_methods[
2900
+ self._transport.delete_private_connection
2901
+ ]
2902
+
2903
+ # Certain fields should be provided within the metadata header;
2904
+ # add these here.
2905
+ metadata = tuple(metadata) + (
2906
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2907
+ )
2908
+
2909
+ # Validate the universe domain.
2910
+ self._validate_universe_domain()
2911
+
2912
+ # Send the request.
2913
+ response = rpc(
2914
+ request,
2915
+ retry=retry,
2916
+ timeout=timeout,
2917
+ metadata=metadata,
2918
+ )
2919
+
2920
+ # Wrap the response in an operation future.
2921
+ response = operation.from_gapic(
2922
+ response,
2923
+ self._transport.operations_client,
2924
+ empty_pb2.Empty,
2925
+ metadata_type=datastream.OperationMetadata,
2926
+ )
2927
+
2928
+ # Done; return the response.
2929
+ return response
2930
+
2931
+ def create_route(
2932
+ self,
2933
+ request: Optional[Union[datastream.CreateRouteRequest, dict]] = None,
2934
+ *,
2935
+ parent: Optional[str] = None,
2936
+ route: Optional[datastream_resources.Route] = None,
2937
+ route_id: Optional[str] = None,
2938
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2939
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2940
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2941
+ ) -> operation.Operation:
2942
+ r"""Use this method to create a route for a private
2943
+ connectivity in a project and location.
2944
+
2945
+ .. code-block:: python
2946
+
2947
+ # This snippet has been automatically generated and should be regarded as a
2948
+ # code template only.
2949
+ # It will require modifications to work:
2950
+ # - It may require correct/in-range values for request initialization.
2951
+ # - It may require specifying regional endpoints when creating the service
2952
+ # client as shown in:
2953
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
2954
+ from google.cloud import datastream_v1alpha1
2955
+
2956
+ def sample_create_route():
2957
+ # Create a client
2958
+ client = datastream_v1alpha1.DatastreamClient()
2959
+
2960
+ # Initialize request argument(s)
2961
+ route = datastream_v1alpha1.Route()
2962
+ route.display_name = "display_name_value"
2963
+ route.destination_address = "destination_address_value"
2964
+
2965
+ request = datastream_v1alpha1.CreateRouteRequest(
2966
+ parent="parent_value",
2967
+ route_id="route_id_value",
2968
+ route=route,
2969
+ )
2970
+
2971
+ # Make the request
2972
+ operation = client.create_route(request=request)
2973
+
2974
+ print("Waiting for operation to complete...")
2975
+
2976
+ response = operation.result()
2977
+
2978
+ # Handle the response
2979
+ print(response)
2980
+
2981
+ Args:
2982
+ request (Union[google.cloud.datastream_v1alpha1.types.CreateRouteRequest, dict]):
2983
+ The request object. route creation request
2984
+ parent (str):
2985
+ Required. The parent that owns the
2986
+ collection of Routes.
2987
+
2988
+ This corresponds to the ``parent`` field
2989
+ on the ``request`` instance; if ``request`` is provided, this
2990
+ should not be set.
2991
+ route (google.cloud.datastream_v1alpha1.types.Route):
2992
+ Required. The Route resource to
2993
+ create.
2994
+
2995
+ This corresponds to the ``route`` field
2996
+ on the ``request`` instance; if ``request`` is provided, this
2997
+ should not be set.
2998
+ route_id (str):
2999
+ Required. The Route identifier.
3000
+ This corresponds to the ``route_id`` field
3001
+ on the ``request`` instance; if ``request`` is provided, this
3002
+ should not be set.
3003
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3004
+ should be retried.
3005
+ timeout (float): The timeout for this request.
3006
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3007
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3008
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3009
+ be of type `bytes`.
3010
+
3011
+ Returns:
3012
+ google.api_core.operation.Operation:
3013
+ An object representing a long-running operation.
3014
+
3015
+ The result type for the operation will be :class:`google.cloud.datastream_v1alpha1.types.Route` The Route resource is the child of the PrivateConnection resource.
3016
+ It used to define a route for a PrivateConnection
3017
+ setup.
3018
+
3019
+ """
3020
+ # Create or coerce a protobuf request object.
3021
+ # - Quick check: If we got a request object, we should *not* have
3022
+ # gotten any keyword arguments that map to the request.
3023
+ flattened_params = [parent, route, route_id]
3024
+ has_flattened_params = (
3025
+ len([param for param in flattened_params if param is not None]) > 0
3026
+ )
3027
+ if request is not None and has_flattened_params:
3028
+ raise ValueError(
3029
+ "If the `request` argument is set, then none of "
3030
+ "the individual field arguments should be set."
3031
+ )
3032
+
3033
+ # - Use the request object if provided (there's no risk of modifying the input as
3034
+ # there are no flattened fields), or create one.
3035
+ if not isinstance(request, datastream.CreateRouteRequest):
3036
+ request = datastream.CreateRouteRequest(request)
3037
+ # If we have keyword arguments corresponding to fields on the
3038
+ # request, apply these.
3039
+ if parent is not None:
3040
+ request.parent = parent
3041
+ if route is not None:
3042
+ request.route = route
3043
+ if route_id is not None:
3044
+ request.route_id = route_id
3045
+
3046
+ # Wrap the RPC method; this adds retry and timeout information,
3047
+ # and friendly error handling.
3048
+ rpc = self._transport._wrapped_methods[self._transport.create_route]
3049
+
3050
+ # Certain fields should be provided within the metadata header;
3051
+ # add these here.
3052
+ metadata = tuple(metadata) + (
3053
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
3054
+ )
3055
+
3056
+ # Validate the universe domain.
3057
+ self._validate_universe_domain()
3058
+
3059
+ # Send the request.
3060
+ response = rpc(
3061
+ request,
3062
+ retry=retry,
3063
+ timeout=timeout,
3064
+ metadata=metadata,
3065
+ )
3066
+
3067
+ # Wrap the response in an operation future.
3068
+ response = operation.from_gapic(
3069
+ response,
3070
+ self._transport.operations_client,
3071
+ datastream_resources.Route,
3072
+ metadata_type=datastream.OperationMetadata,
3073
+ )
3074
+
3075
+ # Done; return the response.
3076
+ return response
3077
+
3078
+ def get_route(
3079
+ self,
3080
+ request: Optional[Union[datastream.GetRouteRequest, dict]] = None,
3081
+ *,
3082
+ name: Optional[str] = None,
3083
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3084
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3085
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3086
+ ) -> datastream_resources.Route:
3087
+ r"""Use this method to get details about a route.
3088
+
3089
+ .. code-block:: python
3090
+
3091
+ # This snippet has been automatically generated and should be regarded as a
3092
+ # code template only.
3093
+ # It will require modifications to work:
3094
+ # - It may require correct/in-range values for request initialization.
3095
+ # - It may require specifying regional endpoints when creating the service
3096
+ # client as shown in:
3097
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3098
+ from google.cloud import datastream_v1alpha1
3099
+
3100
+ def sample_get_route():
3101
+ # Create a client
3102
+ client = datastream_v1alpha1.DatastreamClient()
3103
+
3104
+ # Initialize request argument(s)
3105
+ request = datastream_v1alpha1.GetRouteRequest(
3106
+ name="name_value",
3107
+ )
3108
+
3109
+ # Make the request
3110
+ response = client.get_route(request=request)
3111
+
3112
+ # Handle the response
3113
+ print(response)
3114
+
3115
+ Args:
3116
+ request (Union[google.cloud.datastream_v1alpha1.types.GetRouteRequest, dict]):
3117
+ The request object. route get request
3118
+ name (str):
3119
+ Required. The name of the Route
3120
+ resource to get.
3121
+
3122
+ This corresponds to the ``name`` field
3123
+ on the ``request`` instance; if ``request`` is provided, this
3124
+ should not be set.
3125
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3126
+ should be retried.
3127
+ timeout (float): The timeout for this request.
3128
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3129
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3130
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3131
+ be of type `bytes`.
3132
+
3133
+ Returns:
3134
+ google.cloud.datastream_v1alpha1.types.Route:
3135
+ The Route resource is the child of
3136
+ the PrivateConnection resource. It used
3137
+ to define a route for a
3138
+ PrivateConnection setup.
3139
+
3140
+ """
3141
+ # Create or coerce a protobuf request object.
3142
+ # - Quick check: If we got a request object, we should *not* have
3143
+ # gotten any keyword arguments that map to the request.
3144
+ flattened_params = [name]
3145
+ has_flattened_params = (
3146
+ len([param for param in flattened_params if param is not None]) > 0
3147
+ )
3148
+ if request is not None and has_flattened_params:
3149
+ raise ValueError(
3150
+ "If the `request` argument is set, then none of "
3151
+ "the individual field arguments should be set."
3152
+ )
3153
+
3154
+ # - Use the request object if provided (there's no risk of modifying the input as
3155
+ # there are no flattened fields), or create one.
3156
+ if not isinstance(request, datastream.GetRouteRequest):
3157
+ request = datastream.GetRouteRequest(request)
3158
+ # If we have keyword arguments corresponding to fields on the
3159
+ # request, apply these.
3160
+ if name is not None:
3161
+ request.name = name
3162
+
3163
+ # Wrap the RPC method; this adds retry and timeout information,
3164
+ # and friendly error handling.
3165
+ rpc = self._transport._wrapped_methods[self._transport.get_route]
3166
+
3167
+ # Certain fields should be provided within the metadata header;
3168
+ # add these here.
3169
+ metadata = tuple(metadata) + (
3170
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3171
+ )
3172
+
3173
+ # Validate the universe domain.
3174
+ self._validate_universe_domain()
3175
+
3176
+ # Send the request.
3177
+ response = rpc(
3178
+ request,
3179
+ retry=retry,
3180
+ timeout=timeout,
3181
+ metadata=metadata,
3182
+ )
3183
+
3184
+ # Done; return the response.
3185
+ return response
3186
+
3187
+ def list_routes(
3188
+ self,
3189
+ request: Optional[Union[datastream.ListRoutesRequest, dict]] = None,
3190
+ *,
3191
+ parent: Optional[str] = None,
3192
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3193
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3194
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3195
+ ) -> pagers.ListRoutesPager:
3196
+ r"""Use this method to list routes created for a private
3197
+ connectivity in a project and location.
3198
+
3199
+ .. code-block:: python
3200
+
3201
+ # This snippet has been automatically generated and should be regarded as a
3202
+ # code template only.
3203
+ # It will require modifications to work:
3204
+ # - It may require correct/in-range values for request initialization.
3205
+ # - It may require specifying regional endpoints when creating the service
3206
+ # client as shown in:
3207
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3208
+ from google.cloud import datastream_v1alpha1
3209
+
3210
+ def sample_list_routes():
3211
+ # Create a client
3212
+ client = datastream_v1alpha1.DatastreamClient()
3213
+
3214
+ # Initialize request argument(s)
3215
+ request = datastream_v1alpha1.ListRoutesRequest(
3216
+ parent="parent_value",
3217
+ )
3218
+
3219
+ # Make the request
3220
+ page_result = client.list_routes(request=request)
3221
+
3222
+ # Handle the response
3223
+ for response in page_result:
3224
+ print(response)
3225
+
3226
+ Args:
3227
+ request (Union[google.cloud.datastream_v1alpha1.types.ListRoutesRequest, dict]):
3228
+ The request object. route list request
3229
+ parent (str):
3230
+ Required. The parent that owns the
3231
+ collection of Routess.
3232
+
3233
+ This corresponds to the ``parent`` field
3234
+ on the ``request`` instance; if ``request`` is provided, this
3235
+ should not be set.
3236
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3237
+ should be retried.
3238
+ timeout (float): The timeout for this request.
3239
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3240
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3241
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3242
+ be of type `bytes`.
3243
+
3244
+ Returns:
3245
+ google.cloud.datastream_v1alpha1.services.datastream.pagers.ListRoutesPager:
3246
+ route list response
3247
+
3248
+ Iterating over this object will yield
3249
+ results and resolve additional pages
3250
+ automatically.
3251
+
3252
+ """
3253
+ # Create or coerce a protobuf request object.
3254
+ # - Quick check: If we got a request object, we should *not* have
3255
+ # gotten any keyword arguments that map to the request.
3256
+ flattened_params = [parent]
3257
+ has_flattened_params = (
3258
+ len([param for param in flattened_params if param is not None]) > 0
3259
+ )
3260
+ if request is not None and has_flattened_params:
3261
+ raise ValueError(
3262
+ "If the `request` argument is set, then none of "
3263
+ "the individual field arguments should be set."
3264
+ )
3265
+
3266
+ # - Use the request object if provided (there's no risk of modifying the input as
3267
+ # there are no flattened fields), or create one.
3268
+ if not isinstance(request, datastream.ListRoutesRequest):
3269
+ request = datastream.ListRoutesRequest(request)
3270
+ # If we have keyword arguments corresponding to fields on the
3271
+ # request, apply these.
3272
+ if parent is not None:
3273
+ request.parent = parent
3274
+
3275
+ # Wrap the RPC method; this adds retry and timeout information,
3276
+ # and friendly error handling.
3277
+ rpc = self._transport._wrapped_methods[self._transport.list_routes]
3278
+
3279
+ # Certain fields should be provided within the metadata header;
3280
+ # add these here.
3281
+ metadata = tuple(metadata) + (
3282
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
3283
+ )
3284
+
3285
+ # Validate the universe domain.
3286
+ self._validate_universe_domain()
3287
+
3288
+ # Send the request.
3289
+ response = rpc(
3290
+ request,
3291
+ retry=retry,
3292
+ timeout=timeout,
3293
+ metadata=metadata,
3294
+ )
3295
+
3296
+ # This method is paged; wrap the response in a pager, which provides
3297
+ # an `__iter__` convenience method.
3298
+ response = pagers.ListRoutesPager(
3299
+ method=rpc,
3300
+ request=request,
3301
+ response=response,
3302
+ retry=retry,
3303
+ timeout=timeout,
3304
+ metadata=metadata,
3305
+ )
3306
+
3307
+ # Done; return the response.
3308
+ return response
3309
+
3310
+ def delete_route(
3311
+ self,
3312
+ request: Optional[Union[datastream.DeleteRouteRequest, dict]] = None,
3313
+ *,
3314
+ name: Optional[str] = None,
3315
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
3316
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3317
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
3318
+ ) -> operation.Operation:
3319
+ r"""Use this method to delete a route.
3320
+
3321
+ .. code-block:: python
3322
+
3323
+ # This snippet has been automatically generated and should be regarded as a
3324
+ # code template only.
3325
+ # It will require modifications to work:
3326
+ # - It may require correct/in-range values for request initialization.
3327
+ # - It may require specifying regional endpoints when creating the service
3328
+ # client as shown in:
3329
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
3330
+ from google.cloud import datastream_v1alpha1
3331
+
3332
+ def sample_delete_route():
3333
+ # Create a client
3334
+ client = datastream_v1alpha1.DatastreamClient()
3335
+
3336
+ # Initialize request argument(s)
3337
+ request = datastream_v1alpha1.DeleteRouteRequest(
3338
+ name="name_value",
3339
+ )
3340
+
3341
+ # Make the request
3342
+ operation = client.delete_route(request=request)
3343
+
3344
+ print("Waiting for operation to complete...")
3345
+
3346
+ response = operation.result()
3347
+
3348
+ # Handle the response
3349
+ print(response)
3350
+
3351
+ Args:
3352
+ request (Union[google.cloud.datastream_v1alpha1.types.DeleteRouteRequest, dict]):
3353
+ The request object. route deletion request
3354
+ name (str):
3355
+ Required. The name of the Route
3356
+ resource to delete.
3357
+
3358
+ This corresponds to the ``name`` field
3359
+ on the ``request`` instance; if ``request`` is provided, this
3360
+ should not be set.
3361
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
3362
+ should be retried.
3363
+ timeout (float): The timeout for this request.
3364
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
3365
+ sent along with the request as metadata. Normally, each value must be of type `str`,
3366
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
3367
+ be of type `bytes`.
3368
+
3369
+ Returns:
3370
+ google.api_core.operation.Operation:
3371
+ An object representing a long-running operation.
3372
+
3373
+ 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
3374
+ empty messages in your APIs. A typical example is to
3375
+ use it as the request or the response type of an API
3376
+ method. For instance:
3377
+
3378
+ service Foo {
3379
+ rpc Bar(google.protobuf.Empty) returns
3380
+ (google.protobuf.Empty);
3381
+
3382
+ }
3383
+
3384
+ """
3385
+ # Create or coerce a protobuf request object.
3386
+ # - Quick check: If we got a request object, we should *not* have
3387
+ # gotten any keyword arguments that map to the request.
3388
+ flattened_params = [name]
3389
+ has_flattened_params = (
3390
+ len([param for param in flattened_params if param is not None]) > 0
3391
+ )
3392
+ if request is not None and has_flattened_params:
3393
+ raise ValueError(
3394
+ "If the `request` argument is set, then none of "
3395
+ "the individual field arguments should be set."
3396
+ )
3397
+
3398
+ # - Use the request object if provided (there's no risk of modifying the input as
3399
+ # there are no flattened fields), or create one.
3400
+ if not isinstance(request, datastream.DeleteRouteRequest):
3401
+ request = datastream.DeleteRouteRequest(request)
3402
+ # If we have keyword arguments corresponding to fields on the
3403
+ # request, apply these.
3404
+ if name is not None:
3405
+ request.name = name
3406
+
3407
+ # Wrap the RPC method; this adds retry and timeout information,
3408
+ # and friendly error handling.
3409
+ rpc = self._transport._wrapped_methods[self._transport.delete_route]
3410
+
3411
+ # Certain fields should be provided within the metadata header;
3412
+ # add these here.
3413
+ metadata = tuple(metadata) + (
3414
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3415
+ )
3416
+
3417
+ # Validate the universe domain.
3418
+ self._validate_universe_domain()
3419
+
3420
+ # Send the request.
3421
+ response = rpc(
3422
+ request,
3423
+ retry=retry,
3424
+ timeout=timeout,
3425
+ metadata=metadata,
3426
+ )
3427
+
3428
+ # Wrap the response in an operation future.
3429
+ response = operation.from_gapic(
3430
+ response,
3431
+ self._transport.operations_client,
3432
+ empty_pb2.Empty,
3433
+ metadata_type=datastream.OperationMetadata,
3434
+ )
3435
+
3436
+ # Done; return the response.
3437
+ return response
3438
+
3439
+ def __enter__(self) -> "DatastreamClient":
3440
+ return self
3441
+
3442
+ def __exit__(self, type, value, traceback):
3443
+ """Releases underlying transport's resources.
3444
+
3445
+ .. warning::
3446
+ ONLY use as a context manager if the transport is NOT shared
3447
+ with other clients! Exiting the with block will CLOSE the transport
3448
+ and may cause errors in other clients!
3449
+ """
3450
+ self.transport.close()
3451
+
3452
+
3453
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
3454
+ gapic_version=package_version.__version__
3455
+ )
3456
+
3457
+
3458
+ __all__ = ("DatastreamClient",)